Skip to main content
Glama
Darkstar326

MCP MySQL Server

by Darkstar326

mysql_show_indexes

Display indexes for a MySQL table to analyze query performance and optimize database structure. Specify the table name and optionally the database.

Instructions

Show indexes for a specific table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesTable name to show indexes for
databaseNoDatabase name (uses current database if not specified)

Implementation Reference

  • The main handler function for the 'mysql_show_indexes' tool. It validates input, constructs the full table name, executes the 'SHOW INDEX FROM <table>' SQL query using the MySQL pool, and returns the results as formatted text content.
    private async handleShowIndexes(args: any) {
      if (!this.pool) {
        throw new Error("Not connected to MySQL. Use mysql_connect first.");
      }
    
      const { table, database } = args;
      
      if (!table) {
        throw new Error("Table name is required");
      }
    
      const fullTableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``;
    
      try {
        const [results] = await this.pool.execute(`SHOW INDEX FROM ${fullTableName}`);
        return {
          content: [
            {
              type: "text",
              text: `Indexes for table '${table}':\n${JSON.stringify(results, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to show indexes: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/index.ts:196-213 (registration)
    Tool registration in the ListTools handler, defining the name, description, and input schema for 'mysql_show_indexes'.
    {
      name: "mysql_show_indexes",
      description: "Show indexes for a specific table",
      inputSchema: {
        type: "object",
        properties: {
          table: {
            type: "string",
            description: "Table name to show indexes for",
          },
          database: {
            type: "string",
            description: "Database name (uses current database if not specified)",
          },
        },
        required: ["table"],
      },
    },
  • Input schema (JSON Schema) for the mysql_show_indexes tool, specifying required 'table' parameter and optional 'database'.
    inputSchema: {
      type: "object",
      properties: {
        table: {
          type: "string",
          description: "Table name to show indexes for",
        },
        database: {
          type: "string",
          description: "Database name (uses current database if not specified)",
        },
      },
      required: ["table"],
    },
  • src/index.ts:259-260 (registration)
    Dispatch case in the CallToolRequest handler that routes calls to the mysql_show_indexes tool to its handler function.
    case "mysql_show_indexes":
      return await this.handleShowIndexes(args);

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
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 states what the tool does but doesn't describe the return format (e.g., structure of index information), potential errors, or any operational constraints like performance impact. This leaves significant gaps for an AI agent to understand the tool's behavior.

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 purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to parse quickly.

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 lack of annotations and output schema, the description is incomplete for a tool that likely returns structured data about indexes. It doesn't explain what information is returned (e.g., index names, columns, types) or how to interpret the results, which is crucial for an AI agent to use the tool effectively.

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 in the input schema. The description adds no additional meaning beyond what the schema provides, such as examples or edge cases. 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 verb ('Show') and resource ('indexes for a specific table'), making the purpose immediately understandable. It doesn't differentiate from sibling tools like mysql_describe_table or mysql_get_table_stats, which might also provide index-related information, so it doesn't reach the highest score.

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 like mysql_describe_table or mysql_get_table_stats, which could potentially overlap in functionality. It lacks any mention of prerequisites, exclusions, or specific contexts for usage.

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