describe_table
Retrieve table structure details including columns, data types, and constraints for database analysis and schema understanding.
Instructions
Get table structure
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table name |
Implementation Reference
- src/index.ts:776-799 (handler)The handler function that implements the core logic of the describe_table tool. It ensures a database connection, validates the table argument, executes a MySQL DESCRIBE query, 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:313-322 (schema)Input schema defining the parameters for the describe_table tool, requiring a 'table' string.inputSchema: { type: 'object', properties: { table: { type: 'string', description: 'Table name', }, }, required: ['table'], },
- src/index.ts:310-323 (registration)Tool registration in the ListTools response, including name, description, and schema.{ name: 'describe_table', description: 'Get table structure', inputSchema: { type: 'object', properties: { table: { type: 'string', description: 'Table name', }, }, required: ['table'], }, },
- src/index.ts:545-546 (registration)Dispatch case in the CallToolRequestSchema handler that routes to the describe_table handler.case 'describe_table': return await this.handleDescribeTable(request.params.arguments);