Skip to main content
Glama
nilsir

MCP Server MySQL

by nilsir

describe_table

Retrieve the structure and schema of a MySQL database table to understand column definitions, data types, and constraints.

Instructions

Get the structure/schema of a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesTable name
databaseNoDatabase name (optional)

Implementation Reference

  • The handler function executes a DESCRIBE query on the specified table (optionally in a database) and returns the column structure including Field, Type, Null, Key, Default, and Extra.
    async ({ table, database }) => {
      const p = await getPool();
    
      const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``;
      const [rows] = await p.query<RowDataPacket[]>(`DESCRIBE ${tableName}`);
    
      const columns = rows as Array<{
        Field: string;
        Type: string;
        Null: string;
        Key: string;
        Default: string | null;
        Extra: string;
      }>;
      const output = { table, database: database || null, columns };
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(rows, null, 2),
          },
        ],
        structuredContent: output,
      };
    }
  • Input schema using Zod: required 'table' string and optional 'database' string.
    {
      table: z.string().describe("Table name"),
      database: z.string().optional().describe("Database name (optional)"),
    },
  • src/index.ts:265-298 (registration)
    Registration of the describe_table tool via server.tool call, including name, description, input schema, and handler.
    server.tool(
      "describe_table",
      "Get the structure/schema of a table",
      {
        table: z.string().describe("Table name"),
        database: z.string().optional().describe("Database name (optional)"),
      },
      async ({ table, database }) => {
        const p = await getPool();
    
        const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``;
        const [rows] = await p.query<RowDataPacket[]>(`DESCRIBE ${tableName}`);
    
        const columns = rows as Array<{
          Field: string;
          Type: string;
          Null: string;
          Key: string;
          Default: string | null;
          Extra: string;
        }>;
        const output = { table, database: database || null, columns };
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(rows, null, 2),
            },
          ],
          structuredContent: output,
        };
      }
    );
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 the tool retrieves structure/schema, implying a read-only operation, but doesn't disclose behavioral traits such as required permissions, error handling (e.g., if the table doesn't exist), or output format (e.g., whether it returns columns, types, constraints). This is a significant gap 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 with zero waste. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration, 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 complexity (a read operation with 2 parameters) and lack of annotations and output schema, the description is incomplete. It doesn't explain what the structure/schema includes (e.g., column details, data types), potential errors, or dependencies, leaving gaps for effective tool use despite the concise purpose statement.

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 ('table' as 'Table name' and 'database' as 'Database name (optional)'). The description adds no additional meaning beyond what the schema provides, such as format examples or constraints, so it meets the baseline of 3 for high schema coverage.

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 'Get the structure/schema of a table', which specifies the verb ('Get') and resource ('structure/schema of a table'). It distinguishes from siblings like 'list_tables' (which lists names) or 'query' (which retrieves data), but doesn't explicitly differentiate from all siblings like 'alter_table' (which modifies structure).

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 prerequisites (e.g., needing an active database connection), exclusions, or comparisons to siblings like 'list_tables' (for table names) or 'query' (for data retrieval), leaving usage context unclear.

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

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