Skip to main content
This page lists the configuration options for the that connects to self-hosted CockroachDB deployments. To set up the server, refer to .

Configuration

All configuration is managed via environment variables. In stdio mode, set them in the env block of your MCP client configuration; in HTTP mode, export them in the server’s environment.

Authentication

Certificate-based authentication is recommended in stdio mode. The server runs as a subprocess of the AI agent host, which can read CRDB_PWD, a password embedded in CRDB_DATABASE_URL, PGPASSWORD, or ~/.pgpass from the process’s environment. To protect those credentials, password-based authentication is rejected by default; set CRDB_MCP_ALLOW_PASSWORD_AUTH=true to opt in. You can authenticate with individual variables (recommended) or with a full connection string. CRDB_DATABASE_URL takes precedence when both are set. Alternatively, use a full connection string:

Query behavior

MCP traffic runs at default_transaction_quality_of_service=background by default, so it does not contend with latency-sensitive foreground workloads. The value is chosen with the following precedence:
  1. CRDB_MCP_TXN_QOS, if set (background, regular, or critical).
  2. Otherwise, a default_transaction_quality_of_service=... query parameter in CRDB_DATABASE_URL, if present.
  3. Otherwise, background.

Transport

Logging

Tracing (OpenTelemetry)

Tracing is opt-in. When neither of the following variables is set, no exporter is installed. When enabled, tool calls and their SQL statements are exported as spans, and server logs are exported as OpenTelemetry log records. Query text and errors are redacted before export, so literals and user data never leave the server.

Tools

The following sections list the tools that the MCP server makes available to agents. You likely do not have to invoke these functions explicitly. Most AI tools should be able to decide which functions to call based on natural language prompts provided by the user.

Read-only tools

The following tools are registered by default. They do not modify cluster data.

list_databases

List all databases in the cluster.

list_tables

List all tables in a database.

get_table_schema

Get detailed schema information for a table, including columns and indexes. Returns the statement.

get_cluster

Return cluster identity and version metadata: cluster_id, cluster_name, binary_version, active_version. The identity fields (cluster_id, cluster_name, and active_version) require access to crdb_internal built-in functions, which are gated by default on CockroachDB v25.4 and later. When these fields cannot be accessed, they are returned as null, with the reason reported under an unavailable key. binary_version is always returned. This tool takes no parameters.

list_sql_users

List SQL users defined in the cluster.

list_cluster_nodes

List cluster nodes with address, liveness, and locality. Requires admin or the VIEWCLUSTERMETADATA . This tool takes no parameters.

show_running_queries

List in-flight SQL statements on the cluster, ordered by start time descending. Viewing other users’ statements requires admin or the VIEWACTIVITY or VIEWACTIVITYREDACTED ; otherwise, only the connecting user’s own statements are returned.

select_query

Execute a single statement. Non-SELECT statements are rejected. A default LIMIT of 100 is appended when none is supplied, capped at CRDB_MCP_MAX_ROWS_COUNT. An explicit LIMIT that exceeds CRDB_MCP_MAX_ROWS_COUNT, or LIMIT ALL, is rejected.

explain_query

Return the plan for a single SQL statement without executing it. EXPLAIN ANALYZE (and EXPLAIN ANALYZE (DEBUG)) is rejected because it executes the statement. Display options (VERBOSE, DISTSQL, TYPES, OPT, and so on) pass through.

show_statement

Execute a single SHOW statement such as SHOW SCHEMAS, SHOW INDEXES, SHOW REGIONS, or SHOW JOBS. A default LIMIT is appended, capped at CRDB_MCP_MAX_ROWS_COUNT.

Write tools

The following tools are registered only when CRDB_MCP_ENABLE_WRITE_QUERIES=true is set. Any write tool that includes a RETURNING clause returns the affected rows instead of just the count.

create_database

Create a database.

create_table

Execute a single statement.

insert_rows

Execute a single statement. Returns the number of rows affected.

update_rows

Execute a single statement. A WHERE clause is mandatory. Returns the number of rows affected.

delete_rows

Execute a single statement. A WHERE clause is mandatory. Returns the number of rows affected.

See also