Skip to main content
Glama
enemyrr

MCP-MySQL Server

describe_table

Retrieve the structure of a specified MySQL table, including column details and data types, using the MCP-MySQL Server for schema management and database operations.

Instructions

Get table structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesTable name

Implementation Reference

  • The handler function that implements the describe_table tool by querying the INFORMATION_SCHEMA.COLUMNS table to retrieve and format the table structure.
    private async handleDescribeTable(args: any) {
      if (!args.table) {
        throw new McpError(ErrorCode.InvalidParams, 'Table name is required');
      }
    
      const rows = await this.executeQuery(
        `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`,
        [this.config!.database, args.table]
      );
    
      const formattedRows = (rows as any[]).map(row => ({
        ...row,
        Null: row.Null === 'YES' ? 'YES' : 'NO'
      }));
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(formattedRows, null, 2),
          },
        ],
      };
    }
  • Input schema defining the required 'table' parameter for the describe_table tool.
    inputSchema: {
      type: 'object',
      properties: {
        table: {
          type: 'string',
          description: 'Table name',
        },
      },
      required: ['table'],
    },
  • src/index.ts:476-489 (registration)
    Registration of the describe_table tool in the ListTools response, including name, description, and input schema.
    {
      name: 'describe_table',
      description: 'Get table structure',
      inputSchema: {
        type: 'object',
        properties: {
          table: {
            type: 'string',
            description: 'Table name',
          },
        },
        required: ['table'],
      },
    },
  • src/index.ts:579-580 (registration)
    Dispatcher case in CallToolRequest handler that routes 'describe_table' calls to the handleDescribeTable method.
    case 'describe_table':
      return await this.handleDescribeTable(request.params.arguments);

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

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

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