detect_query_bottlenecks
Identify and analyze database query performance issues to optimize SQL Server execution efficiency and resolve bottlenecks.
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)The main handler function for the 'detect_query_bottlenecks' tool. It calls the BottleneckDetector and formats 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); } }
- index.js:338-341 (registration)Registration and dispatch case in the tool call handler switch statement.case 'detect_query_bottlenecks': return { content: await this.detectQueryBottlenecks(args.database) };
- lib/tools/tool-registry.js:196-213 (schema)Tool definition including name, description, and input schema. Used by getAllTools() for dynamic registration.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'] } } } },
- The delegated detection method in BottleneckDetector class, currently a placeholder that returns empty array.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([]); } }