Skip to main content
Glama
cwilby
by cwilby

get-table

Retrieve a specific table by name from Microsoft SQL Server using the SQL Server MCP server, enabling direct database interactions for AI assistants.

Instructions

Get a specific table by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNameYesThe name of the table to retrieve

Implementation Reference

  • The handler function that implements the 'get-table' tool logic. It queries the database INFORMATION_SCHEMA for the specified table's columns and returns a formatted text result with column details.
    async getTable({ tableName }: { tableName: string }) { const table = await database.query(` SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @tableName ORDER BY ORDINAL_POSITION `, { tableName }); if (!table.length) return this.toResult(`Table with name: ${tableName} not found.`); const columns = table.map((col) => ({ columnName: col.COLUMN_NAME, dataType: col.DATA_TYPE, isNullable: col.IS_NULLABLE === "YES", })); return this.toResult(`Table: ${tableName}\nColumns:\n${JSON.stringify(columns)}`); }
  • Registration of the 'get-table' tool on the MCP server, including name, description, input schema, and binding to the handler method.
    server.tool( "get-table", "Get a specific table by name", { tableName: z.string().describe("The name of the table to retrieve") }, tools.getTable.bind(tools) )
  • Input schema definition using Zod for the 'get-table' tool, specifying the required 'tableName' string parameter.
    { tableName: z.string().describe("The name of the table to retrieve") },

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cwilby/mcp-node-mssql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server