Skip to main content
Glama
cockroachdb-mcp-server

cockroachdb-mcp-server

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


Related MCP server: TiDB MCP Server

βœ… Feature Highlights

  • βœ… REST API for MCP context management (/contexts)

  • βœ… Schema bootstrapping via CLI flag or env var

  • βœ… CRDB URL auto-detection and dialect fix

  • βœ… 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

πŸ” 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()
);

  • 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.).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables Large Language Models to access and interact with database connections, including viewing schemas and performing CRUD operations on connected databases.
      -
    • F
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that allows executing SELECT queries on TiDB databases, with optional support for INSERT, UPDATE, and DELETE operations when explicitly enabled.
      1
      6 npm
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that provides AI assistants with persistent semantic memory and knowledge graph capabilities using PostgreSQL and vector embeddings. It enables cross-session storage, hybrid search, and complex relationship tracking for enhanced contextual awareness.
      12 npm
      1
      MIT