describe_table
Provides the schema details, including column names and data types, for a specified table in a Microsoft SQL Server database. Simplifies table structure analysis for queries and data manipulation.
Instructions
Describes the schema (columns and types) of a specified MSSQL Database table.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | Yes | Name of the table to describe |
Input Schema (JSON Schema)
{
"properties": {
"tableName": {
"description": "Name of the table to describe",
"type": "string"
}
},
"required": [
"tableName"
],
"type": "object"
}
Implementation Reference
- src/tools/DescribeTableTool.ts:17-34 (handler)The run method that executes the describe_table tool logic: queries MSSQL INFORMATION_SCHEMA.COLUMNS for the specified table's columns and types.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)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:90-90 (registration)Instantiation of the DescribeTableTool instance.const describeTableTool = new DescribeTableTool();
- src/index.ts:109-113 (registration)Registration of describeTableTool in the ListToolsRequestHandler for both read-only and full tool lists.server.setRequestHandler(ListToolsRequestSchema, async () => ({ 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:141-149 (registration)Dispatch case in CallToolRequestHandler that validates arguments and calls describeTableTool.run.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;