Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

show_regions

Retrieve database region information for multi-region CockroachDB clusters to understand data distribution and availability across geographic locations.

Instructions

Show database regions for multi-region clusters.

Returns: Region information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that executes the logic to show regions by querying crdb_internal.databases and SHOW REGIONS
    async def show_regions() -> dict[str, Any]: """Show database regions for multi-region clusters. Returns: Region information. """ conn = await connection_manager.ensure_connected() try: async with conn.cursor() as cur: # Get database regions await cur.execute(""" SELECT database_name, primary_region, secondary_region, regions, survival_goal FROM crdb_internal.databases WHERE database_name = current_database() """) db_row = await cur.fetchone() if not db_row: return { "status": "success", "database": connection_manager.current_database, "is_multi_region": False, "message": "Database is not configured for multi-region", } # Get all regions in the cluster await cur.execute("SHOW REGIONS") region_rows = await cur.fetchall() regions = [row.get("region") for row in region_rows if row.get("region")] return { "status": "success", "database": db_row.get("database_name"), "primary_region": db_row.get("primary_region"), "secondary_region": db_row.get("secondary_region"), "regions": db_row.get("regions"), "survival_goal": db_row.get("survival_goal"), "cluster_regions": regions, "is_multi_region": bool(db_row.get("primary_region")), } except Exception as e: # Multi-region may not be enabled if "unknown function" in str(e).lower() or "regions" in str(e).lower(): return { "status": "success", "is_multi_region": False, "message": "Multi-region is not enabled for this cluster", } return {"status": "error", "error": str(e)}
  • MCP tool registration using @mcp.tool() decorator, which delegates to the core implementation in cluster.show_regions()
    @mcp.tool() async def show_regions() -> dict[str, Any]: """Show database regions for multi-region clusters. Returns: Region information. """ try: return await cluster.show_regions() except Exception as e: return {"status": "error", "error": str(e)}

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