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. - Cluster Monitoring - Database Operations - Table Management - Query Engin
Add this skill
npx mdskills install amineelkouhen/mcp-cockroachdbComprehensive CockroachDB interface with well-organized tools and excellent setup documentation
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.
The CockroachDB MCP Server Server provides tools to manage the data stored in CockroachDB.
The tools are organized into four main categories:
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, and schema relationships in CockroachDB.
Summary:
Purpose: Executes and manages SQL queries and transactions.
Summary:
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:
uvx --from git+https://github.com/amineelkouhen/mcp-cockroachdb.git@0.1.0 cockroachdb-mcp-server --url postgresql://localhost:26257/defaultdb
Check the release notes for the latest version in the Releases section. Additional examples are provided below.
# Run with CockroachDB URI
uvx --from git+https://github.com/amineelkouhen/mcp-cockroachdb.git cockroachdb-mcp-server --url postgresql://localhost:26257/defaultdb
# Run with individual parameters
uvx --from git+https://github.com/amineelkouhen/mcp-cockroachdb.git cockroachdb-mcp-server --host localhost --port 26257 --database defaultdb --user root --password mypassword
# See all options
uvx --from git+https://github.com/amineelkouhen/mcp-cockroachdb.git cockroachdb-mcp-server --help
# Run with streamable HTTP transport
uvx --from git+https://github.com/amineelkouhen/mcp-cockroachdb.git cockroachdb-mcp-server \
--url postgresql://localhost:26257/defaultdb \
--transport http \
--http-host 0.0.0.0 \
--http-port 8000 \
--http-path /mcp
For development or if you prefer to clone the repository:
# Clone the repository
git clone https://github.com/amineelkouhen/mcp-cockroachdb.git
cd mcp-cockroachdb
# Install dependencies using uv
uv venv
source .venv/bin/activate
uv sync
# Run with CLI interface
uv run cockroachdb-mcp-server --help
# Or run the main file directly (uses environment variables)
uv run src/main.py
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/{
"mcpServers": {
"cockroach": {
"command": "",
"args": [
"--directory",
"",
"run",
"src/main.py"
],
"env": {
"CRDB_HOST": "",
"CRDB_PORT": "",
"CRDB_DATABASE": "",
"CRDB_USERNAME": "",
"CRDB_PWD": "",
"CRDB_SSL_MODE": "disable|allow|prefer|require|verify-ca|verify-full",
"CRDB_SSL_CA_PATH": "",
"CRDB_SSL_KEYFILE": "",
"CRDB_SSL_CERTFILE": "",
}
}
}
}
You can troubleshoot problems by tailing the log file.
tail -f ~/Library/Logs/Claude/mcp-server-cockroach.log
For local development and testing, use the provided docker-compose.yaml to spin up both CockroachDB and the MCP server:
# Start CockroachDB and MCP server
docker compose up -d
# The MCP server is available at http://localhost:8000/mcp/
# CockroachDB UI is available at http://localhost:8080
# View logs
docker compose logs -f mcp-server
# Stop and clean up
docker compose down -v
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:
docker build -t mcp-cockroachdb .
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:
{
"mcpServers": {
"cockroach": {
"command": "docker",
"args": ["run",
"--rm",
"--name",
"cockroachdb-mcp-server",
"-e", "CRDB_HOST=",
"-e", "CRDB_PORT=",
"-e", "CRDB_DATABASE=",
"-e", "CRDB_USERNAME=",
"mcp-cockroachdb"]
}
}
}
To use the CockroachDB MCP Docker image, just replace your image name (mcp-cockroachdb in the example above) with mcp/cockroachdb.
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:
# Basic CockroachDB connection
uvx --from git+https://github.com/amineelkouhen/mcp-cockroachdb.git cockroachdb-mcp-server \
--host localhost \
--port 26257 \
--db defaultdb \
--user root \
--password mypassword
# Using CockroachDB URI (simpler)
uvx --from git+https://github.com/amineelkouhen/mcp-cockroachdb.git cockroachdb-mcp-server \
--url postgresql://root@localhost:26257/defaultdb
# SSL connection
uvx --from git+https://github.com/amineelkouhen/mcp-cockroachdb.git cockroachdb-mcp-server \
--url postgresql://user:pass@cockroach.example.com:26257/defaultdb?sslmode=verify-full&sslrootcert=path/to/ca.crt&sslcert=path/to/client.username.crt&sslkey=path/to/client.username.key
# See all available options
uvx --from git+https://github.com/amineelkouhen/mcp-cockroachdb.git cockroachdb-mcp-server --help
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)--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'--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 configurationIf 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:cp .env.example .env
Then edit the .env file to set your CockroachDB configuration:
OR,
export CRDB_URL= postgresql://root@127.0.0.1:26257/defaultdb
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.
pip install openai-agents
Configure the OpenAI token:
export OPENAI_API_KEY=""
And run the application.
python3 examples/cockroachdb_assistant.py
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:
{
"mcpServers": {
"CockroachDB MCP Server": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/cockroachdb/mcp-cockroachdb.git",
"cockroachdb-mcp-server",
"--url",
"postgresql://root@localhost:26257/defaultdb"
]
}
}
}
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.
{
"mcpServers": {
"cockroach-mcp-server": {
"type": "stdio",
"command": "/opt/homebrew/bin/uvx",
"args": [
"--from", "git+https://github.com/amineelkouhen/mcp-cockroachdb.git",
"cockroachdb-mcp-server",
"--url", "postgresql://localhost:26257/defaultdb"
]
}
}
}
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:
{
"chat.agent.enabled": true
}
You can start the GitHub desired version of the CockroachDB MCP server using uvx by adding the following JSON to your settings.json:
"mcp": {
"servers": {
"CockroachDB MCP Server": {
"type": "stdio",
"command": "uvx",
"args": [
"--from", "git+https://github.com/amineelkouhen/mcp-cockroachdb.git",
"cockroachdb-mcp-server",
"--url", "postgresql://root@localhost:26257/defaultdb"
]
},
}
},
Alternatively, you can start the server using uv and configure your mcp.json or settings.json. This is usually desired for development.
{
"servers": {
"cockroach": {
"type": "stdio",
"command": "",
"args": [
"--directory",
"",
"run",
"src/main.py"
],
"env": {
"CRDB_HOST": "",
"CRDB_PORT": "",
"CRDB_DATABASE": "",
"CRDB_USERNAME": "",
"CRDB_PWD": ""
}
}
}
}
For more information, see the VS Code documentation.
Read the configuration options here and input your selections with this link:
You can use the MCP Inspector for visual debugging of this MCP Server.
npx @modelcontextprotocol/inspector uv run src/main.py
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.
Install via CLI
npx mdskills install amineelkouhen/mcp-cockroachdbCockroachDB MCP Server is a free, open-source AI agent skill. 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. - Cluster Monitoring - Database Operations - Table Management - Query Engin
Install CockroachDB MCP Server with a single command:
npx mdskills install amineelkouhen/mcp-cockroachdbThis downloads the skill files into your project and your AI agent picks them up automatically.
CockroachDB MCP Server works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Gemini Cli, Amp, Roo Code, Goose. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.