Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

show_sessions

View active database sessions in a CockroachDB cluster to monitor current queries and connections for performance analysis and troubleshooting.

Instructions

Show active sessions in the cluster.

Args:
    active_only: Only show sessions with active queries.

Returns:
    List of sessions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
active_onlyNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'show_sessions'. Registered with @mcp.tool() decorator and delegates execution to the cluster helper function.
    @mcp.tool()
    async def show_sessions(active_only: bool = True) -> dict[str, Any]:
        """Show active sessions in the cluster.
    
        Args:
            active_only: Only show sessions with active queries.
    
        Returns:
            List of sessions.
        """
        try:
            return await cluster.show_sessions(active_only)
        except Exception as e:
            return {"status": "error", "error": str(e)}
  • Underlying helper function that executes the SQL query against crdb_internal.cluster_sessions to retrieve and format session information.
    async def show_sessions(active_only: bool = True) -> dict[str, Any]:
        """Show active sessions in the cluster.
    
        Args:
            active_only: Only show active sessions.
    
        Returns:
            List of sessions.
        """
        conn = await connection_manager.ensure_connected()
    
        try:
            query = """
                SELECT
                    session_id,
                    node_id,
                    user_name,
                    client_address,
                    application_name,
                    active_queries,
                    start
                FROM crdb_internal.cluster_sessions
            """
    
            if active_only:
                query += " WHERE active_queries != '{}'"
    
            query += " ORDER BY start DESC"
    
            async with conn.cursor() as cur:
                await cur.execute(query)
                rows = await cur.fetchall()
    
            sessions = []
            for row in rows:
                sessions.append(
                    {
                        "session_id": row.get("session_id"),
                        "node_id": row.get("node_id"),
                        "user": row.get("user_name"),
                        "client_address": row.get("client_address"),
                        "application": row.get("application_name"),
                        "active_queries": row.get("active_queries"),
                        "started": str(row.get("start")) if row.get("start") else None,
                    }
                )
    
            return {"sessions": sessions, "count": len(sessions)}
        except Exception as e:
            return {"status": "error", "error": str(e)}
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool returns ('List of sessions') but doesn't describe session attributes, format, pagination, permissions required, rate limits, or whether this is a read-only operation. For a monitoring tool with zero annotation coverage, this leaves significant behavioral gaps.

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 efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence earns its place - the purpose statement establishes context, the parameter documentation is essential, and the return statement is necessary given the output schema's existence but unknown content.

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 with filtering), no annotations, and an output schema (though unknown content), the description is minimally adequate. It covers purpose and parameter semantics but lacks behavioral context, usage guidance, and details about the returned session data structure that would be helpful for an 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 explicitly documents the single parameter's purpose: 'active_only: Only show sessions with active queries.' With 0% schema description coverage, this adds crucial semantic meaning beyond the schema's basic boolean type. However, it doesn't explain default behavior or what constitutes 'active queries' in this context.

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 tool's purpose: 'Show active sessions in the cluster' - a specific verb ('show') and resource ('active sessions') with context ('in the cluster'). It doesn't explicitly differentiate from siblings like 'show_jobs' or 'show_statements', but the resource specificity provides reasonable distinction.

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 on when to use this tool versus alternatives is provided. While the description implies monitoring/management context, it doesn't specify use cases, prerequisites, or comparisons to related tools like 'show_jobs' or 'show_statements' that might show different system activities.

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