Skip to main content
Glama
michaelyuwh

Enhanced MCP MSSQL Server

by michaelyuwh

mssql_describe_table

Retrieve detailed table structure information including columns, data types, and constraints from Microsoft SQL Server databases for schema analysis and documentation.

Instructions

Get detailed information about a table structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverYesMSSQL Server hostname or IP address
portNoPort number (default: 1433)
userYesUsername for authentication
passwordYesPassword for authentication
databaseYesDatabase name
tableYesTable name
encryptNoUse encrypted connection (default: true)
trustServerCertificateNoTrust server certificate (default: true)

Implementation Reference

  • The handler function that executes the mssql_describe_table tool. It parses input arguments using ConnectionSchema, establishes a database connection, queries INFORMATION_SCHEMA.COLUMNS with a LEFT JOIN to identify primary keys, and returns structured JSON with table column details including name, type, nullability, default, lengths, precision, scale, and primary key status.
    private async handleDescribeTable(args: any) {
      const config = ConnectionSchema.parse(args);
      const { table } = args;
      const pool = await this.getConnection(config);
      
      const request = pool.request();
      const result = await request.query(`
        USE [${config.database}];
        SELECT 
          c.COLUMN_NAME as column_name,
          c.DATA_TYPE as data_type,
          c.IS_NULLABLE as is_nullable,
          c.COLUMN_DEFAULT as default_value,
          c.CHARACTER_MAXIMUM_LENGTH as max_length,
          c.NUMERIC_PRECISION as precision,
          c.NUMERIC_SCALE as scale,
          CASE WHEN pk.COLUMN_NAME IS NOT NULL THEN 'YES' ELSE 'NO' END as is_primary_key
        FROM INFORMATION_SCHEMA.COLUMNS c
        LEFT JOIN (
          SELECT ku.TABLE_CATALOG, ku.TABLE_SCHEMA, ku.TABLE_NAME, ku.COLUMN_NAME
          FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc
          INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS ku
            ON tc.CONSTRAINT_TYPE = 'PRIMARY KEY'
            AND tc.CONSTRAINT_NAME = ku.CONSTRAINT_NAME
        ) pk ON c.TABLE_CATALOG = pk.TABLE_CATALOG
          AND c.TABLE_SCHEMA = pk.TABLE_SCHEMA
          AND c.TABLE_NAME = pk.TABLE_NAME
          AND c.COLUMN_NAME = pk.COLUMN_NAME
        WHERE c.TABLE_NAME = '${table}'
        ORDER BY c.ORDINAL_POSITION
      `);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              server: config.server,
              database: config.database,
              table: table,
              columns: result.recordset,
            }, null, 2),
          },
        ],
      };
    }
  • Input schema definition for the mssql_describe_table tool, specifying properties like server, port, credentials, database, table, and connection options, with required fields enforced.
    inputSchema: {
      type: 'object',
      properties: {
        server: { type: 'string', description: 'MSSQL Server hostname or IP address' },
        port: { type: 'number', description: 'Port number (default: 1433)', default: 1433 },
        user: { type: 'string', description: 'Username for authentication' },
        password: { type: 'string', description: 'Password for authentication' },
        database: { type: 'string', description: 'Database name' },
        table: { type: 'string', description: 'Table name' },
        encrypt: { type: 'boolean', description: 'Use encrypted connection (default: true)', default: true },
        trustServerCertificate: { type: 'boolean', description: 'Trust server certificate (default: true)', default: true },
      },
      required: ['server', 'user', 'password', 'database', 'table'],
  • src/index.ts:305-322 (registration)
    Tool registration in the ListTools response, defining the name, description, and input schema for mssql_describe_table.
    {
      name: 'mssql_describe_table',
      description: 'Get detailed information about a table structure',
      inputSchema: {
        type: 'object',
        properties: {
          server: { type: 'string', description: 'MSSQL Server hostname or IP address' },
          port: { type: 'number', description: 'Port number (default: 1433)', default: 1433 },
          user: { type: 'string', description: 'Username for authentication' },
          password: { type: 'string', description: 'Password for authentication' },
          database: { type: 'string', description: 'Database name' },
          table: { type: 'string', description: 'Table name' },
          encrypt: { type: 'boolean', description: 'Use encrypted connection (default: true)', default: true },
          trustServerCertificate: { type: 'boolean', description: 'Trust server certificate (default: true)', default: true },
        },
        required: ['server', 'user', 'password', 'database', 'table'],
      },
    },
  • src/index.ts:441-442 (registration)
    Dispatch registration in the CallToolRequest handler switch statement that routes calls to the mssql_describe_table handler function.
    case 'mssql_describe_table':
      return await this.handleDescribeTable(args);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Get detailed information' implies a read-only operation, it doesn't explicitly state this or mention other behavioral traits like authentication requirements, potential performance impact, error conditions, or what format the detailed information will be returned in. The description is too minimal for a tool that interacts with a database system.

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 states the core purpose without any wasted words. It's appropriately sized for a straightforward tool and gets directly to the point with no unnecessary elaboration.

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?

For a database metadata tool with 8 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'detailed information' includes (columns, data types, constraints, indexes, etc.), doesn't mention authentication requirements despite the schema including user/password parameters, and provides no context about the complexity of the operation or expected output format.

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 schema description coverage is 100%, with all 8 parameters well-documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema, so it meets the baseline of 3 for high schema coverage. It doesn't explain how parameters interact or provide usage examples.

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 tool's purpose as 'Get detailed information about a table structure' which is a specific verb+resource combination. It distinguishes itself from siblings like mssql_list_tables (which lists tables) and mssql_query (which executes queries), though it doesn't explicitly mention these distinctions in the description text itself.

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. It doesn't mention when this tool is appropriate compared to mssql_list_tables (for listing tables) or mssql_get_relationships (for understanding table relationships), nor does it specify prerequisites or constraints for its use.

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

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