Distributed SQL database
## CockroachDB MCP Server: Distributed SQL Database The **CockroachDB MCP Server** integrates CockroachDB into Google Antigravity, enabling distributed SQL operations with strong consistency, automatic sharding, and geo-partitioning directly from your development environment. ### Why CockroachDB MCP? - **Distributed SQL**: PostgreSQL-compatible distributed database - **Strong Consistency**: Serializable isolation by default - **Automatic Sharding**: Data distributed automatically across nodes - **Geo-Partitioning**: Pin data to specific regions for compliance - **Survivability**: Survive node, zone, and region failures ### Key Features #### 1. SQL Queries ```python # Execute SQL query result = await mcp.query(""" SELECT id, email, region, created_at FROM users WHERE region = $1 AND status = $2 ORDER BY created_at DESC LIMIT 100 """, params=["us-east", "active"]) for row in result["rows"]: print(f"User: {row['email']} ({row['region']})") ``` #### 2. Transaction Operations ```python # Execute transaction await mcp.transaction([ { "query": "UPDATE accounts SET balance = balance - $1 WHERE id = $2", "params": [100, "acc_sender"] }, { "query": "UPDATE accounts SET balance = balance + $1 WHERE id = $2", "params": [100, "acc_receiver"] }, { "query": "INSERT INTO transfers (from_id, to_id, amount) VALUES ($1, $2, $3)", "params": ["acc_sender", "acc_receiver", 100] } ]) ``` #### 3. Schema Management ```python # Create table with regions await mcp.execute(""" CREATE TABLE orders ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), user_id UUID NOT NULL, region STRING NOT NULL, total DECIMAL(10, 2), created_at TIMESTAMPTZ DEFAULT now() ) LOCALITY REGIONAL BY ROW AS region """) # Add index await mcp.execute(""" CREATE INDEX idx_orders_user ON orders (user_id) STORING (total, created_at) """) ``` #### 4. Cluster Operations ```python # Get cluster info info = await mcp.get_cluster_info() print(f"Version: {info['version']}") print(f"Nodes: {len(info['nodes'])}") # Get ranges info ranges = await mcp.get_table_ranges(table="orders") for r in ranges: print(f"Range: {r['range_id']} on {r['node']}") ``` ### Configuration ```json { "mcpServers": { "cockroachdb": { "command": "npx", "args": ["-y", "@anthropic/mcp-cockroachdb"], "env": { "COCKROACH_URL": "postgresql://user:password@host:26257/defaultdb?sslmode=verify-full", "COCKROACH_CLUSTER": "your-cluster-id" } } } } ``` ### Use Cases **Global Applications**: Build globally distributed apps with local latency. **Financial Systems**: ACID transactions for financial operations. **Multi-Region**: Deploy across regions with data locality. **High Availability**: Build systems that survive failures. The CockroachDB MCP enables distributed SQL within your development environment.
{
"mcpServers": {
"cockroachdb": {
"mcpServers": {
"cockroachdb": {
"env": {
"COCKROACH_URL": "postgresql://user:pass@host:26257/db"
},
"args": [
"-y",
"cockroachdb-mcp-server"
],
"command": "npx"
}
}
}
}
}