describe_table
Retrieve the structure of a specific MySQL table to analyze its columns, data types, and schema details for efficient database management and query optimization.
Instructions
Get the structure of a specific table.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Name of the table to describe |
Input Schema (JSON Schema)
{
"properties": {
"table": {
"description": "Name of the table to describe",
"type": "string"
}
},
"required": [
"table"
],
"type": "object"
}
Implementation Reference
- src/index.ts:454-482 (handler)The handler function for the 'describe_table' tool. It validates the table name parameter, executes a DESCRIBE SQL query using the shared executeQuery helper, and returns the table structure as JSON or an error message.case "describe_table": { try { const tableName = request.params.arguments?.table as string; if (!tableName) { throw new Error("Table name is required"); } const rows = await executeQuery("DESCRIBE ??", [tableName]); return { content: [{ type: "text", text: JSON.stringify(rows, null, 2) }], isError: false }; } catch (error) { return { content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error occurred" } ], isError: true }; } }
- src/index.ts:217-230 (registration)Registration of the 'describe_table' tool in the ListTools response, including its name, description, and input schema definition.{ name: "describe_table", description: "Get the structure of a specific table.", inputSchema: { type: "object", properties: { table: { type: "string", description: "Name of the table to describe" } }, required: ["table"] } },
- src/index.ts:220-229 (schema)Input schema for the 'describe_table' tool, defining the required 'table' string parameter.inputSchema: { type: "object", properties: { table: { type: "string", description: "Name of the table to describe" } }, required: ["table"] }