Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

list_databases

Retrieve all databases in a CockroachDB cluster, with options to include or exclude system databases for comprehensive schema discovery.

Instructions

List all databases in the cluster.

Args:
    include_system: Include system databases (postgres, defaultdb, etc.).

Returns:
    List of databases.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_systemNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that executes the 'SHOW DATABASES' query, filters out blocked and system databases (unless specified), and returns a structured list of databases.
    async def list_databases(include_system: bool = False) -> dict[str, Any]:
        """List all databases in the cluster.
    
        Args:
            include_system: Include system databases.
    
        Returns:
            List of databases.
        """
        conn = await connection_manager.ensure_connected()
    
        try:
            async with conn.cursor() as cur:
                await cur.execute("SHOW DATABASES")
                rows = await cur.fetchall()
    
            databases = []
            system_dbs = {"system", "postgres", "defaultdb", "crdb_internal"}
    
            for row in rows:
                db_name = row.get("database_name", "")
    
                # Skip blocked databases
                if _is_blocked_database(db_name):
                    continue
    
                # Skip system databases unless requested
                is_system = db_name in system_dbs
                if is_system and not include_system:
                    continue
    
                databases.append(
                    {
                        "name": db_name,
                        "is_system": is_system,
                    }
                )
    
            return {
                "databases": databases,
                "count": len(databases),
                "current_database": connection_manager.current_database,
            }
        except Exception as e:
            return {"status": "error", "error": str(e)}
  • MCP tool registration using @mcp.tool() decorator. This wrapper function handles the tool invocation, delegates to the core implementation in tables.py, and provides error handling.
    @mcp.tool()
    async def list_databases(include_system: bool = False) -> dict[str, Any]:
        """List all databases in the cluster.
    
        Args:
            include_system: Include system databases (postgres, defaultdb, etc.).
    
        Returns:
            List of databases.
        """
        try:
            return await tables.list_databases(include_system)
        except Exception as e:
            return {"status": "error", "error": str(e)}
  • Helper function used by list_databases to filter out blocked databases based on configuration.
    def _is_blocked_database(db_name: str) -> bool:
        """Check if a database is blocked."""
        return db_name in settings.blocked_databases_list
Behavior3/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 describes the core functionality (listing databases) and includes a parameter explanation, but doesn't mention important behavioral aspects like whether this requires specific permissions, how results are formatted, pagination behavior, or potential rate limits. The description provides basic operational context but lacks comprehensive behavioral details.

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 perfectly structured with a clear purpose statement followed by organized sections for Args and Returns. Every sentence serves a purpose with zero redundancy, and the information is front-loaded with the most important statement first. The formatting makes it easy to scan and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (single boolean parameter) and the presence of an output schema (which handles return value documentation), the description provides adequate context. It covers the purpose, parameter meaning, and return type at a high level. The main gap is the lack of behavioral details that would be important for a cluster administration tool, but the output schema reduces the need for extensive return value explanation.

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

Parameters4/5

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

The description adds meaningful semantic context for the single parameter 'include_system' by explaining what it does and providing examples (postgres, defaultdb). With 0% schema description coverage and only one parameter, this description effectively compensates for the schema's lack of parameter documentation, though it doesn't cover edge cases or provide format details.

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 specific action ('List all databases') and resource ('in the cluster'), using a precise verb+resource combination. It distinguishes itself from sibling tools like list_nodes, list_schemas, and list_tables by focusing specifically on databases rather than other cluster components.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through the parameter explanation (including system databases), but doesn't explicitly state when to use this tool versus alternatives like list_schemas or list_tables. There's no guidance about prerequisites, timing, or specific scenarios where this tool is preferred over other listing tools.

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/bpamiri/cockroachdb-mcp'

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