Skip to main content
Glama

mysql_schema

Inspect WordPress database schema to list tables or view columns and indexes for development analysis.

Instructions

Inspect database schema. Without args: lists tables. With table: shows columns and indexes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNoOptional table name to inspect

Implementation Reference

  • Handler function for the 'mysql_schema' tool. If no table is provided, lists all tables. Otherwise, fetches columns and indexes for the specified table using MySQLClient methods and returns JSON-formatted results.
    case 'mysql_schema': {
      const table = args.table as string | undefined;
      if (!table) {
        const tables = await mysql.listTables();
        return { content: [{ type: 'text', text: JSON.stringify(tables, null, 2) }] };
      }
      const [columns, indexes] = await Promise.all([
        mysql.getTableColumns(table),
        mysql.getTableIndexes(table),
      ]);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({ table, columns, indexes }, null, 2),
          },
        ],
      };
    }
  • Input schema definition for the mysql_schema tool, defining an optional 'table' string parameter.
    inputSchema: {
      type: 'object',
      properties: {
        table: {
          type: 'string',
          description: 'Optional table name to inspect',
        },
      },
    },
  • src/index.ts:81-94 (registration)
    Registration of the mysql_schema tool in the tools array returned by ListToolsRequestHandler.
      {
        name: 'mysql_schema',
        description: 'Inspect database schema. Without args: lists tables. With table: shows columns and indexes.',
        inputSchema: {
          type: 'object',
          properties: {
            table: {
              type: 'string',
              description: 'Optional table name to inspect',
            },
          },
        },
      },
    ];
  • Helper method to list all tables in the database, used when no table is specified in mysql_schema.
    async listTables(): Promise<any[]> {
      const sql = `
        SELECT
          TABLE_NAME AS table_name,
          ENGINE AS engine,
          TABLE_ROWS AS table_rows,
          DATA_LENGTH AS data_length,
          INDEX_LENGTH AS index_length
        FROM information_schema.TABLES
        WHERE TABLE_SCHEMA = DATABASE() AND TABLE_TYPE = 'BASE TABLE'
        ORDER BY TABLE_NAME
      `;
      return this.executeReadOnlyQuery(sql);
    }
  • Helper method to retrieve column information for a specific table, used in mysql_schema handler.
    async getTableColumns(table: string): Promise<any[]> {
      this.ensureSafeIdentifier(table);
      const sql = `
        SELECT
          COLUMN_NAME AS column_name,
          COLUMN_TYPE AS column_type,
          DATA_TYPE AS data_type,
          IS_NULLABLE AS is_nullable,
          COLUMN_DEFAULT AS column_default,
          COLUMN_KEY AS column_key,
          EXTRA AS extra
        FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?
        ORDER BY ORDINAL_POSITION
      `;
      return this.executeReadOnlyQuery(sql, [table]);
    }
  • Helper method to retrieve index information for a specific table, used in mysql_schema handler.
    async getTableIndexes(table: string): Promise<any[]> {
      this.ensureSafeIdentifier(table);
      const sql = `
        SELECT
          INDEX_NAME AS index_name,
          NON_UNIQUE AS non_unique,
          SEQ_IN_INDEX AS seq_in_index,
          COLUMN_NAME AS column_name,
          INDEX_TYPE AS index_type
        FROM information_schema.STATISTICS
        WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?
        ORDER BY index_name, seq_in_index
      `;
      return this.executeReadOnlyQuery(sql, [table]);
    }
Behavior3/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 describes the tool's dual behavior based on argument presence, which is useful context. However, it doesn't cover other behavioral traits such as permissions needed, rate limits, error handling, or output format details, leaving gaps for a tool that inspects database schema.

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 two sentences that efficiently convey the tool's dual functionality. Every word earns its place, with no redundant or verbose language, making it easy to parse quickly.

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?

Given the tool's moderate complexity (dual behavior based on parameter presence) and lack of annotations or output schema, the description is partially complete. It covers the basic operational modes but omits details on output structure, error cases, or integration with the sibling tool 'mysql_query'. It's adequate for minimal use but has clear gaps for full contextual understanding.

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 input schema has 100% description coverage, with the parameter 'table' documented as optional. The description adds value by explaining the semantic effect of providing or omitting the parameter, but it doesn't provide additional details beyond what the schema already states, such as format constraints or examples. Baseline 3 is appropriate given 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 function as inspecting database schema, with specific behaviors for two scenarios: listing tables without arguments and showing columns/indexes with a table argument. It uses the verb 'inspect' with the resource 'database schema', making the purpose unambiguous. However, it doesn't explicitly differentiate from the sibling tool 'mysql_query', which likely executes queries rather than inspecting structure.

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 guidelines by specifying when to use with or without arguments, but it doesn't provide explicit guidance on when to choose this tool over alternatives like 'mysql_query'. It mentions the two operational modes but lacks context on prerequisites, exclusions, or comparative scenarios with siblings.

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/verygoodplugins/mcp-local-wp'

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