MCP Connector

Manage Model Contexts with CockroachDB

A FastAPI-based MCP server that persists model context definitions as JSONB in CockroachDB, with full CRUD REST endpoints.

Works with cockroachdbgithub

Maintainer of this project? Claim this page to edit the listing.


91
Spark score
out of 100
Updated Jun 2025
Version 0.2.2
Models
universal

Add to Favorites

Why it matters

Reliably manage AI model contexts using CockroachDB as a backend. This asset provides full CRUD operations and flexible JSONB storage for your model data.

Outcomes

What it gets done

01

Create, retrieve, update, and delete model contexts.

02

Store arbitrary input/output data schemas using JSONB.

03

Initialize database schema automatically or via configuration.

04

Integrate with CockroachDB via standard connection URLs.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-cockroachdb-mcp-server | bash

Capabilities

Tools your agent gets

create_context

Create a new model context

list_contexts

Get a list of all contexts

get_context

Get a context by ID

update_context

Update an existing context

delete_context

Delete a context by ID

Overview

CockroachDB MCP Server

This MCP server implements full CRUD REST APIs for model context definitions, storing them as JSONB in CockroachDB rather than memory or files, with auto-bootstrapped schema and dialect-aware connection handling. Use it when you need durable, SQL-backed storage for MCP contexts across a team or service. It's an early-stage community project without built-in auth, so check hardening needs before production use.

What it does

cockroachdb-mcp-server is a production-grade, spec-aligned Model Context Protocol server implemented in Python with FastAPI, using CockroachDB as its resilient, SQL-compatible backend. It exposes full CRUD REST APIs for managing model contexts, storing each context definition as JSONB - which allows arbitrary input/output schemas rather than a fixed structure. It auto-detects and rewrites postgresql:// connection URLs to the cockroachdb:// dialect for compatibility, supports schema bootstrapping via a CLI flag or environment variable, and provides structured, configurable logging.

When to use - and when NOT to

Use this when you need a durable, queryable store for MCP context definitions backed by a real SQL database rather than an in-memory or file-based store - for example, building infrastructure that manages many model contexts across teams or services and needs CockroachDB's resilience characteristics. It pairs with the companion cockroachdb-mcp-client CLI for managing contexts, simulating LLM runs, exporting, and batch-simulating across providers. It is explicitly designed for internal and community use with contributions welcome to extend functionality (auth, deployment support, /evaluate, telemetry) - meaning some capabilities like authentication are not yet built in, so evaluate hardening needs before production use.

Capabilities

REST endpoints for context management:

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

The auto-bootstrapped schema:

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()
);

The server is noted as "ready for" future /run, /deploy, /evaluate extensions, though these are not yet implemented.

How to install

pip install cockroachdb-mcp-server

Set the database connection and run with schema initialization:

export CRDB_URL="postgresql://root@localhost:26257/defaultdb?sslmode=disable"
cockroachdb-mcp-server serve --init-schema --log-level INFO

Or auto-init the schema on every start:

export MCP_AUTO_INIT_SCHEMA=true
cockroachdb-mcp-server serve

Other CLI options: cockroachdb-mcp-server serve --port 8081 --host 127.0.0.1 --reload and cockroachdb-mcp-server --version. The server runs at http://localhost:8081 by default.

Who it's for

Developers and teams building MCP infrastructure who want context definitions persisted in a real SQL-compatible database rather than memory or flat files, and who are comfortable with an early-stage, community-driven project where auth and deployment tooling are still on the roadmap.

Source README

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
  • โœ… 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()
);

๐Ÿ”— 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.).

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.