describe_table
Extract and display the structure of a specified MySQL table, including its columns, data types, and schema details, using the standardized MCP MySQL Server interface.
Instructions
Get table structure
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table name |
Implementation Reference
- src/index.ts:599-632 (handler)The main execution logic for the 'describe_table' tool. It validates the table argument, executes a query against INFORMATION_SCHEMA.COLUMNS to retrieve column details, formats the null flag, and returns the structured table description as JSON.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), }, ], }; }
- src/index.ts:429-438 (schema)Input schema definition for the 'describe_table' tool, specifying an object with a required 'table' string property.inputSchema: { type: 'object', properties: { table: { type: 'string', description: 'Table name', }, }, required: ['table'], },
- src/index.ts:426-439 (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:527-528 (registration)Dispatch/registration case in the CallToolRequest handler that routes to the handleDescribeTable method.case 'describe_table': return await this.handleDescribeTable(request.params.arguments);