@tng-sh/mcp-server
v1.0.6
Published
MCP server for TNG test generation and code auditing
Maintainers
Readme
TNG MCP Server
Model Context Protocol server for TNG - Bring AI-powered test generation and code auditing to any AI assistant
This MCP server exposes TNG's test generation and code auditing capabilities to AI assistants like Claude Desktop, Cursor, Antigravity, and any other MCP-compatible tool.
What is MCP?
The Model Context Protocol allows AI assistants to interact with external tools and services. With this MCP server, you can ask your AI assistant questions like:
- "Audit the
process_paymentmethod inapp/services/payment_processor.rb" - "Generate comprehensive tests for the UserController#create method"
- "What can TNG do here?"
And the AI will use TNG automatically to provide detailed, actionable results.
Features
- Method Auditing - Deep analysis for bugs, security issues, and performance problems
- Test Generation - Automatic test creation for Ruby, Python, and JavaScript
- Symbolic Trace - Execution path analysis for debugging and understanding code flow
- Clone Detection - Find duplicate code with token-based, structural, and fuzzy matching
- Dead Code Detection - Identify unused imports, variables, functions, and unreachable code
- Capabilities Listing - List available TNG MCP tools and when to use them
- Multi-Language Support - Works with Ruby, Python, JavaScript/TypeScript
- Universal Integration - Works with any MCP-compatible AI assistant
Prerequisites
IMPORTANT: The TNG MCP server works just like the VSCode extension - it assumes you already have TNG installed and configured in your project.
Step 1: Install TNG in Your Project
Choose based on your project type:
For Ruby Projects
- Add to your
Gemfile:gem 'tng' - Run:
bundle install - Get API key from tng.sh
- Configure:
rails generate tng:installor setTNG_API_KEYenvironment variable
####For Python Projects
- Install TNG:
- pip:
pip install tng-python - uv:
uv add tng-python - Poetry:
poetry add tng-python
- pip:
- Get API key from tng.sh
- Configure: Run
tng initor setTNG_API_KEYenvironment variable
For Node.js Projects
- Install TNG:
npm install tng-js - Get API key from tng.sh
- Configure: Set
TNG_API_KEYin your.envfile
Step 2: Install MCP Server
After TNG is working in your project:
Option 1: Install from npm (when published)
npm install -g @tng-sh/mcp-serverOption 2: Install from source (for development)
cd /path/to/tng-mcp
npm install
npm run build
npm linkConfiguration
For Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"tng": {
"command": "tng-mcp"
}
}
}For Cursor
Add to your project's .cursor/mcp_config.json:
{
"mcpServers": {
"tng": {
"command": "npx",
"args": ["-y", "@tng-sh/mcp-server"]
}
}
}For Other MCP Clients
The server runs on stdio, so configure it as:
Command: tng-mcpEnvironment Configuration (Ruby/Python/JS + Version Managers)
If you use version managers like mise, asdf, rbenv, pyenv, or uv, the MCP server might not find the correct language environment by default. You can fix this by adding environment variables to your MCP config.
The most reliable setup is to specify the TNG command per language, so mixed Ruby + JS + Python repos work correctly:
{
"mcpServers": {
"tng": {
"command": "tng-mcp",
"env": {
"TNG_COMMAND_RUBY": "bundle",
"TNG_COMMAND_RUBY_ARGS": "exec,tng",
"TNG_COMMAND_PYTHON": "uv",
"TNG_COMMAND_PYTHON_ARGS": "run,tng",
"TNG_COMMAND_JS": "npx",
"TNG_COMMAND_JS_ARGS": "-p,@tng-sh/js,tng",
"PATH": "/Users/USERNAME/.local/share/mise/shims:/usr/local/bin:/usr/bin:/bin"
}
}
}
}If you only use a single language, you can also set a global command:
{
"mcpServers": {
"tng": {
"command": "tng-mcp",
"env": {
"TNG_COMMAND": "bundle",
"TNG_COMMAND_ARGS": "exec,tng",
"PATH": "/usr/local/bin:/usr/bin:/bin"
}
}
}
}If you do not set any TNG_COMMAND* variables, the server will auto-detect based on file extension.
{
"mcpServers": {
"tng": {
"command": "tng-mcp",
"env": {
"PATH": "/Users/USERNAME/.local/share/mise/shims:/usr/local/bin:/usr/bin:/bin",
"GEM_HOME": "/Users/USERNAME/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0",
"GEM_PATH": "/Users/USERNAME/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0",
"PYTHONPATH": "/path/to/your/python/libs"
}
}
}
}This ensures that bundle exec tng or uv run tng use the correct version and find all installed gems/packages.
Usage Examples
Once configured, interact naturally with your AI assistant:
Audit a Method
You: Audit the process_payment method in app/services/payment_processor.rb
AI: I'll audit that method for you.
[*calls audit_method tool*]
# Audit Results for PaymentProcessor#process_payment
## Issues Found (3)
### 1. Security - Severity: High
**Description:** Potential SQL injection vulnerability
**Location:** Line 52
**Suggested Fix:** Use parameterized queries instead of string interpolation
...One-Time Setup Helper
Generate a ready-to-paste MCP config by running:
npx @tng-sh/mcp-server initThis prints configuration blocks for Claude, Cursor, ChatGPT Desktop, Antigravity, and OpenCode. Copy the block for your client and paste it into your MCP config file.
Generate Tests
You: Generate tests for the User model's validate_email method
AI: I'll generate comprehensive tests for that method.
[*calls generate_test tool*]
✅ Test Generated Successfully
**Test File:** test/models/user_test.rb
**Command to Run:** bundle exec rails test
## Generated Test Code
...Trace Execution
You: Trace the execution path of calculate_discount
AI: I'll generate a symbolic trace for that method.
[*calls trace_method tool*]
# Symbolic Trace for PricingService#calculate_discount
### Step 1
**Action:** Initialize base_price from params
**Location:** Line 12
**State:** base_price = 100.0
...Detect Code Clones
You: Find duplicate code in app/services/report_generator.rb
AI: I'll check for code clones in that file.
[*calls detect_clones tool*]
# Clone Detection Results
**Detection Level:** All Levels (Comprehensive detection)
**Total Clone Groups Found:** 2
### Clone Group 1 (structural)
**Similarity:** 95%
**Instances (3):**
1. **Location:** Lines 45-52
2. **Location:** Lines 78-85
3. **Location:** Lines 112-119Find Dead Code
You: Check for unused code in src/utils/helpers.js
AI: I'll analyze that file for dead code.
[*calls detect_deadcode tool*]
# Dead Code Analysis for src/utils/helpers.js
## Summary
- **Total Issues:** 5
- **Unused Imports:** 2
- **Unused Functions:** 3
### Unused Imports (2)
1. **lodash**
- Location: Line 3
- Suggestion: Remove unused importAvailable Tools
The MCP server exposes seven tools:
1. audit_method
Audit a method for issues and behaviors.
Parameters:
file_path(required) - Path to the source filemethod_name(required) - Name of the method to audittest_type(optional) - Component type for JS/Python (e.g., "react_component", "utility")
Returns:
- Detailed issues with severity levels
- Suggested fixes
- Behavioral analysis
2. generate_test
Generate comprehensive tests for a method.
Parameters:
file_path(required) - Path to the source filemethod_name(required) - Name of the methodtest_type(optional) - Test framework or component type hint
Returns:
- Generated test code
- Test file path
- Command to run tests
3. trace_method
Generate symbolic trace execution path for a method.
Parameters:
file_path(required) - Path to the source filemethod_name(required) - Name of the method to trace
Returns:
- Step-by-step execution path
- Variable states at each step
- Control flow analysis
4. detect_clones
Detect code duplication within a file.
Parameters:
file_path(required) - Path to the source filelevel(optional) - Detection level: "1" (token), "2" (structural), "3" (fuzzy), or "all" (default)
Returns:
- Clone groups with similarity scores
- Locations of duplicated code
- Refactoring recommendations
5. detect_deadcode
Detect dead code in a file or across the whole project.
Parameters:
file_path(optional) - Path to the source file (omit when usingall=true)all(optional) - Set to true for a project-wide scan (uses CLI flag--all)project_root(required whenall=true) - Project root to run the scan from
Returns:
- Unused imports, variables, and functions
- Unreachable code blocks
- Cleanup recommendations
6. find_call_sites
Find in-repo call sites for a method/function.
Parameters:
file_path(required) - Path to the source file containing the methodmethod_name(required) - Method/function nameclass_name(optional) - Class/module name to disambiguate methods with the same nameproject_root(optional) - Project root to resolve relative paths
Returns:
- Files and line numbers where the method is called
- Snippet/context lines (when available)
Development
Building
npm install
npm run buildDevelopment Mode (with watch)
npm run devTesting the Server
You can test the MCP server using the MCP Inspector:
npx @modelcontextprotocol/inspector tng-mcpOr test individual tools manually using the mcp CLI.
Troubleshooting
"TNG CLI not found"
Make sure you have TNG installed:
# Check Ruby gem
gem list tng
# Check Python package
pip list | grep tng
# Check Node.js package
npm list -g | grep tng"Authentication failed"
Ensure you have run tng init (or the equivalent for your language) in your project to set up your API key. The MCP server uses your local TNG configuration.
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details
Support
- Documentation: tng.sh/docs
- Issues: GitHub Issues
- Discord: TNG Community
- Email: [email protected]
Made with ❤️ by Binary Dreams LLC
