describe_table
Retrieve the schema structure of any MSSQL database table, including column names and data types, to understand table composition for query planning and data analysis.
Instructions
Describes the schema (columns and types) of a specified MSSQL Database table.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | Yes | Name of the table to describe |
Implementation Reference
- src/tools/DescribeTableTool.ts:17-34 (handler)The `run` method implementing the core logic of the `describe_table` tool, which queries the INFORMATION_SCHEMA.COLUMNS to retrieve column names and data types for the specified table.async run(params: { tableName: string }) { try { const { tableName } = params; const request = new sql.Request(); const query = `SELECT COLUMN_NAME as name, DATA_TYPE as type FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @tableName`; request.input("tableName", sql.NVarChar, tableName); const result = await request.query(query); return { success: true, columns: result.recordset, }; } catch (error) { return { success: false, message: `Failed to describe table: ${error}`, }; } }
- src/tools/DescribeTableTool.ts:9-15 (schema)The input schema defining the required `tableName` parameter for the `describe_table` tool.inputSchema = { type: "object", properties: { tableName: { type: "string", description: "Name of the table to describe" }, }, required: ["tableName"], } as any;
- src/index.ts:96-96 (registration)Instantiation of the DescribeTableTool instance used throughout the server.const describeTableTool = new DescribeTableTool();
- src/index.ts:116-119 (registration)Registration of `describeTableTool` in the list of available tools returned by ListToolsRequestSchema handler, conditionally based on readonly mode.tools: isReadOnly ? [listTableTool, readDataTool, describeTableTool] // todo: add searchDataTool to the list of tools available in readonly mode once implemented : [insertDataTool, readDataTool, describeTableTool, updateDataTool, createTableTool, createIndexTool, dropTableTool, listTableTool], // add all new tools here }));
- src/index.ts:147-155 (registration)Dispatch logic in CallToolRequestSchema handler for executing the `describe_table` tool, including input validation.case describeTableTool.name: if (!args || typeof args.tableName !== "string") { return { content: [{ type: "text", text: `Missing or invalid 'tableName' argument for describe_table tool.` }], isError: true, }; } result = await describeTableTool.run(args as { tableName: string }); break;