describe_table
Retrieve the structure of a MySQL table, including column names, data types, and constraints, using the MCP MySQL Server for efficient database management.
Instructions
Get table structure
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table name |
Implementation Reference
- src/index.ts:339-362 (handler)The main handler function for the 'describe_table' tool. It ensures a database connection, validates the table argument, executes a 'DESCRIBE' SQL query using the provided table name, and returns the table structure as JSON.private async handleDescribeTable(args: any) { await this.ensureConnection(); if (!args.table) { throw new McpError(ErrorCode.InvalidParams, 'Table name is required'); } try { const [rows] = await this.connection!.query('DESCRIBE ??', [args.table]); return { content: [ { type: 'text', text: JSON.stringify(rows, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to describe table: ${getErrorMessage(error)}` ); } }
- src/index.ts:179-188 (schema)Input schema definition for the 'describe_table' tool, specifying that a 'table' string parameter is required.inputSchema: { type: 'object', properties: { table: { type: 'string', description: 'Table name', }, }, required: ['table'], },
- src/index.ts:176-189 (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:203-204 (registration)Dispatch case in the CallToolRequest handler that routes 'describe_table' calls to the handleDescribeTable method.case 'describe_table': return await this.handleDescribeTable(request.params.arguments);