describe_table
Retrieve the structure of a MySQL database table to understand column definitions, data types, and constraints.
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 handler function that executes the DESCRIBE SQL query to get the table structure.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 for the describe_table tool defining the required 'table' parameter.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.{ 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)Registration and dispatch of describe_table in the CallToolRequest switch statement.case 'describe_table': return await this.handleDescribeTable(request.params.arguments);