Skip to main content
Glama
cwilby

SQL Server MCP

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") },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves a table but doesn't mention whether it's a read-only operation, what happens if the table doesn't exist (e.g., error handling), or the format of the returned data. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It is front-loaded and directly conveys the core purpose without unnecessary details, making it highly concise and well-structured for its simplicity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'Get' entails (e.g., returns metadata, schema, or data), error conditions, or how it fits with sibling tools like transactions. For a tool with no structured behavioral data, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the parameter 'tableName' documented as 'The name of the table to retrieve'. The description adds no additional meaning beyond this, as it only repeats the concept of retrieving by name without specifying syntax, constraints, or examples. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('a specific table by name'), making the purpose understandable. It doesn't explicitly differentiate from sibling tools like 'get-tables' (plural) or 'query', but the specificity of retrieving a single table by name is reasonably clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get-tables' (for listing tables) or 'query' (for querying table data). It lacks context about prerequisites, such as needing an existing table name, or exclusions, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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