Provides a containerized deployment option with an official Docker image for running the CockroachDB MCP Server.
Provides tools for managing, monitoring, and querying CockroachDB data through VS Code with GitHub Copilot's agent mode.
Integrates with OpenAI Agents SDK to enable AI assistants to query and manage CockroachDB data through natural language.
Connects to CockroachDB using the PostgreSQL interface to provide database operations, table management, and query execution capabilities.
CockroachDB MCP Server
Overview
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.
Table of Contents
Features
- Natural Language Queries: Enables AI agents to query and create transactions using natural language, supporting complex workflows.
- Search & Filtering: Supports efficient data retrieval and searching in CockroachDB.
- Cluster Monitoring: Check and monitor the CockroachDB cluster status, including node health and replication.
- Database Operations: Perform all operations related to databases, such as creation, deletion, and configuration.
- Table Management: Handle tables, indexes, and schemas for flexible data modeling.
- Seamless MCP Integration: Works with any MCP client for smooth communication.
- Scalable & Lightweight: Designed for high-performance data operations.
Tools
The CockroachDB MCP Server Server provides tools to manage the data stored in CockroachDB.
The tools are organized into four main categories:
Cluster Monitoring
Purpose: Provides tools for monitoring and managing CockroachDB clusters.
Summary:
- Get cluster health and node status.
- Show currently running queries.
- Analyze query performance statistics.
- Retrieve replication and distribution status for tables or the whole database.
Database Operations
Purpose: Handles database-level operations and connection management.
Summary:
- Connect to a CockroachDB database.
- List, create, drop, and switch databases.
- Get connection status and active sessions.
- Retrieve database settings.
Table Management
Purpose: Provides tools for managing tables, indexes, views, and schema relationships in CockroachDB.
Summary:
- Create, drop, and describe tables and views.
- Bulk import data into tables.
- Manage indexes (create/drop).
- List tables, views, and table relationships.
- Analyze schema structure and metadata.
Query Engine
Purpose: Executes and manages SQL queries and transactions.
Summary:
- Execute SQL queries with formatting options (JSON, CSV, table).
- Run multi-statement transactions.
- Explain query plans for optimization.
- Track and retrieve query history.
Installation
The CockroachDB MCP Server supports the stdio
transport. Support for the streamable-http
transport will be added in a future release.
Quick Start with uvx
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.
Development Installation
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.
- Specify your CockroachDB credentials and TLS configuration
- Retrieve your
uv
command full path (e.g.which uv
) - Edit the
claude_desktop_config.json
configuration file - on a MacOS, at~/Library/Application Support/Claude/
You can troubleshoot problems by tailing the log file.
With Docker
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
.
Configuration
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.
Configuration via command line arguments
When using the CLI interface, you can configure the server with command line arguments:
Available CLI Options:
--url
- CockroachDB connection URI (postgresql://user@host/db)--host
- CockroachDB hostname--port
- CockroachDB port (default: 26257)--db
- CockroachDB database name (default: defaultdb)--user
- CockroachDB username--password
- CockroachDB password--ssl-mode
- SSL mode - Possible values: require, verify-ca, verify-full, disable (default)--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'
Configuration via Environment Variables
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:
- Using a
.env
File: Place a.env
file in your project directory with key-value pairs for each environment variable. Tools likepython-dotenv
,pipenv
, anduv
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,
- Setting Variables in the Shell: You can export environment variables directly in your shell before running your application. For example:
This method is helpful for temporary overrides or quick testing.
Integrations
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.
OpenAI Agents SDK
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.
Augment
You can configure the CockroachDB MCP Server in Augment by importing the server via JSON:
Claude Desktop
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
.
If you'd like to test the CockroachDB MCP Server via Smithery, you can configure Claude Desktop automatically:
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.
VS Code with GitHub Copilot
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.
Cursor
Read the configuration options here and input your selections with this link:
Testing
You can use the MCP Inspector for visual debugging of this MCP Server.
Contributing
- Fork the repository
- Create a new branch (
feature-branch
) - Commit your changes
- Push to your branch and submit a pull request.
License
This project is licensed under the MIT License.
Contact
If you have any questions or need support, please feel free to contact us through GitHub Issues.
Tools
A natural language interface that enables LLMs and agentic applications to manage, monitor, and query data in CockroachDB through MCP (Model Content Protocol).
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol (MCP) server implementation for DuckDB, providing database interaction capabilities through MCP tools. It would be interesting to have LLM analyze it. DuckDB is suitable for local analysis.Last updated -5139PythonMIT License
- -securityAlicense-qualityA Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.Last updated -1,783156TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol (MCP) server that enables LLMs to interact directly the documents that they have on-disk through agentic RAG and hybrid search in LanceDB. Ask LLMs questions about the dataset as a whole or about specific documents.Last updated -463TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases, allowing them to query collections, inspect schemas, and manage data seamlessly through natural language.Last updated -1,783MIT License