Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

show_statements

View active SQL statements running in a CockroachDB cluster to monitor current database operations and identify performance issues.

Instructions

Show active statements in the cluster.

Args:
    limit: Maximum statements to return.

Returns:
    List of active statements.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'show_statements'. Registered via @mcp.tool() decorator. Thin wrapper that calls the underlying cluster.show_statements() and handles exceptions.
    @mcp.tool()
    async def show_statements(limit: int = 20) -> dict[str, Any]:
        """Show active statements in the cluster.
    
        Args:
            limit: Maximum statements to return.
    
        Returns:
            List of active statements.
        """
        try:
            return await cluster.show_statements(limit)
        except Exception as e:
            return {"status": "error", "error": str(e)}
  • Core helper function implementing the logic to show active statements. Connects to DB, queries crdb_internal.cluster_queries, processes results into structured dict.
    async def show_statements(limit: int = 20) -> dict[str, Any]:
        """Show active statements in the cluster.
    
        Args:
            limit: Maximum statements to return.
    
        Returns:
            List of active statements.
        """
        conn = await connection_manager.ensure_connected()
    
        try:
            async with conn.cursor() as cur:
                await cur.execute(f"""
                    SELECT
                        query_id,
                        node_id,
                        user_name,
                        query,
                        start,
                        phase,
                        application_name
                    FROM crdb_internal.cluster_queries
                    ORDER BY start DESC
                    LIMIT {limit}
                """)
                rows = await cur.fetchall()
    
            statements = []
            for row in rows:
                statements.append(
                    {
                        "query_id": row.get("query_id"),
                        "node_id": row.get("node_id"),
                        "user": row.get("user_name"),
                        "query": row.get("query"),
                        "started": str(row.get("start")) if row.get("start") else None,
                        "phase": row.get("phase"),
                        "application": row.get("application_name"),
                    }
                )
    
            return {"statements": statements, "count": len(statements)}
        except Exception as e:
            return {"status": "error", "error": str(e)}
  • The @mcp.tool() decorator registers the show_statements function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations, the description carries full burden but provides minimal behavioral insight. It states 'show active statements' implying read-only, but doesn't disclose permissions needed, rate limits, what 'active' means (e.g., running queries), or how results are formatted beyond 'list'. This is inadequate for a tool with potential complexity.

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 front-loaded with the core purpose in the first sentence, followed by structured Args and Returns sections. Every sentence earns its place with no wasted words, making it highly efficient and easy to parse.

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 moderate complexity (monitoring active statements in a cluster), no annotations, and an output schema present (which handles return values), the description is minimally adequate. It covers purpose and parameters but lacks behavioral details like what 'active' entails or usage context, leaving gaps for an AI agent.

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 context for the single parameter 'limit' by explaining it as 'Maximum statements to return', which clarifies its purpose beyond the schema's basic type and default. With 0% schema description coverage and only one parameter, this compensates well, though it could specify units or constraints.

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 'show' and resource 'active statements in the cluster', making the purpose evident. It distinguishes from siblings like show_jobs, show_sessions, and show_ranges by specifying 'statements', but doesn't explicitly differentiate from all siblings like show_zone_config or show_regions.

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. The description doesn't mention prerequisites, context (e.g., during monitoring or debugging), or comparisons to siblings like show_sessions or show_jobs, leaving usage unclear.

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