Skip to main content
Glama
egarcia74

Warp SQL Server MCP

by egarcia74

analyze_query_performance

Analyze SQL query performance and receive optimization suggestions to improve database efficiency and execution speed.

Instructions

Analyze query performance and provide optimization suggestions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSQL query to analyze for performance optimization
databaseNoDatabase name (optional)

Implementation Reference

  • Core implementation performing static analysis on SQL queries: calculates complexity score, detects bottlenecks, generates performance warnings and optimization suggestions using heuristic analysis.
    analyzeQuery(query, executionStats = {}, planData = {}) {
      // Input validation to prevent null pointer exceptions
      if (!query || typeof query !== 'string') {
        throw new Error('Query must be a non-empty string');
      }
    
      try {
        const analysis = {
          query: query.trim(),
          query_type: this.determineQueryType(query),
          complexity_score: this.calculateComplexityScore(query),
          estimated_cost: planData.TotalSubtreeCost || 0,
          table_access_methods: this.extractTableAccessMethods(planData),
          join_algorithms: this.extractJoinAlgorithms(planData),
          operators: this.extractOperators(planData),
          bottlenecks: this.identifyBottlenecks(query, executionStats, planData),
          performance_warnings: this.generatePerformanceWarnings(query, executionStats),
          optimization_suggestions: this.generateOptimizationSuggestions(
            query,
            executionStats,
            planData
          ),
          is_modification_query: this.isModificationQuery(query)
        };
    
        return analysis;
      } catch (error) {
        // Log the error and return a safe fallback analysis
        console.error('Error during query analysis:', error.message);
        return {
          query: query.trim(),
          query_type: 'UNKNOWN',
          complexity_score: 0,
          estimated_cost: 0,
          table_access_methods: [],
          join_algorithms: [],
          operators: [],
          bottlenecks: [],
          performance_warnings: ['Query analysis failed due to parsing error'],
          optimization_suggestions: [],
          is_modification_query: false,
          error: 'Query analysis failed'
        };
      }
  • Tool schema definition including input validation schema with required 'query' parameter and optional 'database'.
      name: 'analyze_query_performance',
      description: 'Analyze query performance and provide optimization suggestions',
      inputSchema: {
        type: 'object',
        properties: {
          query: { type: 'string', description: 'SQL query to analyze for performance optimization' },
          database: { type: 'string', description: 'Database name (optional)' }
        },
        required: ['query']
      }
    }
  • index.js:333-336 (registration)
    Tool registration in the main MCP tool call dispatcher switch statement.
    case 'analyze_query_performance':
      return {
        content: await this.analyzeQueryPerformance(args.query, args.database)
      };
  • MCP tool handler wrapper that delegates analysis to QueryOptimizer class and formats JSON response.
    async analyzeQueryPerformance(query, database) {
      const analysis = await this.queryOptimizer.analyzeQuery(query, database);
      return [
        {
          type: 'text',
          text: JSON.stringify(
            {
              success: true,
              data: analysis
            },
            null,
            2
          )
        }
      ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions analysis and suggestions but doesn't describe what the tool actually does (e.g., runs diagnostics, returns metrics, or provides textual advice), whether it's read-only or has side effects, or any performance or permission considerations. This is inadequate for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of performance analysis and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., suggestions, metrics, or reports), how it interacts with the database, or any limitations. For a tool with no structured output and behavioral gaps, this is insufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with clear descriptions for both parameters ('query' and 'database'). The description adds no additional meaning beyond what the schema provides, such as format details or usage examples. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'analyze query performance and provide optimization suggestions,' which is a specific verb+resource combination. However, it doesn't differentiate from siblings like 'detect_query_bottlenecks' or 'get_optimization_insights,' which appear to have overlapping functionality. The purpose is clear but lacks sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'detect_query_bottlenecks,' 'explain_query,' and 'get_optimization_insights,' there's no indication of context, exclusions, or prerequisites. This leaves the agent guessing about the appropriate use case.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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