Skip to main content
Glama
KannaKim

PostgreSQL MCP Server

by KannaKim

list_tables

Retrieve the names of all tables in the current PostgreSQL database. This provides an overview of the database schema for exploration and analysis.

Instructions

List all tables in the current database schema

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:14-53 (registration)
    The @app.list_tools() decorator registers 'list_tables' as one of the available tools, specifying its name, description, and input schema (no parameters required).
    @app.list_tools()
    async def list_tools() -> list[Tool]:
        return [
            Tool(
                name="list_tables",
                description="List all tables in the current database schema",
                inputSchema={
                    "type": "object",
                    "properties": {},
                }
            ),
            Tool(
                name="get_schema",
                description="Get the schema (columns, types) of a specific table",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "table_name": {
                            "type": "string",
                            "description": "Name of the table"
                        }
                    },
                    "required": ["table_name"]
                }
            ),
            Tool(
                name="run_query",
                description="Run a read-only SQL query against the database. ONLY SELECT queries are allowed for safety.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "query": {
                            "type": "string",
                            "description": "The read-only SQL query to execute"
                        }
                    },
                    "required": ["query"]
                }
            )
        ]
  • main.py:17-23 (schema)
    The input schema for 'list_tables' defines an empty object with no required properties (this tool takes no arguments).
    Tool(
        name="list_tables",
        description="List all tables in the current database schema",
        inputSchema={
            "type": "object",
            "properties": {},
        }
  • main.py:60-71 (handler)
    The handler for 'list_tables' queries information_schema.tables for all BASE TABLE entries in the 'public' schema, returning a formatted list of table names.
    if name == "list_tables":
        async with pool.acquire() as conn:
            records = await conn.fetch("""
                SELECT table_name 
                FROM information_schema.tables 
                WHERE table_schema = 'public' 
                  AND table_type = 'BASE TABLE'
            """)
            tables = [record["table_name"] for record in records]
            if not tables:
                return [TextContent(type="text", text="No tables found in public schema.")]
            return [TextContent(type="text", text=f"Tables in public schema:\n" + "\n".join(f"- {t}" for t in tables))]
Behavior2/5

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

With no annotations, the description carries full burden. It states the basic action but fails to disclose important behaviors such as whether system tables are included, required permissions, or response format. The minimal description limits 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, clear sentence that conveys the core action efficiently. It is front-loaded with the verb and resource, containing no unnecessary words.

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 simplicity (no parameters, no output schema), the description is adequate to understand what it does. However, it lacks information about the output format or any constraints, making it partially complete for effective agent use.

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?

There are no parameters, and schema description coverage is 100%. The description adds minimal context ('current database schema'), which provides scope but does not significantly enhance parameter meaning. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (List) and the resource (tables) with a specific scope ('current database schema'). It differentiates well from siblings: get_schema likely retrieves schema structure, run_query executes queries, while list_tables is focused solely on listing table names.

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 like get_schema or run_query. The description does not mention context, prerequisites, or exclusions, leaving the agent to infer usage.

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/KannaKim/PostgresqlMCPServer'

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