Skip to main content

Model Context Protocol server with CockroachDB

Project description

cockroachdb-mcp-server

PyPI Python License CI MCP Compatible

A Model Context Protocol (MCP) server implemented in Python using FastAPI and CockroachDB.


🧠 What This Is

cockroachdb-mcp-server is a production-grade, spec-aligned MCP server that:

  • Implements the Model Context Protocol
  • Uses CockroachDB as a resilient, SQL-compatible backend
  • Exposes full CRUD APIs for managing model contexts
  • Stores context definitions as JSONB, allowing arbitrary input/output schema
  • Works seamlessly with the cockroachdb-mcp-client CLI

✅ Feature Highlights

  • ✅ REST API for MCP context management (/contexts)
  • ✅ Schema bootstrapping via CLI flag or env var
  • ✅ CRDB URL auto-detection and dialect fix
  • ✅ ASCII banner and version info
  • ✅ Structured logging and configurable log level
  • ✅ Ready for /run, /deploy, /evaluate extensions

🚀 Quickstart

📦 Install from PyPI

pip install cockroachdb-mcp-server

🏃 Run with schema init

cockroachdb-mcp-server serve --init-schema --log-level INFO

Or:

export MCP_AUTO_INIT_SCHEMA=true
cockroachdb-mcp-server serve

Server runs at http://localhost:8081 by default


🔧 CLI Usage

cockroachdb-mcp-server serve --init-schema
cockroachdb-mcp-server serve --port 8081 --host 127.0.0.1 --reload
cockroachdb-mcp-server --version
cockroachdb-mcp-server --banner

🔐 Configuring the Database

✅ Set the CRDB_URL environment variable

export CRDB_URL="postgresql://root@localhost:26257/defaultdb?sslmode=disable"

Automatically rewritten to cockroachdb://... under the hood for compatibility.

Alternatively, set it directly:

export CRDB_URL="cockroachdb://root@localhost:26257/defaultdb?sslmode=disable"

✅ Both formats are supported.


🧪 API Endpoints

Method Path Description
POST /contexts Create a context
GET /contexts List all contexts
GET /contexts/{id} Get context by ID
PUT /contexts/{id} Update context
DELETE /contexts/{id} Delete context

📘 View full API reference →

📘 View hosted API Docs


🧱 Schema Auto-Bootstrap

Run this manually:

cockroachdb-mcp-server serve --init-schema

Or automatically with:

export MCP_AUTO_INIT_SCHEMA=true

The schema created is:

CREATE TABLE IF NOT EXISTS mcp_contexts (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  context_name STRING NOT NULL,
  context_version STRING NOT NULL,
  body JSONB NOT NULL,
  created_at TIMESTAMP DEFAULT now()
);

🔗 Related Projects

  • cockroachdb-mcp-client: CLI tool to manage MCP contexts, simulate LLM runs, export, and batch simulate across providers.

🙌 Contributions

This project is designed for internal and community use.

PRs welcome to extend functionality (auth, deployment support, /evaluate, telemetry, etc.).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cockroachdb_mcp_server-0.2.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cockroachdb_mcp_server-0.2.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file cockroachdb_mcp_server-0.2.1.tar.gz.

File metadata

  • Download URL: cockroachdb_mcp_server-0.2.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for cockroachdb_mcp_server-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f12ca32b478e19e2bbd370b18b4b81698ef471cb00ebac8d82c0230426e2de4b
MD5 0ecea579f0a98160ed8ad5643357b33f
BLAKE2b-256 b20e2a1de7a8f57ca6bbbffe973c2761ecec876e4749279ef8e0526c4033868c

See more details on using hashes here.

File details

Details for the file cockroachdb_mcp_server-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for cockroachdb_mcp_server-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8930a8bcffc796940dbbf24a0b804e11bba07351279232bb2e4b87f687b87f8
MD5 f9da5027c5995ab587eacde0994f29c4
BLAKE2b-256 a2250007a5ae3c6707e638deaf265ab5c35be62a64da68aa2dcdc66a8547db51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page