UNPKG

ai-debug-local-mcp

Version:

🎯 ENHANCED AI GUIDANCE v4.1.2: Dramatically improved tool descriptions help AI users choose the right tools instead of 'close enough' options. Ultra-fast keyboard automation (10x speed), universal recording, multi-ecosystem debugging support, and compreh

213 lines • 9.95 kB
#!/usr/bin/env node import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js'; // Essential debugging tools only for Cursor const ESSENTIAL_TOOLS = [ 'inject_debugging', 'simulate_user_action', 'take_screenshot', 'monitor_realtime', 'run_audit', 'get_debug_report', 'start_ai_test_recording', 'generate_tests_from_session', 'review_generated_tests' ]; class CursorMinimalServer { server; fullServer; constructor() { this.server = new Server({ name: 'ai-debug-local-minimal', version: '1.0.0', }); this.setupToolHandlers(); this.setupErrorHandling(); } async setupToolHandlers() { // Import the full server dynamically try { const { LocalDebugEngine } = await import('./local-debug-engine.js'); this.fullServer = new LocalDebugEngine(); } catch (error) { console.error('Failed to load full debug engine:', error); } this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'inject_debugging', description: 'Start debugging session with browser automation', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to debug' }, framework: { type: 'string', description: 'Framework hint (auto/react/vue/nextjs/phoenix/flutter)' }, headless: { type: 'boolean', description: 'Run in headless mode', default: false } }, required: ['url'] } }, { name: 'simulate_user_action', description: 'Simulate user interactions (click, type, submit)', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Debug session ID' }, action: { type: 'string', enum: ['click', 'type', 'submit', 'scroll', 'hover'] }, selector: { type: 'string', description: 'CSS selector' }, value: { type: 'string', description: 'Value for type actions' } }, required: ['sessionId', 'action', 'selector'] } }, { name: 'take_screenshot', description: 'Capture screenshot for visual debugging', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Debug session ID' }, fullPage: { type: 'boolean', description: 'Capture full page', default: true } }, required: ['sessionId'] } }, { name: 'monitor_realtime', description: 'Monitor real-time application events', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Debug session ID' }, duration: { type: 'number', description: 'Monitoring duration in seconds', default: 30 } }, required: ['sessionId'] } }, { name: 'run_audit', description: 'Run comprehensive quality audits (performance, accessibility, SEO)', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Debug session ID' }, categories: { type: 'array', items: { enum: ['all', 'accessibility', 'performance', 'seo', 'security', 'bestPractices'] }, default: ['all'] } }, required: ['sessionId'] } }, { name: 'get_debug_report', description: 'Generate comprehensive debugging report', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Debug session ID' }, includeAI: { type: 'boolean', description: 'Include AI analysis', default: false } }, required: ['sessionId'] } }, { name: 'start_ai_test_recording', description: 'Begin AI test generation recording', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Debug session ID' }, testIntent: { type: 'string', description: 'What this test should validate' }, userStory: { type: 'string', description: 'Optional user story context' }, tags: { type: 'array', items: { type: 'string' }, description: 'Test categorization tags' } }, required: ['sessionId', 'testIntent'] } }, { name: 'generate_tests_from_session', description: 'Generate test code from recorded debugging session', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Debug session ID' }, framework: { type: 'string', enum: ['playwright', 'jest', 'cypress', 'exunit'], default: 'playwright', description: 'Test framework to generate for' } }, required: ['sessionId'] } }, { name: 'review_generated_tests', description: 'AI review of generated test code for quality', inputSchema: { type: 'object', properties: { testCode: { type: 'string', description: 'Test code to review' }, framework: { type: 'string', enum: ['playwright', 'jest', 'cypress', 'exunit'] }, qualityThreshold: { type: 'number', minimum: 0, maximum: 1, default: 0.85 } }, required: ['testCode', 'framework'] } } ] }; }); this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { // Delegate to full server if available if (this.fullServer && typeof this.fullServer.callTool === 'function') { return await this.fullServer.callTool(name, args); } // Fallback response if full server not available return { content: [ { type: 'text', text: `Tool ${name} is not available in minimal mode. Please install the full AI Debug Local MCP server.` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error executing ${name}: ${error instanceof Error ? error.message : String(error)}` } ], 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() { const transport = new StdioServerTransport(); await this.server.connect(transport); console.log('🔬 AI Debug Local MCP (Minimal) - 9 essential tools ready!'); } } const server = new CursorMinimalServer(); server.run().catch(console.error); //# sourceMappingURL=cursor-minimal-server.js.map