The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the MCP Cockroachdb listing page.
The CockroachDB MCP Server is a natural language interface designed for LLMs and agentic applications to manage, monitor, and query data in CockroachDB. It integrates seamlessly with MCP (Model Content Protocol) clients, such as Claude Desktop or Cursor, enabling AI-driven workflows to interact directly with your database.
--read-only mode, explicit confirm=True for destructive ops, redacted DSN responses.The CockroachDB MCP Server exposes CockroachDB as a set of MCP tools. Requests flow from any MCP client through a transport, into the safety layer, then to one of the thirteen tool categories, and finally to CockroachDB via an asyncpg connection pool.
The tools are organized into thirteen categories, grouped above by concern. Every write-shaped tool is gated by --read-only. Every destructive tool also requires --allow-destructive plus a per-call confirm=True parameter; see the Safety Model section.
Purpose: Provides tools for monitoring and managing CockroachDB clusters.
Summary:
Purpose: Handles database-level operations and connection management.
Summary:
Purpose: Provides tools for managing tables, indexes, views, schemas, and relationships in CockroachDB.
Summary:
alter_table_add_column, alter_table_drop_column, alter_table_rename_column.list_schemas, create_schema, drop_schema).Purpose: Executes and manages SQL queries and transactions.
Summary:
Purpose: Manage SQL users, roles, and privileges. Use this from an administrative agent to provision the agent's own scoped (non-root) user.
Summary:
list_users, create_user, drop_user, alter_user_password.create_role, drop_role, grant_role, revoke_role.show_grants, grant_privileges, revoke_privileges.Privileges are validated against an allowlist (SELECT, INSERT, UPDATE,
DELETE, ALL, BACKUP, RESTORE, MODIFYCLUSTERSETTING, ...). Identifiers
go through the same strict regex as everywhere else.
Purpose: Search VECTOR columns with CockroachDB's similarity operators (v25.2+) and manage C-SPANN ANN indexes.
Summary:
vector_similarity_search with metric of cosine (default), l2, ip,
or auto (matches the existing index opclass). Returns distance and a
derived similarity field.create_cspann_index with metric → opclass mapping
(vector_cosine_ops / vector_l2_ops / vector_ip_ops).drop_cspann_index (destructive).The query vector is always passed as a $1::VECTOR parameter; identifier and
optional where clause values are validated. For normalized embeddings (e.g.
Takara DS1, OpenAI text-embedding-3) all three metrics rank identically; the
default cosine is the safest because it ignores magnitude.
Purpose: Observe and control long-running CockroachDB jobs (BACKUP, RESTORE, IMPORT, SCHEMA CHANGE, CHANGEFEED).
Summary:
list_jobs (filter by status and type), get_job_status.pause_job, resume_job, cancel_job (destructive).Purpose: Take and restore cluster, database, and table backups.
Summary:
create_backup to s3/gs/azure/nodelocal/userfile destinations.list_backups to enumerate backups at a storage URI.restore_backup (destructive) with optional new_db_name.list_scheduled_backups.URI schemes are validated against an allowlist; identifier targets are identifier-validated.
Purpose: Compute and inspect the table statistics the cost-based optimizer relies on.
Summary:
create_statistics (CREATE STATISTICS).show_statistics (SHOW STATISTICS FOR TABLE).Purpose: Configure multi-region behaviour: regions, survival goals, table localities, zone configurations.
Summary:
show_regions, show_database_regions.add_database_region, drop_database_region (destructive).set_survival_goal (ZONE or REGION).set_table_locality (REGIONAL, REGIONAL_BY_ROW, REGIONAL_BY_TABLE, GLOBAL).show_zone_config for DATABASE/TABLE/INDEX.Purpose: Set up and operate CDC pipelines to Kafka, webhooks, or cloud storage.
Summary:
create_changefeed with sink-scheme validation (kafka, webhook-http(s), s3,
gs, azure-blob, external, null), JSON or Avro format, choice of envelope.list_changefeeds, pause_changefeed, resume_changefeed.cancel_changefeed (destructive).Purpose: Cluster-wide administration: cluster settings and node lifecycle.
Summary:
show_cluster_setting, set_cluster_setting, reset_cluster_setting
(destructive). Setting names are validated against a strict regex.decommission_node, drain_node. Note that SQL-initiated decommission
only marks intent; for the full lifecycle use the cockroach node CLI.Purpose: Inspect tracing spans and request statement-diagnostics bundles.
Summary:
get_recent_traces from crdb_internal.cluster_inflight_traces.list_statement_diagnostics_requests.request_statement_diagnostics for a statement fingerprint.The CockroachDB MCP Server supports the stdio transport and the streamable-http transport.
The easiest way to use the CockroachDB MCP Server is with uvx, which allows you to run it directly from GitHub (from a branch, or use a tagged release). It is recommended to use a tagged release. The main branch is under active development and may contain breaking changes. As an example, you can execute the following command to run the 0.1.0 release:
Check the release notes for the latest version in the Releases section. Additional examples are provided below.
For development or if you prefer to clone the repository:
Once you cloned the repository, installed the dependencies and verified you can run the server, you can configure Claude Desktop or any other MCP Client to use this MCP Server running the main file directly (it uses environment variables). This is usually preferred for development. The following example is for Claude Desktop, but the same applies to any other MCP Client.
uv command full path (e.g. which uv)claude_desktop_config.json configuration file
- on a MacOS, at ~/Library/Application Support/Claude/You can troubleshoot problems by tailing the log file.
For local development and testing, use the provided docker-compose.yaml to spin up both CockroachDB and the MCP server:
You can use a dockerized deployment of this server. You can either build your image or use the official CockroachDB MCP Docker image.
If you'd like to build your image, the CockroachDB MCP Server provides a Dockerfile. Build this server's image with:
Finally, configure the client to create the container at start-up. An example for Claude Desktop is provided below. Edit the claude_desktop_config.json and add:
To use the CockroachDB MCP Docker image, just replace your image name (mcp-cockroachdb in the example above) with mcp/cockroachdb.
The repository ships an MCPB manifest under mcpb/manifest.json. MCPB (.mcpb) is a single-file archive that clients like Claude Desktop and catalogs like Smithery can install as a local stdio server, prompting the user for connection details via a UI instead of hand-editing JSON.
The manifest declares six user_config fields: url (marked sensitive, so the client stores it in the OS keychain rather than plaintext config), read_only (default true), allow_destructive (default false), and optional ssl_ca_cert / ssl_cert / ssl_key file pickers. Values are passed to the server via env vars (CRDB_URL, MCP_READ_ONLY, MCP_ALLOW_DESTRUCTIVE, CRDB_SSL_*).
Build the bundle:
Install locally in Claude Desktop: double-click the resulting .mcpb file. Claude Desktop will show the config form built from user_config.
Publish to Smithery:
The CockroachDB MCP Server can be configured in two ways: either via command-line arguments or via environment variables. The precedence is: CLI arguments > environment variables > default values.
When using the CLI interface, you can configure the server with command line arguments:
Available CLI Options:
--url - CockroachDB connection URI (postgresql://user:pass@host:port/db)--host - CockroachDB hostname--port - CockroachDB port (default: 26257)--db - CockroachDB database name (default: defaultdb)--username - CockroachDB username (default: root)--password - CockroachDB password--ssl-mode - SSL mode - Possible values: disable (default), allow, prefer, require, verify-ca, verify-full--ssl-key - Path to SSL client key file--ssl-cert - Path to SSL client certificate file--ssl-ca-cert - Path to CA (root) certificate file--transport - MCP transport to use (stdio or http)--http-host - HTTP host to bind for streamable HTTP transport--http-port - HTTP port to bind for streamable HTTP transport--http-path - HTTP path for streamable HTTP transport (e.g., /mcp)--stateless-http - Enable stateless HTTP mode for horizontal scaling--use-env - Use environment variables for CockroachDB configuration--read-only - Refuse all DDL and write tools; recommended for assistant-style deployments--allow-destructive - Required for drop_database, drop_table, drop_index, drop_view. Even with this flag, every destructive call must include confirm=True.--version - Show the server version and exitThis server is designed for use with an LLM-driven agent, where a prompt-injection attack on the agent could turn into SQL injection or data destruction. Three layers of defense are built in:
^[A-Za-z_][A-Za-z0-9_]{0,62}$ before being interpolated into SQL.$1, $2, ...). No user-controlled value is interpolated into SQL.--read-only disables every DDL and write-shaped tool (drop_*, create_*, execute_query of INSERT/UPDATE/etc., bulk_import, ...).--allow-destructive is required for drop_* tools. Even then, the caller must pass confirm=True per call.connect() results.Recommended defaults for production assistant-style use: --read-only. For administrative agents that need to manage schema, set --allow-destructive but never disable the confirm=True requirement.
Logging is configured via environment variables:
MCP_LOG_LEVEL (default INFO) — standard Python logging level (DEBUG/INFO/WARNING/ERROR).MCP_LOG_JSON=1 — emit JSON-structured log lines, recommended when running with --transport http.CRDB_POOL_MIN (default 1)CRDB_POOL_MAX (default 10)CRDB_COMMAND_TIMEOUT (default 60 seconds)If desired, you can use environment variables. Defaults are provided for all variables.
| Name | Description | Default Value |
|---|---|---|
CRDB_HOST | The host name or address of a CockroachDB node or load balancer. | 127.0.0.1 |
CRDB_PORT | The port number of the SQL interface of the CockroachDB node or load balancer. | 26257 |
CRDB_DATABASE | A database name to use as the current database. | defaultdb |
CRDB_USERNAME | The SQL user that will own the client session. | root |
CRDB_PWD | The user's password. | None |
CRDB_SSL_MODE | Which type of secure connection to use. | disable |
CRDB_SSL_CA_PATH | Path to the CA certificate, when sslmode is not disable. | None |
CRDB_SSL_CERTFILE | Path to the client certificate, when sslmode is not disable. | None |
CRDB_SSL_KEYFILE | Path to the client private key, when sslmode is not disable. | None |
There are several ways to set environment variables:
.env File:
Place a .env file in your project directory with key-value pairs for each environment variable. Tools like python-dotenv, pipenv, and uv can automatically load these variables when running your application. This is a convenient and secure way to manage configuration, as it keeps sensitive data out of your shell history and version control (if .env is in .gitignore).
For example, create a .env file with the following content from the .env.example file provided in the repository:Then edit the .env file to set your CockroachDB configuration:
OR,
This method is helpful for temporary overrides or quick testing.
Integrating this MCP Server with development frameworks like OpenAI Agents SDK or using tools like Claude Desktop, VS Code, or Augment is described in the following sections.
Integrate this MCP Server with the OpenAI Agents SDK. Read the documents to learn more about the integration of the SDK with MCP.
Install the Python SDK.
Configure the OpenAI token:
And run the application.
You can troubleshoot your agent workflows using the OpenAI dashboard.
You can configure the CockroachDB MCP Server in Augment by importing the server via JSON:
The simplest way to configure MCP clients is using uvx. Add the following JSON to your claude_desktop_config.json, remember to provide the full path to uvx.
Please follow the prompt and give the details to configure the server and connect to CockroachDB (e.g., using a managed CockroachDB instance).
The procedure will create the proper configuration in the claude_desktop_config.json configuration file.
To use the CockroachDB MCP Server with VS Code, you must enable the agent mode tools. Add the following to your settings.json:
You can start the GitHub desired version of the CockroachDB MCP server using uvx by adding the following JSON to your settings.json:
Alternatively, you can start the server using uv and configure your mcp.json or settings.json. This is usually desired for development.
For more information, see the VS Code documentation.
Read the configuration options here and input your selections with this link:
The repository ships with a pytest suite covering the SQL identifier validators, type serializers, DSN parsing, URL helpers, output formatting, and policy gating (read-only mode, destructive-op gating, injection rejection).
CI runs the same suite on Python 3.12 and 3.13. See .github/workflows/test.yml.
For interactive debugging of the live server, use the MCP Inspector:
feature-branch)This project is licensed under the MIT License.
If you have any questions or need support, please feel free to contact us through GitHub Issues.