AI tools with cluster access can execute operations on your behalf. When first connecting an AI tool to CockroachDB, consider starting with a staging cluster to understand the tool’s behavior before granting it access to production data.
Before you begin
- To install with
go installor build from source, ensure that you have Go 1.26 or later. - Ensure that you have a reachable CockroachDB cluster. For a multi-node cluster, connect through a ; for development, you can connect to any node directly. The default port is
26257. - Create a dedicated for the server, and issue for it.
- the user only the privileges that the tools you plan to use need. For example, grant
SELECTon the relevant databases for read-only use. Avoidadminand write privileges unless you plan to enable the .
- the user only the privileges that the tools you plan to use need. For example, grant
Step 1. Install the server
- Mac
- Linux
- Windows
Pre-built binaries are not available for macOS because a CockroachDB parser dependency requires cgo on macOS. Use one of the following options instead.Option 1:
The binary lands in The image runs as
Option 1: go install
$(go env GOPATH)/bin/cockroachdb-mcp-server.Option 2: Build from source
Option 3: Docker
Pull the multi-arch image (linux/amd64, linux/arm64) from Google Artifact Registry:nonroot on a distroless base image. On Apple Silicon, Docker runs the linux/arm64 image natively. This is the only install option on macOS that does not require Go.To configure an MCP client to run the image, refer to the Docker configuration in Step 2.Step 2. Configure your MCP client
Each server instance connects to a single cluster. To give your AI tool access to multiple clusters, add onemcpServers entry per cluster, each pointing at its own server instance.
- stdio (default)
- HTTP
In stdio mode, your AI tool launches the server as a subprocess, so all configuration is passed in the must include an For the full list of configuration options, refer to the .In this example,
env block of the tool’s MCP configuration. Add one of the following to your MCP client’s configuration file, replacing the example values with your own host, user, and certificate paths. Most MCP clients read an mcpServers block or an equivalent. Refer to your client’s documentation for the file location and format.GUI clients such as Claude Desktop often launch with a minimal
PATH and do not expand ~, so a bare command may not resolve. Use the absolute path to the binary instead, for example /Users/{username}/go/bin/cockroachdb-mcp-server.Specify configuration variables
Certificate authentication (recommended)
Use to connect with client certificates:Connection string
Use to pass all connection parameters in a single string:sslmode of require, verify-ca, or verify-full. A connection string that omits sslmode is rejected at startup.Local insecure cluster (development only)
For a local cluster started withcockroach start-single-node --insecure or , opt in to a TLS-free connection. No certificate files are needed:Docker
To run the Docker image in stdio mode, setcommand to docker and move all configuration into args: pass run, --rm, and -i, followed by each environment variable with -e, and the image reference last. The same CRDB_* variables apply unchanged. Because the server runs inside the container, mount the host certificate directory read-only and point the CRDB_SSL_* paths at the in-container mount location:/path/to/certs is the certificate directory on the host, and /certs is where it is mounted inside the container.A connection string translates the same way: keep the read-only mount, and use the in-container /certs paths in the sslcert, sslkey, and sslrootcert parameters of CRDB_DATABASE_URL.For a local insecure cluster, localhost inside the container refers to the container itself, not the host. On macOS and Windows, use host.docker.internal in place of localhost in the connection string. On Linux, add "--network", "host" to args and keep localhost.
