Skip to main content
Glama
dpflucas

MySQL Database Access

describe_table

Retrieve the schema of a MySQL table to view its columns, data types, and structure details.

Instructions

Show the schema for a specific table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoDatabase name (optional, uses default if not specified)
tableYesTable name

Implementation Reference

  • src/index.ts:89-105 (registration)
    Tool registration for 'describe_table' — defines the tool name, description, and input schema (requires table name, optional database).
    {
      name: "describe_table",
      description: "Show the schema for a specific table",
      inputSchema: {
        type: "object",
        properties: {
          database: {
            type: "string",
            description: "Database name (optional, uses default if not specified)"
          },
          table: {
            type: "string",
            description: "Table name"
          }
        },
        required: ["table"]
      }
  • Handler for 'describe_table' — extracts database/table arguments, validates table is provided, executes DESCRIBE SQL query, and returns table schema as JSON.
    case "describe_table": {
      console.error('[Tool] Executing describe_table');
      
      const database = request.params.arguments?.database as string | undefined;
      const table = request.params.arguments?.table as string;
      
      if (!table) {
        throw new McpError(ErrorCode.InvalidParams, "Table name is required");
      }
      
      const { rows } = await executeQuery(
        pool,
        `DESCRIBE \`${table}\``,
        [],
        database
      );
      
      return {
        content: [{
          type: "text",
          text: JSON.stringify(rows, null, 2)
        }]
      };
    }
  • Input schema for describe_table — defines 'database' (optional string) and 'table' (required string) properties with type and description.
    {
      name: "describe_table",
      description: "Show the schema for a specific table",
      inputSchema: {
        type: "object",
        properties: {
          database: {
            type: "string",
            description: "Database name (optional, uses default if not specified)"
          },
          table: {
            type: "string",
            description: "Table name"
          }
        },
        required: ["table"]
      }
  • Helper function executeQuery used by describe_table handler — acquires a connection, optionally switches database via USE, executes the DESCRIBE SQL, applies row limits, and returns results.
    export async function executeQuery(
      pool: mysql.Pool,
      sql: string,
      params: any[] = [],
      database?: string
    ): Promise<{ rows: any; fields: mysql.FieldPacket[] }> {
      console.error(`[Query] Executing: ${sql}`);
      
      let connection: mysql.PoolConnection | null = null;
      
      try {
        // Get connection from pool
        connection = await pool.getConnection();
        
        // Use specific database if provided
        if (database) {
          console.error(`[Query] Using database: ${database}`);
          await connection.query(`USE \`${database}\``);
        }
        
        // Execute query with timeout
        const [rows, fields] = await Promise.race([
          connection.query(sql, params),
          new Promise<never>((_, reject) => {
            setTimeout(() => reject(new Error('Query timeout')), DEFAULT_TIMEOUT);
          }),
        ]);
        
        // Apply row limit if result is an array
        const limitedRows = Array.isArray(rows) && rows.length > DEFAULT_ROW_LIMIT
          ? rows.slice(0, DEFAULT_ROW_LIMIT)
          : rows;
        
        // Log result summary
        console.error(`[Query] Success: ${Array.isArray(rows) ? rows.length : 1} rows returned`);
        
        return { rows: limitedRows, fields };
      } catch (error) {
        console.error('[Error] Query execution failed:', error);
        throw error;
      } finally {
        // Release connection back to pool
        if (connection) {
          connection.release();
        }
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It only states 'show the schema' without disclosing behavioral traits like read-only nature, required permissions, idempotency, or error handling. This is insufficient for a tool with zero 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.

Conciseness4/5

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

The description is a single sentence with no waste. However, it could include a brief note on sibling differentiation or usage context, but overall it is appropriately concise.

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

Completeness3/5

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

For a simple introspection tool with two parameters and no output schema, the description is adequate but lacks details on return format, error cases, or prerequisites (e.g., table must exist). It does not reference siblings, leaving the agent to infer context.

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 baseline is 3. The description adds no additional meaning beyond the schema (e.g., clarifying what 'table' or 'database' refer to). It does not enhance parameter semantics.

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

Purpose5/5

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

"Show the schema for a specific table" uses a specific verb and resource, and clearly distinguishes from siblings like list_tables and execute_query.

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

Usage Guidelines3/5

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

The description implies usage for schema retrieval, but provides no explicit guidance on when to use this tool vs alternatives like list_tables (which only lists names) or execute_query (for custom queries). No when-not-to-use or alternative mentions.

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

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