UNPKG

@mmlotfy/intellicodemcp

Version:

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

262 lines 11.6 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"); async function startMCPServer() { const server = new index_js_1.Server({ name: 'intellicode-mcp', version: '2.3.0', }, { capabilities: { tools: {}, }, }); // List available tools server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => { return { tools: [ { name: 'memory_bank', description: 'File-based storage system for project data with search capabilities', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['read', 'write', 'append', 'search'], description: 'Operation to perform: read, write, append, or search files' }, category: { type: 'string', enum: ['docs', 'threads', 'knots', 'technical', 'profiles', 'search'], description: 'Storage category for organizing files' }, 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 finding files' } }, required: ['action', 'category', 'file_name'] } }, { name: 'code_trace', description: 'Real-time TypeScript and ESLint error tracking', inputSchema: { type: 'object', properties: { project_path: { type: 'string', description: 'Path to the project directory to analyze' }, check_type: { type: 'string', enum: ['typescript', 'eslint', 'all'], description: 'Type of code analysis: typescript, eslint, or all' }, fix: { type: 'boolean', description: 'Whether to automatically fix ESLint errors' } }, required: ['project_path', 'check_type'] } }, { name: 'smartcontext_weaver', description: 'Long conversation context management and summarization', inputSchema: { type: 'object', properties: { thread_id: { type: 'string', description: 'Unique identifier for the conversation thread' }, task_id: { type: 'string', description: 'Unique identifier for the specific task' }, max_tokens: { type: 'number', description: 'Maximum number of tokens for the summary' }, query: { type: 'string', description: 'Search query to enhance context' } } } }, { name: 'smartthink_weaver', description: 'Multi-agent reasoning for complex problem solving', inputSchema: { type: 'object', properties: { problem: { type: 'string', description: 'The complex problem statement to analyze and solve' }, context: { type: 'string', description: 'Additional context or background information' }, max_steps: { type: 'number', description: 'Maximum number of reasoning steps to perform' }, query: { type: 'string', description: 'Search query for additional context from memory' } }, required: ['problem'] } }, { name: 'performance_orchestrator', description: 'Intelligent AI model selection and task orchestration', inputSchema: { type: 'object', properties: { task: { type: 'object', properties: { id: { type: 'string', description: 'Unique identifier for the task' }, input: { type: 'string', description: 'The task description or input to process' }, priority: { type: 'string', enum: ['low', 'medium', 'high'], description: 'Task priority level' }, type: { type: 'string', enum: ['simple', 'code_writing', 'analytical', 'complex'], description: 'Type of task for optimal model selection' }, context: { type: 'string', description: 'Additional context for the task' } }, required: ['id', 'input', 'priority'] } }, required: ['task'] } }, { name: 'web_search', description: 'Search the web using SerpAPI for real-time information', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query to find information on the web' }, num_results: { type: 'number', minimum: 1, maximum: 20, description: 'Number of search results to return (1-20)' }, api_key: { type: 'string', description: 'SerpAPI key (optional if set in environment variable)' } }, required: ['query'] } } ] }; }); // Handle tool calls 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 }; } }); // Error handling server.onerror = (error) => { console.error('[MCP Error]', error); }; process.on('SIGINT', async () => { await server.close(); process.exit(0); }); // Start server const transport = new stdio_js_1.StdioServerTransport(); await server.connect(transport); console.error('IntelliCodeMCP server running on stdio'); } startMCPServer().catch((error) => { console.error('Failed to start server:', error); process.exit(1); }); //# sourceMappingURL=intellicodemcp.js.map