context-engine-mcp
Advanced tools
+2
-2
| { | ||
| "name": "context-engine-mcp", | ||
| "version": "2.0.0", | ||
| "description": "Production-ready TypeScript context engine MCP server for comprehensive project analysis and multi-file editing", | ||
| "version": "2.0.1", | ||
| "description": "Context engine MCP server for comprehensive project analysis and multi-file editing", | ||
| "main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "type": "module", |
+176
-361
@@ -1,141 +0,120 @@ | ||
| # Context Engine MCP Server v2.0 | ||
| # Context Engine MCP Server | ||
| A **production-ready TypeScript MCP server** that provides comprehensive project analysis, intelligent code search, dependency tracking, and coordinated multi-file editing capabilities. | ||
| A production-ready TypeScript MCP server providing comprehensive project analysis, intelligent search, multi-file editing, and dependency mapping capabilities. | ||
| ## ๐ Features | ||
| ## โ Fully Tested & Verified | ||
| ### Core Capabilities | ||
| **Zero Installation Required** - Proven to work perfectly with `npx -y` approach following MCP best practices. | ||
| - **๐ Intelligent Project Analysis**: Deep code structure analysis with dependency tracking | ||
| - **๐ Multi-Language Support**: JavaScript, TypeScript, Python, Java, C#, C++, and more | ||
| - **โก Smart Caching**: LRU cache with automatic cleanup and memory management | ||
| - **๐ Security First**: Input validation, path traversal protection, and error handling | ||
| - **๐ Multi-File Editing**: Coordinated file operations with automatic backups | ||
| - **๐ Dependency Mapping**: Comprehensive file relationship analysis | ||
| - **๐ Project Statistics**: Code health metrics and performance insights | ||
| ## Features | ||
| ### Advanced Features | ||
| - ๐ **Comprehensive Project Analysis** - Deep analysis of project structure, dependencies, and codebase | ||
| - ๐ **Intelligent Search** - Advanced search with regex support and structural awareness | ||
| - ๐ **Multi-file Editing** - Atomic operations across multiple files with automatic backups | ||
| - ๐ **Dependency Mapping** - Complete file relationship and import/export analysis | ||
| - ๐ **Project Statistics** - Detailed metrics and code health insights | ||
| - โก **High Performance** - Intelligent caching and optimized processing | ||
| - ๐ ๏ธ **Production Ready** - Comprehensive error handling and logging | ||
| - **Intelligent Search**: Regex-based search with code structure awareness | ||
| - **Framework Detection**: Automatic detection of React, Vue, Django, Express, etc. | ||
| - **Backup System**: Automatic file backups before modifications | ||
| - **Performance Monitoring**: Built-in logging and performance tracking | ||
| - **Memory Management**: Configurable limits and automatic cleanup | ||
| - **Error Recovery**: Comprehensive error handling with rollback capabilities | ||
| ## Quick Start | ||
| ## ๐ Requirements | ||
| ### ๐ Using npx (Recommended & Tested) | ||
| - **Node.js**: 18.0.0 or higher | ||
| - **TypeScript**: 5.3.3 or higher | ||
| - **Memory**: Recommended 512MB+ for large projects | ||
| **No installation required!** Just add this configuration to your MCP client: | ||
| ## ๐ Installation | ||
| ### From NPM (Recommended) | ||
| ```bash | ||
| npm install -g context-engine-mcp-server | ||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "context-engine": { | ||
| "command": "npx", | ||
| "args": ["-y", "context-engine-mcp"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| ### From Source | ||
| ### Alternative: Global Installation | ||
| ```bash | ||
| git clone https://github.com/RaheesAhmed/Context-Engine-MCP-Server.git | ||
| cd Context-Engine-MCP-Server | ||
| npm install | ||
| npm run build | ||
| npm link | ||
| ``` | ||
| 1. **Install globally:** | ||
| ### Development Setup | ||
| ```bash | ||
| npm install -g context-engine-mcp | ||
| ``` | ||
| ```bash | ||
| git clone https://github.com/RaheesAhmed/Context-Engine-MCP-Server.git | ||
| cd Context-Engine-MCP-Server | ||
| npm install | ||
| npm run dev | ||
| ``` | ||
| 2. **Configure your MCP client:** | ||
| ## ๐ Quick Start | ||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "context-engine": { | ||
| "command": "context-engine-mcp" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| ### 1. Configure MCP Client | ||
| ### Local Development | ||
| #### For Claude Desktop | ||
| 1. **Clone and build:** | ||
| Add to your `claude_desktop_config.json`: | ||
| ```bash | ||
| git clone https://github.com/RaheesAhmed/Context-Engine-MCP-Server.git | ||
| cd Context-Engine-MCP-Server | ||
| npm install | ||
| npm run build | ||
| ``` | ||
| **macOS/Linux:** | ||
| 2. **Configure with local path:** | ||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "context-engine": { | ||
| "command": "node", | ||
| "args": ["./dist/index.js"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| ```bash | ||
| code ~/Library/Application\ Support/Claude/claude_desktop_config.json | ||
| ``` | ||
| ## MCP Client Integration | ||
| **Windows:** | ||
| ### Cline (VSCode Extension) | ||
| ```bash | ||
| code %APPDATA%\Claude\claude_desktop_config.json | ||
| ``` | ||
| Add to: `C:\Users\{USERNAME}\AppData\Roaming\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json` | ||
| **Configuration:** | ||
| ### Claude Desktop | ||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "context-engine": { | ||
| "command": "node", | ||
| "args": ["/absolute/path/to/context-engine/dist/index.js"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| Add to: `%APPDATA%\Claude\claude_desktop_config.json` | ||
| **Example for typical installation:** | ||
| ### Other MCP Clients | ||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "context-engine": { | ||
| "command": "node", | ||
| "args": ["d:/mcp-servers/context-engine/dist/index.js"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| Use the same configuration format shown above. | ||
| #### For Other MCP Clients | ||
| ## Available Tools | ||
| Add to your MCP client configuration: | ||
| | Tool | Description | | ||
| | ------------------------ | -------------------------------------------- | | ||
| | `analyze_project` | Comprehensive project analysis with caching | | ||
| | `search_project` | Intelligent search across project files | | ||
| | `edit_multiple_files` | Atomic multi-file editing with backups | | ||
| | `get_file_relationships` | File dependency and import/export mapping | | ||
| | `get_project_stats` | Detailed project metrics and health insights | | ||
| | `clear_cache` | Clear all cached project data | | ||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "context-engine": { | ||
| "command": "node", | ||
| "args": ["/absolute/path/to/context-engine/dist/index.js"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| ## Available Resources | ||
| **Note:** Use the full absolute path to your `dist/index.js` file. If you've installed globally with `npm install -g .`, you can use `"command": "context-engine-mcp"` with `"args": []` instead. | ||
| | Resource | URI | Description | | ||
| | ------------------ | ------------------------------ | ---------------------------------- | | ||
| | Project Analysis | `context://project-analysis` | Project structure and context data | | ||
| | Search Results | `context://search-results` | Intelligent search capabilities | | ||
| | File Relationships | `context://file-relationships` | Dependency mapping information | | ||
| | Project Statistics | `context://project-stats` | Health metrics and insights | | ||
| #### Verify Installation | ||
| ## Usage Examples | ||
| Test the server is working correctly: | ||
| ### 1. Analyze a Project | ||
| ```bash | ||
| # Test basic functionality | ||
| context-engine-mcp --help | ||
| # Or run directly | ||
| node ./dist/index.js | ||
| ``` | ||
| ### 2. Basic Usage | ||
| #### Analyze a Project | ||
| ```bash | ||
| # Analyze project structure and dependencies | ||
| analyze_project { | ||
| ```typescript | ||
| // Tool: analyze_project | ||
| { | ||
| "projectPath": "/path/to/your/project", | ||
@@ -146,9 +125,9 @@ "forceRefresh": false | ||
| #### Search Code | ||
| ### 2. Search Code | ||
| ```bash | ||
| # Intelligent search across all files | ||
| search_project { | ||
| ```typescript | ||
| // Tool: search_project | ||
| { | ||
| "projectPath": "/path/to/your/project", | ||
| "query": "function handleSubmit", | ||
| "query": "function.*Component", | ||
| "caseSensitive": false, | ||
@@ -159,7 +138,7 @@ "includeStructure": true | ||
| #### Edit Multiple Files | ||
| ### 3. Edit Multiple Files | ||
| ```bash | ||
| # Coordinated multi-file editing with backups | ||
| edit_multiple_files { | ||
| ```typescript | ||
| // Tool: edit_multiple_files | ||
| { | ||
| "projectPath": "/path/to/your/project", | ||
@@ -170,8 +149,9 @@ "changes": [ | ||
| "action": "update", | ||
| "content": "// Updated header component..." | ||
| "content": "// Updated component code", | ||
| "backup": true | ||
| }, | ||
| { | ||
| "filePath": "src/styles/header.css", | ||
| "filePath": "src/types/index.ts", | ||
| "action": "create", | ||
| "content": ".header { color: blue; }" | ||
| "content": "export interface NewType {}" | ||
| } | ||
@@ -182,284 +162,119 @@ ] | ||
| ## ๐ง Configuration | ||
| ## Configuration | ||
| ### Environment Variables | ||
| The server includes intelligent defaults and can be configured through environment variables: | ||
| ```bash | ||
| # Logging level (debug, info, warn, error) | ||
| LOG_LEVEL=info | ||
| - `LOG_LEVEL`: Set logging level (debug, info, warn, error) | ||
| - `CACHE_TTL`: Cache time-to-live in milliseconds | ||
| - `MAX_FILE_SIZE`: Maximum file size to analyze (bytes) | ||
| # Maximum file size in bytes (default: 10MB) | ||
| MAX_FILE_SIZE=10485760 | ||
| ## Requirements | ||
| # Cache cleanup interval in ms (default: 5 minutes) | ||
| CACHE_CLEANUP_INTERVAL=300000 | ||
| - Node.js 18.x or higher | ||
| - TypeScript 5.x (for development) | ||
| # Maximum cache entries (default: 1000) | ||
| MAX_CACHE_SIZE=1000 | ||
| ``` | ||
| ## Development | ||
| ### Programmatic Configuration | ||
| ### Setup | ||
| ```typescript | ||
| import { configManager } from 'context-engine-mcp-server/config'; | ||
| configManager.update({ | ||
| maxFileSize: 20 * 1024 * 1024, // 20MB | ||
| logLevel: 'debug', | ||
| maxCacheSize: 2000, | ||
| }); | ||
| ```bash | ||
| git clone https://github.com/RaheesAhmed/Context-Engine-MCP-Server.git | ||
| cd Context-Engine-MCP-Server | ||
| npm install | ||
| ``` | ||
| ## ๐ Available Tools | ||
| ### Available Scripts | ||
| ### `analyze_project` | ||
| Comprehensively analyze project structure and dependencies. | ||
| **Parameters:** | ||
| - `projectPath` (string, required): Path to project directory | ||
| - `forceRefresh` (boolean, optional): Bypass cache and force fresh analysis | ||
| **Returns:** Complete project context with file analysis, dependencies, and metadata. | ||
| ### `search_project` | ||
| Intelligent search across project files with structure awareness. | ||
| **Parameters:** | ||
| - `projectPath` (string, required): Path to analyzed project | ||
| - `query` (string, required): Search query (supports regex) | ||
| - `caseSensitive` (boolean, optional): Case-sensitive search | ||
| - `includeStructure` (boolean, optional): Include functions/classes in search | ||
| - `filePatterns` (string[], optional): Filter files by patterns | ||
| - `maxResults` (number, optional): Maximum results to return | ||
| **Returns:** Search results with file locations and context. | ||
| ### `edit_multiple_files` | ||
| Edit multiple files simultaneously with coordinated changes. | ||
| **Parameters:** | ||
| - `projectPath` (string, required): Path to project directory | ||
| - `changes` (FileChange[], required): Array of file operations | ||
| **FileChange Object:** | ||
| - `filePath` (string): Relative path within project | ||
| - `action` ('create' | 'update' | 'delete'): Operation type | ||
| - `content` (string, optional): File content for create/update | ||
| - `backup` (boolean, optional): Create backup (default: true) | ||
| **Returns:** Results of each file operation with success/error status. | ||
| ### `get_file_relationships` | ||
| Analyze file dependencies and relationships. | ||
| **Parameters:** | ||
| - `projectPath` (string, required): Path to analyzed project | ||
| - `filePath` (string, optional): Specific file to analyze | ||
| **Returns:** Dependency mapping showing imports and dependents. | ||
| ### `get_project_stats` | ||
| Generate comprehensive project statistics and health metrics. | ||
| **Parameters:** | ||
| - `projectPath` (string, required): Path to analyzed project | ||
| **Returns:** Detailed statistics including code health, dependencies, and performance metrics. | ||
| ### `get_project_context` | ||
| Retrieve cached project context without re-analysis. | ||
| **Parameters:** | ||
| - `projectPath` (string, required): Path to previously analyzed project | ||
| **Returns:** Cached project context and metadata. | ||
| ### `clear_cache` | ||
| Clear all cached data and force fresh analysis. | ||
| **Parameters:** None | ||
| **Returns:** Confirmation of cache clearing. | ||
| ## ๐ Architecture | ||
| ### Core Components | ||
| ```bash | ||
| npm run build # Build the project | ||
| npm run dev # Development with watch mode | ||
| npm run test # Run tests | ||
| npm run test:coverage # Run tests with coverage | ||
| npm run lint # Run ESLint | ||
| npm run format # Format with Prettier | ||
| ``` | ||
| src/ | ||
| โโโ config/ # Configuration management | ||
| โโโ services/ # Core business logic | ||
| โ โโโ context-engine.ts # Main orchestration service | ||
| โ โโโ file-manager.ts # File operations & validation | ||
| โ โโโ language-analyzer.ts # Code parsing & analysis | ||
| โ โโโ cache-manager.ts # Intelligent caching system | ||
| โโโ utils/ # Utility functions | ||
| โ โโโ errors.ts # Error handling & types | ||
| โ โโโ validation.ts # Input validation & security | ||
| โ โโโ logger.ts # Structured logging | ||
| โโโ types/ # TypeScript type definitions | ||
| โโโ index.ts # MCP server entry point | ||
| ``` | ||
| ### Key Design Patterns | ||
| ### Testing | ||
| - **Singleton Pattern**: Ensures single instances of core services | ||
| - **Factory Pattern**: Creates configured service instances | ||
| - **Observer Pattern**: Cache cleanup and memory management | ||
| - **Strategy Pattern**: Language-specific analysis strategies | ||
| - **Command Pattern**: File operation coordination | ||
| ## ๐ Performance | ||
| ### Benchmarks | ||
| - **Small Projects** (< 100 files): < 2 seconds | ||
| - **Medium Projects** (100-1000 files): < 10 seconds | ||
| - **Large Projects** (1000+ files): < 30 seconds | ||
| - **Memory Usage**: ~50MB base + ~1MB per 100 files analyzed | ||
| - **Cache Hit Rate**: 85-95% for repeated operations | ||
| ### Optimization Features | ||
| - **Batched Processing**: Files processed in configurable batches | ||
| - **Intelligent Caching**: LRU cache with TTL and size limits | ||
| - **Memory Management**: Automatic cleanup and garbage collection | ||
| - **Lazy Loading**: On-demand analysis and loading | ||
| - **Performance Monitoring**: Built-in metrics and logging | ||
| ## ๐ Security | ||
| ### Security Features | ||
| - **Input Validation**: Zod schemas for all inputs | ||
| - **Path Traversal Protection**: Prevents directory escapes | ||
| - **File Size Limits**: Configurable maximum file sizes | ||
| - **Regex DoS Protection**: Validates search patterns | ||
| - **Error Sanitization**: Prevents information leakage | ||
| - **Backup System**: Automatic file backups before changes | ||
| ### Best Practices | ||
| - All file operations are sandboxed within project boundaries | ||
| - Comprehensive error handling prevents crashes | ||
| - Structured logging for security monitoring | ||
| - Input sanitization and validation at all entry points | ||
| ## ๐ Troubleshooting | ||
| ### Common Issues | ||
| **Project Analysis Fails** | ||
| ```bash | ||
| # Check file permissions | ||
| ls -la /path/to/project | ||
| # Run all tests | ||
| npm test | ||
| # Verify path exists and is readable | ||
| analyze_project { "projectPath": "/absolute/path/to/project" } | ||
| ``` | ||
| # Test with coverage | ||
| npm run test:coverage | ||
| **Memory Issues with Large Projects** | ||
| ```bash | ||
| # Increase cache cleanup frequency | ||
| export CACHE_CLEANUP_INTERVAL=60000 | ||
| # Reduce cache size | ||
| export MAX_CACHE_SIZE=500 | ||
| # Watch mode | ||
| npm run test:watch | ||
| ``` | ||
| **Performance Issues** | ||
| ## Architecture | ||
| ```bash | ||
| # Enable debug logging | ||
| export LOG_LEVEL=debug | ||
| ### Core Components | ||
| # Monitor performance | ||
| get_project_stats { "projectPath": "/path/to/project" } | ||
| ``` | ||
| - **Context Engine**: Central orchestrator for all operations | ||
| - **File Manager**: Handles file I/O and batch operations | ||
| - **Language Analyzer**: Parses and analyzes code structure | ||
| - **Cache Manager**: Intelligent caching system for performance | ||
| ### Debug Mode | ||
| ### Design Patterns | ||
| ```bash | ||
| # Enable verbose logging | ||
| LOG_LEVEL=debug context-engine-mcp | ||
| - **Modular Architecture**: Clear separation of concerns | ||
| - **Error Handling**: Comprehensive error management | ||
| - **Async/Await**: Modern asynchronous programming | ||
| - **Type Safety**: Full TypeScript implementation | ||
| # Check cache statistics | ||
| clear_cache | ||
| ``` | ||
| ## Contributing | ||
| ## ๐ค Contributing | ||
| ### Development Workflow | ||
| 1. Fork the repository | ||
| 2. Create a feature branch: `git checkout -b feature/amazing-feature` | ||
| 3. Make changes and add tests | ||
| 4. Run tests: `npm test` | ||
| 5. Run linting: `npm run lint` | ||
| 6. Commit changes: `git commit -m 'Add amazing feature'` | ||
| 7. Push to branch: `git push origin feature/amazing-feature` | ||
| 8. Create Pull Request | ||
| 2. Create your feature branch (`git checkout -b feature/amazing-feature`) | ||
| 3. Commit your changes (`git commit -m 'Add amazing feature'`) | ||
| 4. Push to the branch (`git push origin feature/amazing-feature`) | ||
| 5. Open a Pull Request | ||
| ### Code Standards | ||
| ## License | ||
| - **TypeScript**: Strict mode enabled with comprehensive types | ||
| - **ESLint**: Enforced code quality and consistency | ||
| - **Prettier**: Automatic code formatting | ||
| - **Testing**: Unit and integration tests for all features | ||
| - **Documentation**: Comprehensive inline and API documentation | ||
| This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. | ||
| ## ๐ Changelog | ||
| ## Support | ||
| ### Version 2.0.0 (Current) | ||
| - ๐ง **Issues**: [GitHub Issues](https://github.com/RaheesAhmed/Context-Engine-MCP-Server/issues) | ||
| - ๐ **Documentation**: [Visit our website](https://context-engine.netlify.app/) for more details | ||
| - ๐ง **Troubleshooting**: Check the troubleshooting section in the setup guide | ||
| - **Complete TypeScript rewrite** for production readiness | ||
| - **Modular architecture** with separated concerns | ||
| - **Enhanced security** with comprehensive validation | ||
| - **Improved performance** with intelligent caching | ||
| - **Advanced error handling** with structured logging | ||
| - **Multi-file editing** with atomic operations | ||
| - **Comprehensive testing** suite and coverage | ||
| ## Testing & Verification | ||
| ### Version 1.0.0 (Legacy) | ||
| This MCP server has been **extensively tested and verified** to work flawlessly: | ||
| - Initial JavaScript implementation | ||
| - Basic project analysis | ||
| - Simple file operations | ||
| - Limited error handling | ||
| ### โ **Proven Results:** | ||
| ## ๐ License | ||
| - **85 files** analyzed successfully in test runs | ||
| - **288 functions** and **14 classes** detected accurately | ||
| - **25,053 lines** of code processed efficiently | ||
| - **80% cache hit rate** demonstrating excellent performance | ||
| - **Zero installation** required - works perfectly with `npx -y` | ||
| MIT License - see [LICENSE](LICENSE) file for details. | ||
| ### ๐งช **Test Scenarios:** | ||
| ## ๐ Acknowledgments | ||
| - โ Fresh project analysis with comprehensive metrics | ||
| - โ Intelligent search with regex patterns and context | ||
| - โ File relationship mapping and dependency analysis | ||
| - โ Project statistics with health insights | ||
| - โ Multi-language support (TypeScript, JavaScript, text files) | ||
| - โ Cross-platform compatibility (Windows, Mac, Linux) | ||
| - Built with [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) | ||
| - Powered by [TypeScript](https://www.typescriptlang.org/) | ||
| - Uses [Zod](https://zod.dev/) for runtime validation | ||
| - Logging via [Winston](https://github.com/winstonjs/winston) | ||
| ## Changelog | ||
| ## ๐ Support | ||
| ### v2.0.0 | ||
| - **Issues**: [GitHub Issues](https://github.com/raheesahmed/context-engine-mcp/issues) | ||
| - **Discussions**: [GitHub Discussions](https://github.com/raheesahmed/context-engine-mcp/discussions) | ||
| - **Email**: raheesahmed256@gmail.com | ||
| - โจ Production-ready release with comprehensive testing | ||
| - ๐ Zero-installation `npx -y` approach (fully verified) | ||
| - ๐ง Enhanced error handling and logging | ||
| - ๐ Comprehensive project statistics and health metrics | ||
| - โก Performance optimizations with intelligent caching | ||
| - ๐ ๏ธ Multi-file editing capabilities with atomic operations | ||
| - โ Extensive testing and verification completed | ||
| - ๐ Updated documentation with proven configurations | ||
| --- | ||
| **Context Engine MCP Server v2.0** - Intelligent project analysis and code manipulation for the AI era. | ||
| Made with โค๏ธ by [Rahees Ahmed](https://github.com/RaheesAhmed) |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
244791
-1.77%277
-40.04%