Skip to main content
Glama
MadeByNando

MCP Postgres Server

by MadeByNando

list_tables

Retrieve all tables within a specified schema on a PostgreSQL database using the Model Context Protocol (MCP) for secure and efficient database exploration.

Instructions

List all tables in a schema

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNo

Implementation Reference

  • The handler function that lists all tables in the public schema by querying information_schema.tables and returns a JSON array of table names.
    async () => {
      try {
        debugLog("Listing database tables");
        
        return await executeDbQuery(async (client) => {
          const result = await withTimeout(
            client.query(
              "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"
            ),
            API_TIMEOUT_MS,
            "Listing database tables"
          ) as pg.QueryResult;
          
          debugLog(`Found ${result.rows.length} tables`);
          
          const tableList = result.rows.map((row: { table_name: string }) => row.table_name);
          
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(tableList, null, 2),
              },
            ],
          };
        }, "Failed to list database tables");
      } catch (error) {
        handleError(error, "Failed to list database tables");
        throw error;
      }
    }
  • index.ts:215-249 (registration)
    Registration of the postgres_list_tables tool on the MCP server, including empty input schema and inline handler.
    server.tool(
      "postgres_list_tables",
      {},
      async () => {
        try {
          debugLog("Listing database tables");
          
          return await executeDbQuery(async (client) => {
            const result = await withTimeout(
              client.query(
                "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"
              ),
              API_TIMEOUT_MS,
              "Listing database tables"
            ) as pg.QueryResult;
            
            debugLog(`Found ${result.rows.length} tables`);
            
            const tableList = result.rows.map((row: { table_name: string }) => row.table_name);
            
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(tableList, null, 2),
                },
              ],
            };
          }, "Failed to list database tables");
        } catch (error) {
          handleError(error, "Failed to list database tables");
          throw error;
        }
      }
    );
  • Input/output schema declaration for the tool in the MCP server capabilities. No parameters required.
    postgres_list_tables: {
      description: "List all tables in the PostgreSQL database",
      parameters: {},
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It lacks details on permissions required, output format (e.g., list structure, pagination), error handling, or whether it's read-only (implied but not confirmed). This leaves significant behavioral gaps.

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 wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly.

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 parameter, no output schema, no annotations), the description is minimal but inadequate. It doesn't cover parameter meaning, behavioral traits, or usage context, leaving the agent with insufficient information to use the tool effectively beyond its basic purpose.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description doesn't mention the 'schema' parameter at all. It fails to explain what 'schema' means in this context (e.g., database schema name) or provide any semantic details beyond what the bare schema implies, leaving the parameter undocumented.

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 a schema'), making the purpose unambiguous. However, it doesn't differentiate from siblings like 'list_schemas' or 'list_views' beyond the resource type, which slightly limits its specificity.

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 like 'list_schemas' or 'describe_table', nor does it mention prerequisites such as needing a valid schema name. Usage context is implied but not explicit.

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

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

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