Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

cluster_status

Check CockroachDB cluster health status to monitor node availability and count for operational oversight.

Instructions

Get the health status of the CockroachDB cluster.

Returns: Cluster health including node count and live nodes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'cluster_status' that delegates to cluster.cluster_health() with error handling.
    @mcp.tool() async def cluster_status() -> dict[str, Any]: """Get the health status of the CockroachDB cluster. Returns: Cluster health including node count and live nodes. """ try: return await cluster.cluster_health() except Exception as e: return {"status": "error", "error": str(e)}
  • Core helper function implementing cluster health status by querying organization, version, total nodes, live nodes, and determining overall health.
    async def cluster_health() -> dict[str, Any]: """Get the health status of the CockroachDB cluster. Returns: Cluster health information. """ conn = await connection_manager.ensure_connected() try: result: dict[str, Any] = {"status": "healthy"} async with conn.cursor() as cur: # Get cluster settings await cur.execute("SHOW CLUSTER SETTING cluster.organization") org_row = await cur.fetchone() result["organization"] = org_row.get("cluster.organization") if org_row else None # Get version await cur.execute("SELECT version()") version_row = await cur.fetchone() result["version"] = version_row.get("version") if version_row else None # Get node count await cur.execute("SELECT count(*) as node_count FROM crdb_internal.gossip_nodes") node_row = await cur.fetchone() result["node_count"] = node_row.get("node_count") if node_row else 0 # Get live node count await cur.execute(""" SELECT count(*) as live_nodes FROM crdb_internal.gossip_nodes WHERE is_live = true """) live_row = await cur.fetchone() result["live_nodes"] = live_row.get("live_nodes") if live_row else 0 # Check if cluster is healthy if result["live_nodes"] < result["node_count"]: result["status"] = "degraded" result["message"] = ( f"{result['node_count'] - result['live_nodes']} node(s) are not live" ) return result 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