Skip to main content
Glama

mysql_schema

Retrieve database schema for local WordPress sites. Lists all tables or details columns and indexes for a specified table.

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

  • The handler for the 'mysql_schema' tool. If no table argument is given, it calls mysql.listTables() to list all tables. If a table argument is provided, it calls mysql.getTableColumns(table) and mysql.getTableIndexes(table) in parallel and returns the schema info.
    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),
          },
        ],
      };
    }
  • The tool schema/definition for 'mysql_schema'. It defines the tool name, description, and input schema with an optional 'table' string parameter.
    {
      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',
          },
        },
      },
    },
  • src/index.ts:81-131 (registration)
    The 'mysql_schema' tool is registered as part of the 'tools' array on line 101-113 (within the array defined at line 81). The array is used in the ListToolsRequestSchema handler to advertise available tools.
    const tools: Tool[] = [
      {
        name: 'mysql_query',
        description: 'Execute a read-only SQL query against the Local WordPress database',
        inputSchema: {
          type: 'object',
          properties: {
            sql: {
              type: 'string',
              description: 'Single read-only SQL statement (SELECT/SHOW/DESCRIBE/EXPLAIN).',
            },
            params: {
              type: 'array',
              description: 'Optional parameter values for placeholders (?).',
              items: { type: 'string' },
            },
          },
          required: ['sql'],
        },
      },
      {
        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',
            },
          },
        },
      },
      {
        name: 'mysql_current_site',
        description:
          'Get information about the currently connected Local WordPress site, including how it was selected',
        inputSchema: {
          type: 'object',
          properties: {},
        },
      },
      {
        name: 'mysql_list_sites',
        description: 'List all available Local WordPress sites and their running status',
        inputSchema: {
          type: 'object',
          properties: {},
        },
      },
    ];
  • MySQLClient.listTables() method — queries information_schema.TABLES to list all base tables in the current database.
    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);
    }
  • MySQLClient.getTableColumns(table) method — queries information_schema.COLUMNS to get column details for a specific table.
    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]);
    }
Behavior3/5

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

No annotations provided, so description must cover behavior. It describes the two modes but lacks details on side effects, authentication, or output format. For a read-heavy tool, this is adequate but not thorough.

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?

Two tightly written sentences, no superfluous words. Purpose is front-loaded. Ideal conciseness for a simple tool.

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

Completeness4/5

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

Given the tool's simplicity (1 param, no output schema), the description covers the essential functionality. Minor omission: not specifying output format, but it's not critical for an inspect tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% for the single parameter. The description adds concrete meaning by explaining the effect of providing the table parameter versus omitting it, going beyond the schema's description.

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?

Clearly states the tool inspects database schema, with specific behavior: without args lists tables, with table shows columns and indexes. This distinguishes it from sibling tools like mysql_query or mysql_list_sites.

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

Usage Guidelines4/5

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

Provides clear usage guidance for both modes (with/without args) but does not explicitly mention when not to use or alternatives. The context is clear enough for basic usage.

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