detect_query_bottlenecks
Identify and analyze database query performance issues to optimize SQL execution and improve system efficiency.
Instructions
Detect and analyze query bottlenecks in the database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Database name (optional) | |
| limit | No | Maximum number of bottlenecks to return (optional, defaults to 10) | |
| severity_filter | No | Filter by severity level: LOW, MEDIUM, HIGH, CRITICAL (optional) |
Implementation Reference
- index.js:675-694 (handler)Main MCP tool handler function that executes the detect_query_bottlenecks tool by delegating to the BottleneckDetector class and formatting the response.async detectQueryBottlenecks(database) { try { const bottlenecks = await this.bottleneckDetector.detectBottlenecks(database); return [ { type: 'text', text: JSON.stringify( { success: true, data: bottlenecks }, null, 2 ) } ]; } catch (error) { throw new McpError(ErrorCode.InternalError, error.message); } }
- lib/tools/tool-registry.js:196-212 (schema)Input schema definition for the detect_query_bottlenecks tool, including parameters for database, limit, and severity filter.name: 'detect_query_bottlenecks', description: 'Detect and analyze query bottlenecks in the database', inputSchema: { type: 'object', properties: { database: { type: 'string', description: 'Database name (optional)' }, limit: { type: 'number', description: 'Maximum number of bottlenecks to return (optional, defaults to 10)' }, severity_filter: { type: 'string', description: 'Filter by severity level: LOW, MEDIUM, HIGH, CRITICAL (optional)', enum: ['LOW', 'MEDIUM', 'HIGH', 'CRITICAL'] } } }
- index.js:338-341 (registration)Tool registration in the main request handler switch statement that routes calls to the detectQueryBottlenecks method.case 'detect_query_bottlenecks': return { content: await this.detectQueryBottlenecks(args.database) };
- Core helper method in BottleneckDetector class that performs the actual bottleneck detection (currently a placeholder implementation). Additional helper methods like analyzeQuery, identifyBottleneckType exist in the same class for supporting logic.async detectBottlenecks(query) { const pool = this.connectionManager.getPool(); if (!pool) { throw new Error('Not connected to any server'); } if (!query) { throw new Error('Query is required for detectBottlenecks'); } // Placeholder for actual implementation return Promise.resolve([]); }