describe_table
Retrieve and display the schema of a specified table in MariaDB/MySQL databases, enabling users to understand its structure and attributes quickly. Supports optional database selection for precise queries.
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:137-146 (handler)Handler for the describe_table tool. It validates the table parameter, optionally uses a database, executes a DESCRIBE SQL query, and returns the table schema as formatted JSON.case "describe_table": { const tbl = args.table as string; if (!tbl) throw new McpError(ErrorCode.InvalidParams, "`table` is required"); const db = args.database as string | undefined; const { rows } = await executeQuery(`DESCRIBE \`${tbl}\``, [], db); return { content: [{ type: "text", text: JSON.stringify(rows, null, 2) }], }; }
- src/index.ts:95-103 (registration)Registration of the describe_table tool in the ListTools response, including its name, description, and input schema definition.{ name: "describe_table", description: "Show schema of a table", inputSchema: { type: "object", properties: { database: { type: "string" }, table: { type: "string" } }, required: ["table"], }, },
- src/index.ts:98-102 (schema)Input schema for describe_table tool defining required 'table' string and optional 'database' string.inputSchema: { type: "object", properties: { database: { type: "string" }, table: { type: "string" } }, required: ["table"], },