Skip to main content
Glama
sajithrw

MCP MySQL Server

by sajithrw

mysql_get_table_stats

Retrieve table statistics like row count and size from MySQL databases to monitor performance and optimize queries.

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

  • Executes the mysql_get_table_stats tool by querying the INFORMATION_SCHEMA.TABLES for statistics like row count, data length, index length, etc., for the specified table.
    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)}`);
      }
    }
  • Input schema definition for the mysql_get_table_stats tool, specifying parameters table (required) 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"],
    },
  • src/index.ts:214-231 (registration)
    Tool registration in the listTools response, defining name, description, and inputSchema 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"],
      },
    },
  • src/index.ts:261-262 (registration)
    Dispatch case in the CallToolRequest handler that routes to the mysql_get_table_stats handler function.
    case "mysql_get_table_stats":
      return await this.handleGetTableStats(args);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves statistics, implying a read-only operation, but doesn't specify whether it requires specific permissions, has performance implications (e.g., for large tables), or what the return format looks like (e.g., structured data vs. raw text). For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior and constraints.

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 extremely concise and front-loaded, consisting of a single sentence that directly states the tool's purpose with no wasted words. Every part of the sentence ('Get statistics about a table' and the parenthetical examples) contributes essential information, making it efficient and easy to parse.

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 a database statistics tool with no annotations and no output schema, the description is insufficiently complete. It doesn't cover behavioral aspects like permissions, performance, or error handling, and with no output schema, it fails to describe what the return values look like (e.g., JSON structure, units for size). For a tool that could involve significant data retrieval, more context is needed to ensure proper usage.

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 both parameters (table and database) fully documented in the input schema. The description adds no additional parameter semantics beyond what the schema provides—it doesn't explain format requirements, valid table/database names, or default behaviors. Given the high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 with a specific verb ('Get') and resource ('statistics about a table'), including examples of what statistics are retrieved ('row count, size, etc.'). It distinguishes itself from siblings like mysql_describe_table or mysql_show_indexes by focusing on statistical metrics rather than schema or index details. However, it doesn't explicitly differentiate from all siblings (e.g., mysql_query could potentially retrieve similar data), keeping it at a 4 rather than a 5.

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. It doesn't mention when to prefer mysql_get_table_stats over other tools like mysql_describe_table for structural info or mysql_query for custom statistical queries. There's also no indication of prerequisites (e.g., needing a connection established via mysql_connect) or exclusions, leaving usage context entirely implicit.

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

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