Navigation
CockroachDB MCP Server: Real-Time Mirroring & Zero-Downtime Resilience - MCP Implementation

CockroachDB MCP Server: Real-Time Mirroring & Zero-Downtime Resilience

CockroachDB MCP Server ensures rock-solid reliability with real-time mirrored replication, powering mission-critical apps through seamless scale and zero-downtime resilience.

Developer Tools
4.1(83 reviews)
124 saves
58 comments

Users create an average of 35 projects per month with this tool

About CockroachDB MCP Server

What is CockroachDB MCP Server: Real-Time Mirroring & Zero-Downtime Resilience?

CockroachDB MCP Server acts as an interface to interact with CockroachDB instances, enabling real-time access to database schemas, table structures, and cluster metadata. It supports executing SQL queries with execution plan analysis while maintaining zero-downtime resilience through seamless failover and data mirroring. This server exposes resources via standardized endpoints and integrates with tools like Claude for Desktop and Cline for streamlined database management.

How to use CockroachDB MCP Server: Real-Time Mirroring & Zero-Downtime Resilience?

Deployment involves three core steps: cloning the repository, installing dependencies with pnpm install, and building with npx tsc. Configuration requires specifying a database URL and optionally an auth token for secure access to cluster metadata. Integration with third-party tools like Claude for Desktop or Cline mandates updating their configuration files with server paths, credentials, and authentication parameters. Restarting the tool after configuration ensures the server is recognized and operational.

CockroachDB MCP Server Features

Key Features of CockroachDB MCP Server: Real-Time Mirroring & Zero-Downtime Resilience?

  • Schema Accessibility: Retrieve database and table schemas via endpoints like postgres://{host}/databases/{database}/tables/{table}/schema.
  • Query Execution & Analysis: Run SQL queries with detailed execution plan insights to optimize performance.
  • Cluster Metadata Access: Fetch node information and other metadata using auth-protected endpoints.
  • Seamless Integration: Native support for tools like Cline and Claude for Desktop through standardized JSON configurations.

Use cases of CockroachDB MCP Server: Real-Time Mirroring & Zero-Downtime Resilience?

Primary use cases include:

  • Automating database schema discovery and validation in CI/CD pipelines.
  • Debugging slow queries and analyzing execution plans for performance tuning.
  • Monitoring cluster health and node status in real time via metadata endpoints.
  • Enabling developers to test database interactions within IDEs or chat applications like Claude.

CockroachDB MCP Server FAQ

FAQ from CockroachDB MCP Server: Real-Time Mirroring & Zero-Downtime Resilience?

  • Q: How do I resolve connection issues?
    Verify database credentials, network accessibility, and ensure the CockroachDB instance is reachable on the specified port.
  • Q: What is the auth token used for?
    Auth tokens secure access to sensitive cluster metadata endpoints and admin UI integrations.
  • Q: Can I use a read-only user?
    Yes, restrict access by configuring a read-only database user if query execution isn’t required.
  • Q: Why isn’t my tool detecting the server?
    Check configuration file syntax, server.js path validity, and ensure the server is running before tool restart.

Content

CockroachDB MCP Server

This MCP server connects to a CockroachDB instance, exposing database and table schemas as resources, running SQL queries as tools, and providing prompts for query analysis.

Features

Resources

  • postgres://{host}/databases/{database} - Get information about a specific database
  • postgres://{host}/databases/{database}/tables/{table}/schema - Get the schema for a specific table
  • postgres://{host}/cluster-metadata/{resource} - Get cluster metadata (requires auth token)
    • Currently supports: nodes - Information about cluster nodes

Tools

  • query - Execute a SQL query with options for execution plan analysis

Installation

  1. Clone this repository

  2. Install dependencies:

    pnpm install

  3. Build the project:

    npx tsc

Note: You must build the project with tsc before using the MCP server locally.

Configuration

The server requires a database URL as a command-line argument and optionally accepts an auth token for accessing admin UI endpoints:

node dist/server.js postgres://user:password@host:port/database [auth_token]

The auth token is required for accessing cluster metadata resources.

Using with Claude for Desktop

  1. Open your Claude for Desktop App configuration:
* macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
* Windows: `%APPDATA%\Claude\claude_desktop_config.json`
  1. Add your server configuration:
{
  "mcpServers": {
    "cockroachdb": {
      "command": "node",
      "args": [
        "/path/to/cockroachdb-mcp-server/dist/server.js", 
        "postgres://user:password@host:port/database",
        "your_auth_token"
      ]
    }
  }
}
  1. Restart Claude for Desktop

Using with Cline

  1. Open your Cline configuration file from the extension settings under "MCP Servers". Select "Configure MCP Servers".

  2. Add your server configuration:

{
  "mcpServers": {
    "crdb": {
      "command": "node",
      "args": [
        "/path/to/cockroachdb-mcp-server/dist/server.js",
        "postgres://[[email protected]](/cdn-cgi/l/email-protection):26257/testdb",
        "your_auth_token"
      ]
    }
  }
}
  1. Restart Cline or start a new session

Example Queries

Here are some example queries you can ask Claude:

  1. "What databases are available in my CockroachDB instance?"
  2. "Can you show me the schema for the 'users' table in the 'testdb' database?"
  3. "Run this query on my database: SELECT * FROM users LIMIT 10"
  4. "Debug this query and suggest improvements: SELECT * FROM orders WHERE customer_id = 123"
  5. "Show me information about all nodes in my CockroachDB cluster"

Security Considerations

  • Be careful when configuring database access. Consider using a read-only user for the connection if you only need to query data.
  • The auth token is used to access the CockroachDB admin UI API. Make sure to keep this token secure.

Troubleshooting

  • If you encounter connection issues, verify your database credentials and ensure the CockroachDB instance is accessible from your machine.
  • For SQL errors, check the server logs for detailed error messages.
  • If Claude can't see the server, verify the configuration file is properly formatted and the path to the server.js file is correct.
  • For cluster metadata resources, ensure you've provided a valid auth token and that the admin UI is accessible on port 8080.

Related MCP Servers & Clients