Skip to main content
Glama
sbfulfil

PostgreSQL MCP Server

by sbfulfil

describe_table

Retrieve detailed schema information for PostgreSQL tables to understand column definitions, data types, and table structure for database exploration and analysis.

Instructions

Get detailed schema information for a specific table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYesName of the table to describe
schemaNoSchema name (default: public)public

Implementation Reference

  • The core handler function that implements the describe_table tool. It queries the PostgreSQL information_schema.columns for column details of the specified table and schema, formats them into a readable text table, and returns as MCP content.
    async describeTable(tableName, schema = 'public') {
      const client = await this.connectToDatabase();
      
      try {
        const query = `
          SELECT 
            column_name,
            data_type,
            is_nullable,
            column_default,
            character_maximum_length,
            numeric_precision,
            numeric_scale,
            ordinal_position
          FROM information_schema.columns 
          WHERE table_schema = $1 AND table_name = $2
          ORDER BY ordinal_position;
        `;
        
        const result = await client.query(query, [schema, tableName]);
        
        if (result.rows.length === 0) {
          throw new Error(`Table "${tableName}" not found in schema "${schema}"`);
        }
    
        const tableInfo = result.rows.map(row => ({
          column: row.column_name,
          type: row.data_type,
          nullable: row.is_nullable === 'YES',
          default: row.column_default,
          maxLength: row.character_maximum_length,
          precision: row.numeric_precision,
          scale: row.numeric_scale,
          position: row.ordinal_position
        }));
    
        return {
          content: [
            {
              type: 'text',
              text: `Schema for table "${schema}.${tableName}":\n\n` + 
                    tableInfo.map(col => 
                      `${col.column} | ${col.type}${col.maxLength ? `(${col.maxLength})` : ''}${col.precision ? `(${col.precision}${col.scale ? `,${col.scale}` : ''})` : ''} | ${col.nullable ? 'NULL' : 'NOT NULL'}${col.default ? ` | DEFAULT ${col.default}` : ''}`
                    ).join('\n'),
            },
          ],
        };
      } finally {
        await client.end();
      }
    }
  • Input schema for the describe_table tool, defining parameters table_name (required, string) and schema (optional string, defaults to 'public').
    inputSchema: {
      type: 'object',
      properties: {
        table_name: {
          type: 'string',
          description: 'Name of the table to describe',
        },
        schema: {
          type: 'string',
          description: 'Schema name (default: public)',
          default: 'public'
        }
      },
      required: ['table_name'],
    },
  • src/index.js:71-89 (registration)
    Registration of the describe_table tool in the ListToolsRequestSchema response, including name, description, and input schema.
    {
      name: 'describe_table',
      description: 'Get detailed schema information for a specific table',
      inputSchema: {
        type: 'object',
        properties: {
          table_name: {
            type: 'string',
            description: 'Name of the table to describe',
          },
          schema: {
            type: 'string',
            description: 'Schema name (default: public)',
            default: 'public'
          }
        },
        required: ['table_name'],
      },
    },
  • src/index.js:148-149 (registration)
    Dispatch registration in the CallToolRequestSchema switch statement, mapping tool calls to the describeTable handler.
    case 'describe_table':
      return await this.describeTable(args.table_name, args?.schema || 'public');
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. It states this is a read operation ('Get'), but doesn't disclose behavioral traits like error handling, permissions needed, rate limits, or what 'detailed schema information' includes. For a tool with no annotations, this leaves significant gaps in understanding how it behaves.

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's front-loaded with the core purpose and appropriately sized for the tool's complexity. Every word contributes to understanding the tool's function.

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 no annotations and no output schema, the description is minimal but adequate for a simple read tool. It covers the basic purpose but lacks details on behavior, output format, or sibling differentiation. For a tool with 2 parameters and 100% schema coverage, it meets the minimum viable threshold but has clear gaps in context.

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%, so the schema fully documents both parameters. The description adds no additional meaning beyond what's in the schema, such as examples or constraints. With high schema coverage, 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 verb 'Get' and resource 'detailed schema information for a specific table', making the purpose unambiguous. It doesn't explicitly differentiate from siblings like 'get_indexes' or 'list_tables', but the specificity of 'detailed schema information' implies a distinction from listing operations.

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. The description doesn't mention siblings like 'get_indexes' or 'list_tables', nor does it specify prerequisites or exclusions. Usage is implied by 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/sbfulfil/pg-mcp'

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