Skip to content

[Scale/Architecture] Proposal: CockroachDB-Backed MCP Server for Durable State and Idempotent Tool Execution #3977

Description

@farhadakhtar

Summary

I would like to propose an MCP server implementation that uses CockroachDB as its primary state store to provide:

  • Durable server state
  • Strong consistency through Raft replication
  • Transactional idempotency for tool executions
  • Safe retry semantics under concurrent workloads
  • Horizontal scalability without relying on local process state

This proposal is intended as a standalone MCP server project that would later be published separately and referenced from the MCP Registry through a standard server.yaml entry.


Problem Statement

Many MCP server implementations rely on:

  • Local in-memory state
  • File-based persistence
  • Non-idempotent callback execution
  • Single-node storage assumptions

Under concurrent workloads or process restarts, these patterns can lead to:

  • Duplicate tool execution
  • Lost state after crashes
  • Race conditions between concurrent requests
  • Difficult horizontal scaling

As MCP adoption grows, there may be value in providing a reference architecture for stateful MCP servers that require stronger consistency guarantees.


Proposed Solution

Build a dedicated MCP server that uses CockroachDB as the system of record.

Durable State

All persistent state is stored in CockroachDB rather than local files or memory.

Idempotent Tool Execution

Each tool invocation is assigned an idempotency key.

The server records invocation state inside a transactional table before executing side effects.

This enables safe retries and prevents duplicate execution.

Serializable Transactions

Tool execution metadata is protected by CockroachDB's serializable transaction model, reducing race conditions and write conflicts.

Horizontal Scalability

Server instances remain stateless.

Multiple replicas can serve requests while sharing the same underlying CockroachDB cluster.


Architecture Overview

Core Components

  • MCP Server Runtime
  • CockroachDB Cluster
  • Idempotency Layer
  • Transaction Coordinator
  • Health & Readiness System
  • Horizontal Scaling Layer

Data Flow

  1. Client sends tool invocation.
  2. Server generates an idempotency key.
  3. Invocation metadata is written to CockroachDB.
  4. Transaction executes under serializable isolation.
  5. Result is persisted atomically.
  6. Duplicate requests return the stored result.
  7. Stateless replicas can safely serve future requests.

Intended Deliverables

A separate public repository containing:

  • MCP server implementation
  • Docker image
  • CI/CD pipeline
  • CockroachDB schema and migrations
  • Deployment documentation
  • Example production configuration
  • Load-testing examples

The MCP Registry submission would only contain the registry metadata entry pointing to the implementation repository and published image.


Benefits

Reliability

  • Survives process restarts
  • Durable execution history
  • Reduced risk of data loss

Consistency

  • Serializable transactions
  • Safe concurrent execution
  • Predictable retry behavior

Scalability

  • Stateless server replicas
  • Horizontal scaling support
  • Multi-region deployment capability

Operational Simplicity

  • Centralized state management
  • Simplified failover
  • Standardized deployment patterns

Questions for Maintainers

  1. Would a CockroachDB-backed MCP server be appropriate for inclusion in the MCP ecosystem?

  2. Are there existing MCP servers that already address durable state and idempotent execution in a similar way?

  3. Are there recommended patterns for documenting and registering stateful MCP servers within the registry?

  4. Would maintainers prefer this as:

    • A standalone MCP server implementation
    • A reference architecture/example project
  5. Are there any MCP Registry requirements that should influence repository structure, image publishing, or configuration design?


Additional Context

The goal is not to modify MCP Registry itself.

The goal is to provide a reusable MCP server implementation that demonstrates:

  • Strong consistency
  • Distributed durability
  • Safe concurrency
  • Operational scalability
  • Production-ready deployment practices

Feedback on architecture, scope, implementation strategy, and registry expectations would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions