Skip to main content
Glama
smith-nathanh

Oracle MCP Server

list_tables

Retrieve a list of all database tables with metadata. Filter results by schema owner to identify tables and their structure in Oracle Database.

Instructions

List all tables in the database with metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerNoFilter by schema owner (optional)

Implementation Reference

  • Handler logic within handle_call_tool that processes the list_tables tool call: extracts optional 'owner' parameter, calls DatabaseInspector.get_tables(), and returns JSON-formatted list of tables as TextContent.
    elif name == "list_tables":
        owner = arguments.get("owner")
        tables = await self.inspector.get_tables(owner)
    
        return [
            TextContent(
                type="text",
                text=json.dumps({"tables": tables}, indent=2, default=str),
            )
        ]
  • Registration of the 'list_tables' tool in handle_list_tools(), including name, description, and input schema for optional 'owner' filter.
    Tool(
        name="list_tables",
        description="List all tables in the database with metadata",
        inputSchema={
            "type": "object",
            "properties": {
                "owner": {
                    "type": "string",
                    "description": "Filter by schema owner (optional)",
                    "default": None,
                }
            },
        },
    ),
  • Core implementation in DatabaseInspector.get_tables(): executes secure SQL queries against Oracle's ALL_TABLES/USER_TABLES with privilege checks, applies table whitelists, retrieves metadata (owner, name, row count, comments, etc.), and returns formatted list of dicts.
    async def get_tables(self, owner: Optional[str] = None) -> List[Dict[str, Any]]:
        """Get list of tables with metadata"""
        conn = await self.connection_manager.get_connection()
        try:
            cursor = conn.cursor()
    
            # Security: Only show tables the connected user actually owns or has access to
            # This prevents any access to system schemas or unauthorized tables
    
            if owner:
                # When owner is specified, verify the connected user has access
                query = """
                    SELECT 
                        t.owner,
                        t.table_name,
                        t.num_rows,
                        t.last_analyzed,
                        tc.comments as table_comment,
                        t.tablespace_name
                    FROM all_tables t
                    LEFT JOIN all_tab_comments tc ON t.owner = tc.owner AND t.table_name = tc.table_name
                    WHERE t.owner = :owner
                      AND (t.owner = USER OR EXISTS (
                          SELECT 1 FROM all_tab_privs p 
                          WHERE p.table_name = t.table_name 
                            AND p.table_schema = t.owner 
                            AND p.grantee IN (USER, 'PUBLIC')
                      ))
                """
                params = [owner]
            else:
                # Default: Only show tables owned by the current connected user
                # For testuser, this will only show EMPLOYEES, DEPARTMENTS, etc.
                query = """
                    SELECT 
                        USER as owner,
                        t.table_name,
                        t.num_rows,
                        t.last_analyzed,
                        tc.comments as table_comment,
                        t.tablespace_name
                    FROM user_tables t
                    LEFT JOIN user_tab_comments tc ON t.table_name = tc.table_name
                """
                params = []
    
            # Apply whitelist filter if configured
            if TABLE_WHITE_LIST and TABLE_WHITE_LIST != [""]:
                placeholders = ",".join(
                    [f":table_{i}" for i in range(len(TABLE_WHITE_LIST))]
                )
                if owner:
                    # For all_tables query with owner specified
                    query += f" AND t.table_name IN ({placeholders})"
                else:
                    # For user_tables query (no owner)
                    query += f" AND t.table_name IN ({placeholders})"
                params.extend(TABLE_WHITE_LIST)
    
            # Order by clause depends on query type
            if owner:
                query += " ORDER BY t.owner, t.table_name"
            else:
                query += " ORDER BY t.table_name"
    
            cursor.execute(query, params)
    
            tables = []
            for row in cursor:
                tables.append(
                    {
                        "owner": row[0],
                        "table_name": row[1],
                        "num_rows": row[2],
                        "last_analyzed": row[3].isoformat() if row[3] else None,
                        "table_comment": row[4],
                        "tablespace_name": row[5],
                    }
                )
    
            return tables
    
        finally:
            conn.close()
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. It states the tool lists tables with metadata but doesn't describe what metadata is included, whether there are pagination limits, rate limits, or authentication requirements. This leaves significant behavioral gaps for an agent.

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 that directly states the tool's purpose without any wasted words. It's appropriately sized for a simple listing tool and front-loads the essential information.

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?

For a simple listing tool with one optional parameter and no output schema, the description is minimally adequate but lacks depth. It doesn't explain what 'metadata' includes or how results are structured, which would help an agent understand the tool's output despite the absence of an output schema.

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 schema description coverage is 100%, with the single parameter 'owner' clearly documented in the schema as an optional filter by schema owner. The description adds no additional parameter semantics beyond what's in the schema, so the baseline score of 3 is appropriate.

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 ('all tables in the database'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_views' or 'list_procedures' beyond mentioning 'tables' specifically.

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_views' or 'list_procedures'. It mentions metadata but doesn't specify what kind or how it differs from other listing tools, leaving usage context implied rather than 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

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/smith-nathanh/oracle-mcp-server'

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