Skip to main content
Glama
antonorlov

MCP PostgreSQL Server

list_tables

Retrieve a list of database tables to inspect schema structure and identify available data sources for PostgreSQL operations.

Instructions

List tables in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNoSchema name (default: public)

Implementation Reference

  • The handler function for list_tables tool. Ensures database connection, queries information_schema.tables for tables in the given schema (default 'public'), returns table names as JSON, handles errors.
    private async handleListTables(args: any = {}) {
      await this.ensureConnection();
    
      const schema = args.schema || 'public';
    
      try {
        const result = await this.client!.query(`
          SELECT table_name
          FROM information_schema.tables
          WHERE table_schema = $1
          ORDER BY table_name
        `, [schema]);
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result.rows, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to list tables: ${getErrorMessage(error)}`
        );
      }
    }
  • Input schema for list_tables tool, defining an optional 'schema' string parameter.
    inputSchema: {
      type: 'object',
      properties: {
        schema: {
          type: 'string',
          description: 'Schema name (default: public)',
        },
      },
      required: [],
    },
  • src/index.ts:220-233 (registration)
    Registration of the list_tables tool in the ListToolsRequestSchema response, including name, description, and input schema.
    {
      name: 'list_tables',
      description: 'List tables in the database',
      inputSchema: {
        type: 'object',
        properties: {
          schema: {
            type: 'string',
            description: 'Schema name (default: public)',
          },
        },
        required: [],
      },
    },
  • src/index.ts:265-266 (registration)
    Routing logic in the CallToolRequestSchema handler that dispatches list_tables calls to the handleListTables method.
    case 'list_tables':
      return await this.handleListTables(request.params.arguments);
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 action ('List') but doesn't describe what 'List' entails—e.g., whether it returns all tables, if there's pagination, what format the output is in, or any permissions required. For a tool with no annotation coverage, this is a significant gap in transparency.

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 is appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration. Every word earns its place, making it highly concise.

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?

Given the tool's simplicity (1 optional parameter, no output schema, no annotations), the description is incomplete. It lacks details on output format, behavioral traits, or usage context, which are necessary for an agent to effectively invoke and interpret results. This is inadequate for even a simple tool.

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 'schema' documented as 'Schema name (default: public)'. The description adds no parameter semantics beyond what the schema provides, so it meets the baseline of 3 where the schema does the heavy lifting. No additional value is contributed.

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 ('List') and resource ('tables in the database'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'list_schemas' or 'describe_table', but the specificity of 'tables' provides some implicit distinction. This is clear but lacks explicit sibling differentiation.

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 to connect to the database first), when to prefer 'list_schemas' or 'describe_table', or any usage constraints. This leaves the agent with minimal context for tool selection.

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

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