Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

show_ranges

Display range distribution across a CockroachDB cluster to analyze data partitioning and storage layout, with optional table filtering for targeted insights.

Instructions

Show range distribution in the cluster.

Args:
    table: Optional table to filter ranges.
    limit: Maximum ranges to return.

Returns:
    Range distribution information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that executes the show_ranges tool logic by querying CockroachDB's crdb_internal.ranges_no_leases table for range distribution information.
    async def show_ranges(table: str | None = None, limit: int = 50) -> dict[str, Any]:
        """Show range distribution in the cluster.
    
        Args:
            table: Optional table to filter ranges.
            limit: Maximum ranges to return.
    
        Returns:
            Range distribution information.
        """
        conn = await connection_manager.ensure_connected()
    
        try:
            if table:
                # Parse table name (schema ignored - CockroachDB ranges use just table_name)
                if "." in table:
                    _schema, table_name = table.rsplit(".", 1)
                else:
                    table_name = table
    
                query = f"""
                    SELECT
                        range_id,
                        start_pretty,
                        end_pretty,
                        lease_holder,
                        replicas,
                        range_size_mb
                    FROM crdb_internal.ranges_no_leases
                    WHERE table_name = '{table_name}'
                    LIMIT {limit}
                """
            else:
                query = f"""
                    SELECT
                        range_id,
                        database_name,
                        table_name,
                        start_pretty,
                        end_pretty,
                        lease_holder,
                        replicas,
                        range_size_mb
                    FROM crdb_internal.ranges_no_leases
                    LIMIT {limit}
                """
    
            async with conn.cursor() as cur:
                await cur.execute(query)
                rows = await cur.fetchall()
    
            ranges = []
            for row in rows:
                range_info: dict[str, Any] = {
                    "range_id": row.get("range_id"),
                    "start": row.get("start_pretty"),
                    "end": row.get("end_pretty"),
                    "lease_holder": row.get("lease_holder"),
                    "replicas": row.get("replicas"),
                    "size_mb": row.get("range_size_mb"),
                }
                if not table:
                    range_info["database"] = row.get("database_name")
                    range_info["table"] = row.get("table_name")
                ranges.append(range_info)
    
            return {"ranges": ranges, "count": len(ranges), "table_filter": table}
        except Exception as e:
            return {"status": "error", "error": str(e)}
  • Registration of the show_ranges tool via @mcp.tool() decorator. This thin wrapper delegates execution to the core handler in cluster.py.
    @mcp.tool()
    async def show_ranges(table: str | None = None, limit: int = 50) -> dict[str, Any]:
        """Show range distribution in the cluster.
    
        Args:
            table: Optional table to filter ranges.
            limit: Maximum ranges to return.
    
        Returns:
            Range distribution information.
        """
        try:
            return await cluster.show_ranges(table, limit)
        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?

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'Show' implies a read-only operation, the description doesn't clarify whether this requires specific permissions, has performance implications, or provides real-time versus cached data. It mentions returning 'Range distribution information' but doesn't describe format, pagination, or potential limitations. For a cluster diagnostic tool with zero annotation coverage, this is insufficient.

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?

The description is efficiently structured with a purpose statement followed by Args and Returns sections. Each sentence serves a clear purpose: the first states the tool's function, the second documents parameters, and the third describes the return. There's no wasted text, though the parameter explanations could be slightly more detailed without sacrificing conciseness.

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 that there's an output schema (which should document return values), the description doesn't need to explain returns in detail. However, for a cluster diagnostic tool with no annotations and 2 parameters, the description should provide more context about what 'range distribution' means and when to use it versus siblings. It's minimally adequate but leaves significant gaps in behavioral and usage context.

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?

Schema description coverage is 0%, so the schema provides no parameter documentation. The description compensates by listing both parameters ('table' and 'limit') with brief explanations, adding meaningful context beyond the bare schema. However, it doesn't explain what 'table' filtering entails or what 'range distribution information' includes, leaving some semantic gaps. This meets the baseline for partial compensation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Show range distribution in the cluster', which provides a clear verb ('Show') and resource ('range distribution'), but it's somewhat vague about what 'range distribution' entails. It doesn't distinguish this tool from siblings like 'cluster_status' or 'show_zone_config' that might also provide cluster-level information. The purpose is understandable but lacks specificity about what makes this tool unique.

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. With siblings like 'cluster_status', 'node_status', and 'show_zone_config' that might offer related cluster insights, there's no indication of when this specific range distribution tool is appropriate. The lack of context or exclusions leaves the agent without usage direction.

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