🚧 Development Status: In Active Development 🚧
A Model Context Protocol (MCP) worker that provides comprehensive TypeScript/JavaScript code analysis capabilities. This worker integrates with AI assistants and development tools to provide intelligent code review, static analysis, and automated patch generation.
The Model Context Protocol (MCP) is an open standard that enables AI assistants to securely connect to external data sources and tools. This worker implements the MCP specification to provide TypeScript code analysis services to AI models and development environments.
- ESLint Integration: Full ESLint rule support with custom rule loading
- TypeScript Compiler: Type checking, compilation errors, and project analysis
- TSQuery Pattern Matching: Custom AST pattern detection for code smells
- Multi-file Analysis: Project-wide code review capabilities
- MCP Protocol: Standardized interface for AI model integration
- Structured Output: JSON responses optimized for AI consumption
- Error Handling: Graceful degradation with detailed error reporting
- Health Monitoring: Built-in health checks and status reporting
- Automated Patches: AI-generated code fixes and improvements
- Confidence Scoring: ML-based confidence ratings for findings
- Custom Rules: Extensible rule system for team-specific standards
- Real-time Analysis: Fast, incremental analysis for large codebases
- Node.js 18+
- npm or yarn
# Clone the repository
git clone https://github.com/yashranaway/typescript-mcp-worker.git
cd typescript-mcp-worker
# Install dependencies
npm install
# Build the project
npm run buildimport { TypeScriptWorker } from './src';
// Initialize the worker
const worker = new TypeScriptWorker();
// Analyze a single file
const result = await worker.analyzeCode('example.ts', sourceCode, {
enableESLint: true,
enableTypeScript: true,
enableTsQuery: true,
generatePatches: true
});
console.log('Findings:', result.findings);
console.log('Patches:', result.patches);# Start the MCP server
npm run mcp:serve
# Or build and run
npm run build
node dist/mcp-server.jsThis worker exposes the following tools through the MCP protocol:
Analyzes a single TypeScript/JavaScript file.
Parameters:
filePath: Path to the filesourceCode: Source code contentoptions: Analysis configuration
Returns: Analysis results with findings and patches
Analyzes an entire TypeScript project.
Parameters:
projectRoot: Project root directoryprojectOptions: Project analysis options
Returns: Array of analysis results for all files
Performs health check on all analysis tools.
Returns: Health status and tool details
Updates ESLint configuration.
Parameters:
configPath: Path to ESLint config file
Updates TypeScript configuration.
Parameters:
tsConfigPath: Path to TypeScript config file
Loads custom ESLint rules.
Parameters:
rulesPath: Path to custom rules directory
{
"mcpServers": {
"typescript-worker": {
"command": "node",
"args": ["dist/mcp-server.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}const config = {
eslintConfigPath: './eslint.config.js', // Custom ESLint config
typescriptConfigPath: './tsconfig.json', // TypeScript config
maxFileSize: 1024 * 1024 // Max file size (1MB)
};
const worker = new TypeScriptWorker(config);typescript-mcp-worker/
├── src/
│ ├── index.ts # Main worker class
│ ├── mcp-server.ts # MCP protocol server
│ ├── eslint-analyzer.ts # ESLint integration
│ ├── typescript-analyzer.ts # TypeScript compiler
│ ├── tsquery-analyzer.ts # TSQuery pattern matching
│ ├── patch-generator.ts # Automated patch generation
│ ├── confidence-scorer.ts # ML-based confidence scoring
│ ├── logger.ts # Logging utilities
│ └── types.ts # Type definitions
├── mcp-config.json # MCP configuration
├── example.ts # Usage examples
└── package.json # Project configuration
# Development
npm run dev # Start in watch mode
npm run build # Build the project
npm run start # Start production server
# MCP
npm run mcp:serve # Start MCP server
# Testing
npm run test # Run tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverage
# Utilities
npm run example # Run example code
npm run lint # Lint the codebase
npm run clean # Clean build artifacts# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage{
"filePath": "example.ts",
"findings": [
{
"id": "eslint-console-log",
"type": "CODE_QUALITY",
"severity": "WARNING",
"message": "Console.log statements should be removed in production",
"location": {
"file": "example.ts",
"line": 2,
"column": 10
},
"rule": "no-console",
"confidence": 0.9
}
],
"patches": [
{
"id": "patch-console-log",
"description": "Remove console.log statement",
"changes": [
{
"type": "delete",
"start": 0,
"end": 20,
"description": "Remove console.log line"
}
],
"confidence": 0.8
}
],
"metadata": {
"analysisTime": 150,
"tools": {
"eslint": true,
"typescript": true,
"tsquery": true
}
}
}This project is in active development! We welcome contributions:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Add tests for new functionality
- Ensure all tests pass before submitting
- Update documentation for new features
- Follow the existing code style
- Basic MCP server implementation
- Tool registration and handling
- Error handling and logging
- Advanced TypeScript analysis
- Custom rule engine
- Performance optimizations
- LLM-based patch generation
- Intelligent rule suggestions
- Learning from user feedback
- Multi-tenant support
- Advanced security scanning
- Integration APIs
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
- Built with the Model Context Protocol
- Powered by TypeScript and ESLint
- Enhanced with TSQuery
🚧 Note: This project is in active development. APIs and features may change. 🚧