get_index_recommendations
Analyze database performance and generate index recommendations to optimize SQL Server queries and improve execution efficiency.
Instructions
Get index recommendations for database optimization
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Database name (optional) | |
| schema | No | Schema name (optional, defaults to dbo) | |
| limit | No | Maximum number of recommendations to return (optional, defaults to 10) | |
| impact_threshold | No | Minimum impact score threshold (0-100, optional) |
Implementation Reference
- index.js:637-656 (handler)Primary handler for the get_index_recommendations tool. Delegates to QueryOptimizer.analyzeIndexUsage and formats JSON response.async getIndexRecommendations(database) { try { const recommendations = await this.queryOptimizer.analyzeIndexUsage(database); return [ { type: 'text', text: JSON.stringify( { success: true, data: recommendations }, null, 2 ) } ]; } catch (error) { throw new McpError(ErrorCode.InternalError, error.message); } }
- lib/analysis/query-optimizer.js:738-757 (handler)Core implementation logic for generating index recommendations (placeholder implementation). Called by main handler.async analyzeIndexUsage(database) { // Basic index recommendations - this would normally query SQL Server DMVs return { database, timestamp: new Date().toISOString(), recommendations: [ { type: 'missing_index', priority: 'high', suggestion: 'Consider adding indexes on frequently queried columns', impact: 'Could improve query performance by 50-80%', table: 'example_table', columns: ['column1', 'column2'] } ], unusedIndexes: [], duplicateIndexes: [], fragmentedIndexes: [] }; }
- lib/tools/tool-registry.js:177-194 (schema)Tool definition with name, description, and input schema used for MCP tool listing and validation.name: 'get_index_recommendations', description: 'Get index recommendations for database optimization', inputSchema: { type: 'object', properties: { database: { type: 'string', description: 'Database name (optional)' }, schema: { type: 'string', description: 'Schema name (optional, defaults to dbo)' }, limit: { type: 'number', description: 'Maximum number of recommendations to return (optional, defaults to 10)' }, impact_threshold: { type: 'number', description: 'Minimum impact score threshold (0-100, optional)' } } } },
- index.js:328-331 (registration)Dispatch case in the main tool request handler switch statement that routes to the tool handler.case 'get_index_recommendations': return { content: await this.getIndexRecommendations(args.database) };