Testing Guide
This guide covers testing the MCP JetBrains Code Inspections server and its functionality.
Overview
The project provides multiple ways to test the server functionality. The main testing approaches include MCP Inspector and interactive scripts.
Testing Methods
1. MCP Inspector (Recommended)
The MCP Inspector provides an interactive web interface to test the server:
# Test with built server
yarn inspect
# Test with development server
yarn inspect:dev
# Test with auto-rebuilding
yarn inspect:watch
# Direct inspector command
npx @modelcontextprotocol/inspector node dist/index.js
2. Interactive Test Script
# Run interactive MCP test
yarn test:mcp
3. Development Mode
# Run server in development mode
yarn dev
# Run built server
yarn start
Running Tests
Available Test Scripts
yarn test:mcp
- Interactive MCP server testingyarn inspect
- Launch MCP Inspectoryarn check:ide
- Check IDE availability
Testing the MCP Tool
Using MCP Inspector
-
Start the MCP Inspector:
yarn inspect
-
In the web interface:
- Select the
get_jetbrains_code_inspections
tool - Enter a path parameter (file or directory)
- Click "Call Tool"
- Review the inspection results
- Select the
Example Tool Calls
// Test with a single file
{
"path": "/Users/yourname/project/src/index.ts"
}
// Test with a directory
{
"path": "/Users/yourname/project/src"
}
// Test with current directory
{
"path": "."
}
Environment Variable Testing
Test different configurations:
# Test with specific IDE
FORCE_INSPECT_PATH="/Applications/IntelliJ IDEA CE.app/Contents/bin/inspect.sh" yarn inspect
# Test with timeout
INSPECTION_TIMEOUT=300000 yarn inspect
# Test with debug logging
DEBUG=true yarn inspect
# Test with inspection filtering
EXCLUDE_INSPECTIONS="SpellCheckingInspection,GrazieInspection" yarn inspect
Testing Different Response Formats
# Test markdown output (default)
RESPONSE_FORMAT=markdown yarn inspect
# Test JSON output
RESPONSE_FORMAT=json yarn inspect
Verification Steps
1. Verify IDE Availability
To check which JetBrains IDEs are available on your system, enable debug mode:
DEBUG=true yarn test:mcp --path ./src/index.ts
The debug output will show:
- Which JetBrains IDEs are detected
- IDE priority order for automatic selection
- Selected IDE for inspection
Note: All detected IDEs can be used for inspections thanks to isolated configuration, regardless of whether they're already running.
2. Test Basic Functionality
-
Create a test file with some issues:
// test.ts
const unused = 'this variable is unused';
console.log('Hello world'); -
Test with MCP Inspector:
yarn inspect
-
Call the tool with the test file path
-
Verify you get inspection results
3. Test Error Handling
- Test with non-existent path
- Test with invalid parameters
- Test with no available IDEs
Troubleshooting Tests
Common Issues
-
"No JetBrains IDE found"
- Enable debug mode to see IDE detection:
DEBUG=true yarn test:mcp
- Install IntelliJ IDEA Community Edition (free)
- Set
FORCE_INSPECT_PATH
if IDE is installed in non-standard location
- Enable debug mode to see IDE detection:
-
Timeout errors
- Increase timeout:
INSPECTION_TIMEOUT=300000 yarn inspect
- Test with smaller files/directories first
- Increase timeout:
-
Permission errors
- Check file permissions on IDE inspect scripts
- Ensure temp directory is writable
-
Empty results
- Ensure the file has actual issues to detect
- Check if inspection profile is properly configured
- Try with debug logging:
DEBUG=true yarn inspect
Advanced Testing
Custom IDE Testing
# Test with specific IDE
FORCE_INSPECT_PATH="/Applications/PyCharm.app/Contents/bin/inspect.sh" yarn test:mcp
# Test with custom project root
FORCE_PROJECT_ROOT="/path/to/project" yarn test:mcp
# Test with custom profile
FORCE_PROFILE_PATH="/path/to/profile.xml" yarn test:mcp
Performance Testing
# Test with large timeout
INSPECTION_TIMEOUT=600000 yarn inspect
# Test specific inspections only
ONLY_INSPECTIONS="JSUnusedLocalSymbols,JSUnusedGlobalSymbols" yarn inspect
Quality Assurance
Code Quality Checks
# Run all quality checks
yarn check
# Individual checks
yarn prettier:check # Code formatting
yarn eslint:check # Code linting
yarn typescript:check # Type checking
Integration Testing
For integration testing, use the MCP Inspector or interactive test script to verify:
- Tool registration and discovery
- Parameter validation
- IDE detection and selection
- Inspection execution
- Result formatting and return
- Error handling and reporting
This provides comprehensive testing of the entire MCP server workflow.