Skip to main content
Glama
mlsloynaz

mcp-sqlserver

by mlsloynaz

describe_table

Get column names and data types for SQL Server tables to understand database structure and schema details.

Instructions

Return column names and types for a table.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesTable name (e.g. dbo.MyTable or MyTable)
schemaNoSchema name (e.g. dbo). Defaults to dbo if table has no schema prefix.

Implementation Reference

  • src/index.ts:215-247 (registration)
    Tool registration for 'describe_table' with MCP server, including description and input schema definition using zod.
    mcp.registerTool(
      "describe_table",
      {
        description: "Return column names and types for a table.",
        inputSchema: {
          table: z.string().describe("Table name (e.g. dbo.MyTable or MyTable)"),
          schema: z.string().optional().describe("Schema name (e.g. dbo). Defaults to dbo if table has no schema prefix."),
        },
      },
      async ({ table, schema }) => {
        try {
          const p = await getPool();
          const schemaName = schema ?? "dbo";
          const query = `
            SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, IS_NULLABLE
            FROM INFORMATION_SCHEMA.COLUMNS
            WHERE TABLE_SCHEMA = @schema AND TABLE_NAME = @table
            ORDER BY ORDINAL_POSITION
          `;
          const result = await p
            .request()
            .input("schema", sql.NVarChar(128), schemaName)
            .input("table", sql.NVarChar(128), table)
            .query(query);
          const rows = (result.recordset ?? []) as Record<string, unknown>[];
          const text = formatTable(rows);
          return { content: [{ type: "text" as const, text }] };
        } catch (err) {
          const msg = err instanceof Error ? err.message : String(err);
          return { content: [{ type: "text" as const, text: `Error: ${msg}` }], isError: true };
        }
      }
    );
  • Handler function that queries INFORMATION_SCHEMA.COLUMNS to retrieve column names, data types, max length, and nullability for a specified table.
    async ({ table, schema }) => {
      try {
        const p = await getPool();
        const schemaName = schema ?? "dbo";
        const query = `
          SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, IS_NULLABLE
          FROM INFORMATION_SCHEMA.COLUMNS
          WHERE TABLE_SCHEMA = @schema AND TABLE_NAME = @table
          ORDER BY ORDINAL_POSITION
        `;
        const result = await p
          .request()
          .input("schema", sql.NVarChar(128), schemaName)
          .input("table", sql.NVarChar(128), table)
          .query(query);
        const rows = (result.recordset ?? []) as Record<string, unknown>[];
        const text = formatTable(rows);
        return { content: [{ type: "text" as const, text }] };
      } catch (err) {
        const msg = err instanceof Error ? err.message : String(err);
        return { content: [{ type: "text" as const, text: `Error: ${msg}` }], isError: true };
      }
    }
  • Input schema validation defining 'table' (required) and 'schema' (optional) parameters for the describe_table tool.
    inputSchema: {
      table: z.string().describe("Table name (e.g. dbo.MyTable or MyTable)"),
      schema: z.string().optional().describe("Schema name (e.g. dbo). Defaults to dbo if table has no schema prefix."),
    },
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 returns column names and types, which is helpful, but lacks details on error handling (e.g., if the table doesn't exist), performance characteristics, or output format. For a tool with no annotations, this leaves significant behavioral gaps.

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, clear sentence with zero waste. It is front-loaded with the core purpose and efficiently conveys the essential information without unnecessary elaboration.

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

Completeness3/5

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

Given the tool's moderate complexity (metadata retrieval with 2 parameters) and no annotations or output schema, the description is minimally adequate. It covers the basic purpose but lacks details on behavior, error handling, and output structure, which are important for a tool without structured output documentation.

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?

Schema description coverage is 100%, meaning the input schema fully documents the two parameters ('table' and 'schema') with descriptions. The description adds no additional parameter semantics beyond what the schema provides, such as examples or constraints. Baseline 3 is appropriate when the schema handles 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 ('Return') and the resource ('column names and types for a table'), making the purpose unambiguous. However, it does not explicitly differentiate from sibling tools like 'list_tables' (which likely lists table names) or 'query' (which likely executes queries), though the distinction is somewhat implied by the specific focus on table metadata.

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 'list_tables' or 'query'. There is no mention of prerequisites, such as needing the table to exist, or any context for when this metadata retrieval is appropriate. Usage is implied only by the purpose statement.

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

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/mlsloynaz/mcp-sql-server'

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