Skip to main content
Glama
TranChiHuu

MCP SQL Server

by TranChiHuu

describe_table

Retrieve schema information for a database table to understand its structure, including column names, data types, and constraints.

Instructions

Get schema information for a specific table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNameYesName of the table to describe

Implementation Reference

  • The main handler function that implements the logic for the 'describe_table' tool. It queries the database information schema for PostgreSQL or uses DESCRIBE for MySQL to retrieve column information for the specified table.
    async describeTable(tableName) {
      if (!this.currentConfig) {
        throw new Error('Not connected to any database. Call connect_database first.');
      }
    
      if (this.currentConfig.type === 'postgresql') {
        if (!this.postgresPool) {
          throw new Error('PostgreSQL connection not initialized');
        }
    
        const query = `
          SELECT 
            column_name,
            data_type,
            is_nullable,
            column_default
          FROM information_schema.columns
          WHERE table_schema = 'public' AND table_name = $1
          ORDER BY ordinal_position;
        `;
        const result = await this.postgresPool.query(query, [tableName]);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  table: tableName,
                  columns: result.rows,
                },
                null,
                2
              ),
            },
          ],
        };
      } else if (this.currentConfig.type === 'mysql') {
        if (!this.mysqlConnection) {
          throw new Error('MySQL connection not initialized');
        }
    
        const [rows] = await this.mysqlConnection.query(
          `DESCRIBE ${tableName}`
        );
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  table: tableName,
                  columns: rows,
                },
                null,
                2
              ),
            },
          ],
        };
      } else {
        throw new Error(`Unsupported database type: ${this.currentConfig.type}`);
      }
    }
  • The input schema definition for the 'describe_table' tool, specifying that it requires a 'tableName' string parameter.
    inputSchema: {
      type: 'object',
      properties: {
        tableName: {
          type: 'string',
          description: 'Name of the table to describe',
        },
      },
      required: ['tableName'],
    },
  • index.js:183-196 (registration)
    The registration of the 'describe_table' tool in the ListTools response, including name, description, and input schema.
    {
      name: 'describe_table',
      description: 'Get schema information for a specific table',
      inputSchema: {
        type: 'object',
        properties: {
          tableName: {
            type: 'string',
            description: 'Name of the table to describe',
          },
        },
        required: ['tableName'],
      },
    },
  • The dispatch case in the CallToolRequestSchema handler that invokes the describeTable method for the 'describe_table' tool.
    case 'describe_table':
      return await this.describeTable(args.tableName);
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 schema information, which implies a read-only operation, but doesn't specify details like whether it requires authentication, returns error messages for invalid tables, or provides metadata format (e.g., column types, constraints). For a tool with zero annotation coverage, this leaves significant gaps in understanding its 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, clear sentence that efficiently conveys the core purpose without unnecessary words. It is front-loaded with the key action ('Get schema information'), making it easy to parse. Every part of the sentence earns its place by specifying the resource and scope.

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 low complexity (1 parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on usage context, behavioral traits, and output format. Without annotations or an output schema, the description should ideally provide more context about what 'schema information' includes, but it meets the minimum for a simple read operation.

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 single parameter 'tableName' fully documented in the schema. The description adds no additional parameter details beyond what the schema provides (e.g., examples of table names, format requirements). Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 schema information') and target resource ('for a specific table'), making the purpose immediately understandable. It distinguishes from siblings like 'list_tables' (which lists tables) and 'execute_query' (which runs queries), though it doesn't explicitly mention this differentiation. The description avoids tautology by not just restating the name 'describe_table'.

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 prerequisites (e.g., needing a connected database via 'connect_database'), exclusions (e.g., not for querying data), or comparisons to siblings like 'list_tables' (for table names) or 'execute_query' (for data retrieval). Usage is implied from the purpose but not explicitly stated.

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/TranChiHuu/postgres-mysql-mcp-server'

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