Skip to main content
Glama
irwantocrimson

MySQL MCP Server

get-schema

Read-only

Retrieve the structure of a MySQL database table to understand its columns, data types, and constraints for development or analysis.

Instructions

Get the schema of a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNameYesThe name of the schema

Implementation Reference

  • The handler function for the 'get-schema' tool. It extracts the schemaName from args, calls the getSchema helper, and returns the result as a JSON-formatted text content block.
    async (args) => {
      const schemaName = args.schemaName;
      const result = await getSchema(schemaName);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2),
          }
        ]
      };
    }
  • Zod schema definition for the input parameter 'schemaName' of type string.
    schemaName: z.string().describe("The name of the schema"),
  • src/index.ts:82-101 (registration)
    Registration of the 'get-schema' tool using server.tool, including name, description, input schema, metadata, and handler function.
    server.tool("get-schema", "Get the schema of a table", {
      schemaName: z.string().describe("The name of the schema"),
    }, {
      title: "Get Schema",
      readOnlyHint: true,
      destructiveHint: false,
    },
      async (args) => {
        const schemaName = args.schemaName;
        const result = await getSchema(schemaName);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            }
          ]
        };
      }
    );
  • Helper function that connects to the MySQL database using configuration, executes a DESCRIBE query on the specified schemaName (table), and returns the results or error.
    async function getSchema(schemaName: string) {
      // Create the connection to database using config (environment variables or command-line arguments)
      const connection = await mysql.createConnection({
        host: config.host,
        port: config.port,
        user: config.user,
        password: config.password,
        database: config.database,
      });
    
      try {
        const [results] = await connection.query(
          `DESCRIBE ${mysql.escapeId(schemaName)}`
        );
    
        return results;
      } catch (err) {
        console.log(err);
        return err;
      } finally {
        connection.end();
      }
    }
Behavior3/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, so the agent knows this is a safe read operation. The description adds no behavioral context beyond what annotations provide (e.g., no information about permissions, rate limits, or what happens if the schema doesn't exist). It doesn't contradict annotations, but offers minimal additional value.

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, clear sentence with zero wasted words. It's front-loaded with the essential purpose and appropriately sized for a simple tool. Every word earns its place, making it highly efficient.

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 read-only tool with good annotations and full schema coverage, the description is minimally adequate. However, without an output schema, it doesn't explain what the return value looks like (e.g., structure of the schema object). Given the tool's simplicity, it's complete enough but leaves gaps about output format.

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 input schema fully documents the single parameter 'schemaName'. The description adds no parameter-specific information beyond implying it's for a table schema. Baseline 3 is appropriate when the schema carries the full parameter documentation burden.

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 action ('Get') and resource ('schema of a table'), making the purpose immediately understandable. It's specific about what it retrieves, though it doesn't need to differentiate from siblings since there are none. The verb+resource combination is precise and unambiguous.

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 when needing table schema information, but provides no explicit guidance on when to use it versus alternatives or any prerequisites. With no sibling tools, the need for differentiation is minimal, but it lacks any context about typical use cases or limitations.

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

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