UNPKG

@mmlotfy/intellicodemcp

Version:

IntelliCodeMCP - Advanced AI Model Context Protocol System for intelligent code management and orchestration

269 lines 12.2 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js"); const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js"); const types_js_1 = require("@modelcontextprotocol/sdk/types.js"); const memory_bank_1 = require("../tools/memory-bank"); const code_trace_1 = require("../tools/code-trace"); const smartcontext_weaver_1 = require("../tools/smartcontext-weaver"); const smartthink_weaver_1 = require("../tools/smartthink-weaver"); const performance_orchestrator_1 = require("../tools/performance-orchestrator"); const web_search_1 = require("../tools/web-search"); class IntelliCodeMCPServer { constructor() { this.server = new index_js_1.Server({ name: 'intellicode-mcp', version: '1.0.0', }, { capabilities: { tools: {}, }, }); this.setupToolHandlers(); this.setupErrorHandling(); } setupToolHandlers() { // List available tools this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => { return { tools: [ { name: 'memory_bank', description: 'File-based storage system for project data. Supports read, write, append, and search operations across organized categories.', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['read', 'write', 'append', 'search'], description: 'Operation to perform' }, category: { type: 'string', enum: ['docs', 'threads', 'knots', 'technical', 'profiles', 'search'], description: 'Storage category' }, file_name: { type: 'string', description: 'Name of the file to operate on' }, content: { type: 'string', description: 'Content for write/append operations' }, query: { type: 'string', description: 'Search query for search operations' } }, required: ['action', 'category', 'file_name'] } }, { name: 'code_trace', description: 'Real-time TypeScript and ESLint error tracking with auto-fix capabilities.', inputSchema: { type: 'object', properties: { project_path: { type: 'string', description: 'Path to the project to analyze' }, check_type: { type: 'string', enum: ['typescript', 'eslint', 'all'], description: 'Type of check to perform' }, fix: { type: 'boolean', description: 'Whether to auto-fix ESLint errors' } }, required: ['project_path', 'check_type'] } }, { name: 'smartcontext_weaver', description: 'Manages and summarizes long conversation contexts with intelligent search integration.', inputSchema: { type: 'object', properties: { thread_id: { type: 'string', description: 'ID of the conversation thread' }, task_id: { type: 'string', description: 'ID of the task' }, max_tokens: { type: 'number', description: 'Maximum tokens for summary' }, query: { type: 'string', description: 'Search query for context enhancement' } } } }, { name: 'smartthink_weaver', description: 'Advanced multi-agent reasoning system for complex problem solving.', inputSchema: { type: 'object', properties: { problem: { type: 'string', description: 'Problem statement to analyze' }, context: { type: 'string', description: 'Additional context for the problem' }, max_steps: { type: 'number', description: 'Maximum reasoning steps' }, query: { type: 'string', description: 'Search query for additional context' } }, required: ['problem'] } }, { name: 'performance_orchestrator', description: 'Intelligent AI model selection and task orchestration for optimal performance.', inputSchema: { type: 'object', properties: { task: { type: 'object', properties: { id: { type: 'string' }, input: { type: 'string' }, priority: { type: 'string', enum: ['low', 'medium', 'high'] }, type: { type: 'string', enum: ['simple', 'code_writing', 'analytical', 'complex'] }, context: { type: 'string' } }, required: ['id', 'input', 'priority'] } }, required: ['task'] } }, { name: 'web_search', description: 'Search the web using SerpAPI for real-time information and research.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query to find information on the web' }, num_results: { type: 'number', description: 'Number of search results to return (default: 10)', minimum: 1, maximum: 20 }, api_key: { type: 'string', description: 'SerpAPI key (optional if set in environment)' } }, required: ['query'] } } ] }; }); // Handle tool calls this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { let result; switch (name) { case 'memory_bank': result = await (0, memory_bank_1.executeMemoryFile)(args); break; case 'code_trace': result = await (0, code_trace_1.executeCodeTrace)(args); break; case 'smartcontext_weaver': result = await (0, smartcontext_weaver_1.executeSmartContext)(args); break; case 'smartthink_weaver': result = await (0, smartthink_weaver_1.executeSmartThink)(args); break; case 'performance_orchestrator': result = await (0, performance_orchestrator_1.executePerformanceOrchestrator)(args); break; case 'web_search': result = await (0, web_search_1.executeWebSearch)(args); break; default: throw new Error(`Unknown tool: ${name}`); } return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error: ${error.message}` } ], isError: true }; } }); } setupErrorHandling() { this.server.onerror = (error) => { console.error('[MCP Error]', error); }; process.on('SIGINT', async () => { await this.server.close(); process.exit(0); }); } async run() { try { const transport = new stdio_js_1.StdioServerTransport(); await this.server.connect(transport); console.error('IntelliCodeMCP server running on stdio'); } catch (error) { console.error('Failed to start IntelliCodeMCP server:', error); process.exit(1); } } } // Start the server only if this file is run directly if (require.main === module) { const server = new IntelliCodeMCPServer(); server.run().catch((error) => { console.error('Server startup failed:', error); process.exit(1); }); } //# sourceMappingURL=mcp-server.js.map