Skip to main content
Glama
dhipskind253

mssql-mcp

by dhipskind253

describe_table

Retrieve column details, data types, nullability, identity, primary key, and default values for a specified table.

Instructions

Return columns, data types, nullability, identity, primary key, and defaults for a table.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaYesSchema name (e.g. "dbo").
tableYesTable name.

Implementation Reference

  • The `describeTable` method on `DbManager` that executes the SQL query against sys.columns, sys.tables, sys.indexes, and sys.default_constraints to return column metadata (name, type, max_length, precision, scale, nullability, identity, primary key, default value).
    async describeTable(schema: string, table: string) {
      const r = await (await this.getPool())
        .request()
        .input('schema', sql.NVarChar, schema)
        .input('table', sql.NVarChar, table).query(`
          SELECT
            c.name AS column_name,
            TYPE_NAME(c.user_type_id) AS data_type,
            c.max_length,
            c.precision,
            c.scale,
            c.is_nullable,
            c.is_identity,
            CASE WHEN pk.column_id IS NOT NULL THEN 1 ELSE 0 END AS is_primary_key,
            dc.definition AS default_value
          FROM sys.columns c
          INNER JOIN sys.tables t ON c.object_id = t.object_id
          INNER JOIN sys.schemas s ON t.schema_id = s.schema_id
          LEFT JOIN (
            SELECT ic.object_id, ic.column_id
            FROM sys.indexes i
            INNER JOIN sys.index_columns ic
              ON i.object_id = ic.object_id AND i.index_id = ic.index_id
            WHERE i.is_primary_key = 1
          ) pk ON pk.object_id = c.object_id AND pk.column_id = c.column_id
          LEFT JOIN sys.default_constraints dc
            ON dc.parent_object_id = c.object_id
           AND dc.parent_column_id = c.column_id
          WHERE s.name = @schema AND t.name = @table
          ORDER BY c.column_id
        `);
      return r.recordset;
    }
  • Zod schema for describe_table input parameters: `schema` (string, required, describes 'Schema name (e.g. "dbo")') and `table` (string, required, describes 'Table name.').
    {
      schema: z.string().describe('Schema name (e.g. "dbo").'),
      table: z.string().describe('Table name.'),
    },
  • src/index.ts:80-88 (registration)
    Registration of the 'describe_table' tool with the MCP server via `server.tool(...)`. Binds the tool name, description, and handler.
    server.tool(
      'describe_table',
      'Return columns, data types, nullability, identity, primary key, and defaults for a table.',
      {
        schema: z.string().describe('Schema name (e.g. "dbo").'),
        table: z.string().describe('Table name.'),
      },
      async ({ schema, table }) => runTool(() => db.describeTable(schema, table))
    );
Behavior4/5

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

Without annotations, the description bears full burden. It explicitly lists the returned information (columns, data types, nullability, identity, primary key, defaults), which is good. However, it does not disclose potential error cases, permission requirements, or if the result is a single object or list.

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 that captures the tool's purpose without waste. It is front-loaded with the key action and output.

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

Completeness4/5

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

Given the lack of output schema, the description adequately covers what the tool returns. It lists all key aspects of a table schema. Minor omission: it doesn't specify the output format (e.g., array of objects) or order.

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?

Both parameters have clear descriptions in the schema (schema name with example, table name). The description adds no extra meaning beyond these, so baseline of 3 is appropriate.

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

Purpose5/5

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

The description clearly states the tool returns columns, data types, nullability, identity, primary key, and defaults for a table. It distinguishes from siblings like list_tables (listing tables) and sample_rows (sampling data), making the purpose unambiguous.

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?

No guidance is provided on when to use this tool versus alternatives. There is no mention of prerequisites, exclusions, or other tools like list_foreign_keys for more detailed schema info.

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/dhipskind253/mssql-mcp'

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