Skip to main content
Glama

get_query_performance

Analyze SQL query performance to identify slow queries and optimize database operations. Filter by specific tools and set limits for targeted performance breakdown.

Instructions

Get detailed query performance breakdown by tool

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of queries to analyze (optional, defaults to 50)
tool_filterNoFilter by specific MCP tool name (optional)
slow_onlyNoOnly return slow queries (optional, defaults to false)

Implementation Reference

  • The main handler function for the 'get_query_performance' tool. It retrieves query performance statistics from the PerformanceMonitor instance and returns them formatted as a JSON text response.
    getQueryPerformance(limit = 50) { const queryStats = this.performanceMonitor.getQueryStats(limit); return [ { type: 'text', text: JSON.stringify( { success: true, data: queryStats }, null, 2 ) } ]; }
  • The tool schema definition including name, description, and input schema for validation.
    { name: 'get_query_performance', description: 'Get detailed query performance breakdown by tool', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum number of queries to analyze (optional, defaults to 50)' }, tool_filter: { type: 'string', description: 'Filter by specific MCP tool name (optional)' }, slow_only: { type: 'boolean', description: 'Only return slow queries (optional, defaults to false)' } } } },
  • index.js:318-321 (registration)
    The switch case registration/dispatch that maps the tool name to its handler function during tool call handling.
    case 'get_query_performance': return { content: this.getQueryPerformance(args.limit) };
  • The core helper function getQueryStats in PerformanceMonitor class that processes query metrics, groups by tool, calculates statistics like average time, error rates, and returns detailed performance breakdown.
    getQueryStats(limit = 50) { if (!this.config.enabled) { return { enabled: false }; } const completedQueries = this.metrics.queries .filter(q => q.status === 'completed' || q.status === 'error') .sort((a, b) => b.startTime - a.startTime) .slice(0, limit); // Group by tool const byTool = {}; completedQueries.forEach(query => { if (!byTool[query.tool]) { byTool[query.tool] = { count: 0, totalTime: 0, errors: 0, slowQueries: 0 }; } byTool[query.tool].count++; byTool[query.tool].totalTime += query.duration; if (query.status === 'error') { byTool[query.tool].errors++; } if (query.duration > this.config.slowQueryThreshold) { byTool[query.tool].slowQueries++; } }); // Calculate averages Object.keys(byTool).forEach(tool => { const stats = byTool[tool]; stats.avgTime = stats.totalTime / stats.count; stats.errorRate = (stats.errors / stats.count) * 100; stats.slowQueryRate = (stats.slowQueries / stats.count) * 100; }); return { enabled: true, queries: completedQueries.map(q => ({ tool: q.tool, duration: q.duration, status: q.status, rowCount: q.rowCount, streaming: q.streaming, timestamp: q.startTime })), byTool, slowQueries: completedQueries.filter(q => q.duration > this.config.slowQueryThreshold) }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/egarcia74/warp-sql-server-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server