describe_table
Display the schema of a MySQL database table to understand its structure, columns, data types, and constraints for query planning and data analysis.
Instructions
Show the schema for a specific table
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Database name (optional, uses default if not specified) | |
| table | Yes | Table name |
Implementation Reference
- src/index.ts:171-194 (handler)The main handler logic for the 'describe_table' tool. Extracts database and table parameters, validates table name, executes DESCRIBE query via executeQuery helper, and returns schema as JSON.case "describe_table": { console.error('[Tool] Executing describe_table'); const database = request.params.arguments?.database as string | undefined; const table = request.params.arguments?.table as string; if (!table) { throw new McpError(ErrorCode.InvalidParams, "Table name is required"); } const { rows } = await executeQuery( pool, `DESCRIBE \`${table}\``, [], database ); return { content: [{ type: "text", text: JSON.stringify(rows, null, 2) }] }; }
- src/index.ts:92-105 (schema)Input schema for 'describe_table' tool: optional 'database' string, required 'table' string.inputSchema: { type: "object", properties: { database: { type: "string", description: "Database name (optional, uses default if not specified)" }, table: { type: "string", description: "Table name" } }, required: ["table"] }
- src/index.ts:89-106 (registration)Registration of the 'describe_table' tool in the ListTools response, including name, description, and schema.{ name: "describe_table", description: "Show the schema for a specific table", inputSchema: { type: "object", properties: { database: { type: "string", description: "Database name (optional, uses default if not specified)" }, table: { type: "string", description: "Table name" } }, required: ["table"] } },