Skip to main content
Glama
pickstar-2002

MySQL MCP Server

mysql_describe_table

Retrieve the structure of a MySQL table, including columns, data types, and constraints, by specifying the table and optional database name via the MySQL MCP Server.

Instructions

查看表结构

Input Schema

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

Implementation Reference

  • Core handler implementation: executes DESCRIBE-like query on information_schema.COLUMNS to retrieve table structure (columns, types, nullability, etc.). This is the exact logic for mysql_describe_table.
    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[]; }
  • MCP server handler wrapper: calls DatabaseManager.describeTable and returns formatted text 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)}`, }, ], }; }
  • Tool schema definition: input schema for mysql_describe_table including parameters tableName (required) and database (optional).
    { name: 'mysql_describe_table', description: '查看表结构', inputSchema: { type: 'object', properties: { tableName: { type: 'string', description: '表名称' }, database: { type: 'string', description: '数据库名称(可选)' }, }, required: ['tableName'], }, },
  • src/server.ts:245-246 (registration)
    Tool dispatch registration: switch case mapping tool name to handler in CallToolRequest handler.
    case 'mysql_describe_table': return await this.handleDescribeTable(args as any);

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