Skip to main content
Glama

list_objects

Retrieve tables, views, sequences, or extensions from a PostgreSQL schema to explore database structure and identify available objects.

Instructions

List objects in a schema

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schema_nameYesSchema name
object_typeNoObject type: 'table', 'view', 'sequence', or 'extension'table

Implementation Reference

  • The implementation of the `list_objects` MCP tool, which queries PostgreSQL metadata based on object type (table, view, sequence, or extension).
    async def list_objects(
        schema_name: str = Field(description="Schema name"),
        object_type: str = Field(description="Object type: 'table', 'view', 'sequence', or 'extension'", default="table"),
    ) -> ResponseType:
        """List objects of a given type in a schema."""
        try:
            sql_driver = await get_sql_driver()
    
            if object_type in ("table", "view"):
                table_type = "BASE TABLE" if object_type == "table" else "VIEW"
                rows = await SafeSqlDriver.execute_param_query(
                    sql_driver,
                    """
                    SELECT table_schema, table_name, table_type
                    FROM information_schema.tables
                    WHERE table_schema = {} AND table_type = {}
                    ORDER BY table_name
                    """,
                    [schema_name, table_type],
                )
                objects = (
                    [{"schema": row.cells["table_schema"], "name": row.cells["table_name"], "type": row.cells["table_type"]} for row in rows]
                    if rows
                    else []
                )
    
            elif object_type == "sequence":
                rows = await SafeSqlDriver.execute_param_query(
                    sql_driver,
                    """
                    SELECT sequence_schema, sequence_name, data_type
                    FROM information_schema.sequences
                    WHERE sequence_schema = {}
                    ORDER BY sequence_name
                    """,
                    [schema_name],
                )
                objects = (
                    [{"schema": row.cells["sequence_schema"], "name": row.cells["sequence_name"], "data_type": row.cells["data_type"]} for row in rows]
                    if rows
                    else []
                )
    
            elif object_type == "extension":
                # Extensions are not schema-specific
                rows = await sql_driver.execute_query(
                    """
                    SELECT extname, extversion, extrelocatable
                    FROM pg_extension
                    ORDER BY extname
                    """
                )
                objects = (
                    [{"name": row.cells["extname"], "version": row.cells["extversion"], "relocatable": row.cells["extrelocatable"]} for row in rows]
                    if rows
                    else []
                )
    
            else:
                return format_error_response(f"Unsupported object type: {object_type}")
    
            return format_text_response(objects)
        except Exception as e:
            logger.error(f"Error listing objects: {e}")
            return format_error_response(str(e))
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but reveals nothing about read-only safety, return value structure, pagination behavior, or error handling (e.g., invalid schema names). The description does not clarify what constitutes an 'object' in this context beyond the schema's default of 'table'.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely efficient at four words with no redundancy. However, given the complete absence of annotations and output schema, the description may be overly terse—trading necessary behavioral context for brevity.

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?

Adequate for a simple 2-parameter listing tool with complete schema coverage, but lacks contextual safeguards given no annotations. Missing differentiation from similar sibling tools and behavioral expectations given the 'analyze_' and 'execute_' siblings suggest this is a database introspection tool where safety guidance would be valuable.

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?

Input schema has 100% description coverage, with 'object_type' already enumerating valid values ('table', 'view', 'sequence', 'extension'). The description adds no semantic clarification beyond the schema, meeting the baseline for high-coverage schemas.

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 uses a clear verb ('List') with specific resource ('objects') and scope ('in a schema'), making the basic purpose understandable. However, it fails to differentiate from sibling tools like 'list_schemas' (which lists schemas rather than objects within them) or 'get_object_details' (which retrieves specific object metadata).

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 provided on when to use this tool versus alternatives like 'get_object_details' for single-object lookups or 'list_schemas' for schema enumeration. No mention of prerequisite steps (e.g., verifying schema exists) or when to prefer filtering by specific object types.

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/moecodeshere/mcptrial'

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