Skip to main content
Glama
pickstar-2002

MySQL MCP Server

mysql_describe_table

View MySQL table structure including columns, data types, and constraints to understand database schema and plan queries.

Instructions

查看表结构

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNameYes表名称
databaseNo数据库名称(可选)

Implementation Reference

  • Defines the input schema, description, and registers the mysql_describe_table tool in the ListTools response.
    {
      name: 'mysql_describe_table',
      description: '查看表结构',
      inputSchema: {
        type: 'object',
        properties: {
          tableName: { type: 'string', description: '表名称' },
          database: { type: 'string', description: '数据库名称(可选)' },
        },
        required: ['tableName'],
      },
    },
  • MCP server handler for mysql_describe_table tool that calls DatabaseManager.describeTable and returns formatted response.
    private async handleDescribeTable(args: { tableName: string; database?: string }): Promise<any> {
      const columns = await this.dbManager.describeTable(args.tableName, args.database);
      
      return {
        content: [
          {
            type: 'text',
            text: `表 ${args.tableName} 结构:\n${JSON.stringify(columns, null, 2)}`,
          },
        ],
      };
    }
  • Core implementation in DatabaseManager that executes the SQL query against information_schema.COLUMNS to retrieve table structure.
    async describeTable(tableName: string, database?: string): Promise<ColumnInfo[]> {
      const dbName = database || this.config?.database;
      if (!dbName) {
        throw new Error('请指定数据库名称');
      }
    
      const result = await this.query(`
        SELECT 
          COLUMN_NAME as field,
          COLUMN_TYPE as type,
          IS_NULLABLE as \`null\`,
          COLUMN_KEY as \`key\`,
          COLUMN_DEFAULT as \`default\`,
          EXTRA as extra,
          COLUMN_COMMENT as comment
        FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?
        ORDER BY ORDINAL_POSITION
      `, [dbName, tableName]);
      
      return result.rows as ColumnInfo[];
    }
  • Type definition for ColumnInfo used in the describeTable output.
    export interface ColumnInfo {
      field: string;
      type: string;
      null: string;
      key: string;
      default: string | null;
      extra: string;
      comment: string;
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 of behavioral disclosure. '查看表结构' (view table structure) implies a read-only operation, but it doesn't specify whether this requires database permissions, what the output format is (e.g., column details, types, constraints), or if it's safe to use. The description lacks behavioral details beyond the basic purpose.

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 phrase ('查看表结构') that is extremely concise and front-loaded with the core purpose. There is no wasted text, and it efficiently communicates the tool's function without unnecessary elaboration.

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 tool's moderate complexity (a database operation with 2 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like output format, error handling, or dependencies on other tools (e.g., 'mysql_connect'). For a tool in this context, more detail is needed to guide effective use.

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 parameters 'tableName' and 'database' documented in Chinese. The description doesn't add any meaning beyond what the schema provides (e.g., it doesn't explain parameter interactions or usage examples). With high schema coverage, the baseline score of 3 is appropriate as the schema handles parameter documentation adequately.

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

Purpose3/5

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

The description '查看表结构' (view table structure) states a clear purpose with a specific verb ('view') and resource ('table structure'), but it doesn't distinguish this tool from potential siblings like 'mysql_list_tables' or 'mysql_query' that might also provide table information. It's adequately specific but lacks sibling differentiation.

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 connection via 'mysql_connect'), exclusions, or comparisons to siblings like 'mysql_list_tables' (which lists tables) or 'mysql_query' (which could run DESCRIBE queries). Usage is implied but not explicitly stated.

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

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