Skip to main content
Glama
Darkstar326

MCP MySQL Server

by Darkstar326

mysql_get_table_stats

Retrieve table statistics including row count and size from MySQL databases to monitor performance and optimize storage.

Instructions

Get statistics about a table (row count, size, etc.)

Input Schema

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

Implementation Reference

  • The handler function that implements the mysql_get_table_stats tool by querying INFORMATION_SCHEMA.TABLES for table statistics including row count, engine, data length, index length, and other metrics.
    private async handleGetTableStats(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");
      }
    
      try {
        // Get table information from information_schema
        const dbCondition = database ? `AND TABLE_SCHEMA = '${database}'` : "";
        const query = `
          SELECT 
            TABLE_NAME,
            ENGINE,
            TABLE_ROWS,
            DATA_LENGTH,
            INDEX_LENGTH,
            DATA_FREE,
            AUTO_INCREMENT,
            CREATE_TIME,
            UPDATE_TIME,
            CHECK_TIME
          FROM INFORMATION_SCHEMA.TABLES 
          WHERE TABLE_NAME = '${table}' ${dbCondition}
        `;
    
        const [results] = await this.pool.execute(query);
        return {
          content: [
            {
              type: "text",
              text: `Statistics for table '${table}':\n${JSON.stringify(results, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get table statistics: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/index.ts:214-231 (registration)
    Tool registration in the listTools handler, defining the name, description, and input schema for mysql_get_table_stats.
    {
      name: "mysql_get_table_stats",
      description: "Get statistics about a table (row count, size, etc.)",
      inputSchema: {
        type: "object",
        properties: {
          table: {
            type: "string",
            description: "Table name to get statistics for",
          },
          database: {
            type: "string",
            description: "Database name (uses current database if not specified)",
          },
        },
        required: ["table"],
      },
    },
  • Input schema definition for the mysql_get_table_stats tool, specifying required 'table' parameter and optional 'database'.
    inputSchema: {
      type: "object",
      properties: {
        table: {
          type: "string",
          description: "Table name to get statistics for",
        },
        database: {
          type: "string",
          description: "Database name (uses current database if not specified)",
        },
      },
      required: ["table"],
    },
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. It states it's a read operation ('Get'), but doesn't disclose behavioral traits such as performance impact, permissions required, whether it's cached or real-time, or error handling. This leaves significant gaps for a tool that interacts with a database.

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

Conciseness4/5

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

The description is a single, efficient sentence that front-loads the purpose. It avoids unnecessary words, though 'etc.' is vague and could be more precise. Overall, it's appropriately sized for a simple tool.

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 no annotations and no output schema, the description is incomplete. It doesn't explain what statistics are returned (e.g., format, specific metrics beyond row count and size), behavioral context, or usage guidelines. For a database tool with potential complexity, this leaves the agent under-informed.

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?

Schema description coverage is 100%, so the schema fully documents both parameters (table and database). The description adds no additional meaning beyond implying statistics are for a table, which is already clear from the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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 'Get' and resource 'statistics about a table', specifying the type of information (row count, size, etc.). It distinguishes from siblings like mysql_describe_table (schema structure) and mysql_query (general queries), though not explicitly named. However, it could be more specific about what 'etc.' includes.

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?

No explicit guidance on when to use this tool versus alternatives. It doesn't mention siblings like mysql_describe_table for schema details or mysql_query for custom statistics, nor does it specify prerequisites (e.g., connection state). Usage is implied by the purpose but lacks clear differentiation.

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/Darkstar326/mcp-mysql'

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