Skip to main content

Open Context Protocol — reference server implementation

Project description

ocp-server

Reference server implementation for the Open Context Protocol (OCP) — a vendor-neutral protocol for sharing retrievable context, persistent state, and invalidation events across AI agents, models, and frameworks.

Every OCP server is an MCP server. Drop it into any MCP-compatible IDE or agent runtime with a single config line.

What it does

  • Semantic retrieval — index any codebase or document set, run k-NN search over embedded chunks, assemble token-budget-aware context bundles ready for LLM prompts
  • Scoped state — typed key-value store with agent, session, and global scopes and optimistic concurrency control
  • Session coordination — agent handoff, named checkpoints, restore from checkpoint
  • Invalidation & events — file watcher marks stale chunks automatically; real-time event subscriptions with replay

Quick start

# Zero-install — run directly from PyPI
uvx ocp-server

# Or install permanently
pip install ocp-server
ocp-server          # stdio transport (for IDE / agent integrations)
ocp-server-http     # HTTP/SSE transport (for multi-client / remote scenarios)

IDE integrations

Add to .mcp.json in your project root (Claude Code, VS Code, JetBrains):

{
  "mcpServers": {
    "ocp": {
      "command": "uvx",
      "args": ["ocp-server"],
      "env": { "OCP_DB_PATH": "${workspaceFolder}/.ocp.db" }
    }
  }
}

Works the same way for Claude Desktop, Cursor, and any other MCP-compatible runtime. See the integrations guide for copy-paste configs.

Storage backends

Backend How to enable
SQLite (default) Zero config — just run ocp-server
PostgreSQL + pgvector Set OCP_DATABASE_URL=postgresql://...

Embedding backends

Backend OCP_EMBEDDER Extra deps Quality
Hash n-gram (default) hash none keyword-level
FastEmbed (BAAI/bge) fastembed pip install fastembed semantic
OpenAI openai pip install openai semantic

Docker

docker pull ghcr.io/rajesh1213/ocp:latest

# Run with SQLite
docker run -p 8080:8080 -e OCP_API_KEYS=my-key ghcr.io/rajesh1213/ocp:latest

# Run with PostgreSQL
docker run -p 8080:8080 \
  -e OCP_DATABASE_URL=postgresql://user:pass@host/db \
  -e OCP_API_KEYS=my-key \
  ghcr.io/rajesh1213/ocp:latest

Configuration

All configuration via environment variables:

Variable Default Description
OCP_DB_PATH ocp.db SQLite file path
OCP_DATABASE_URL PostgreSQL DSN (enables Postgres backend)
OCP_API_KEYS Comma-separated Bearer tokens (empty = open/dev mode)
OCP_API_KEY Key the client presents in stdio mode
OCP_HOST 0.0.0.0 HTTP server bind address
OCP_PORT 8080 HTTP server port
OCP_EMBEDDER hash Embedding backend: hash, fastembed, openai
OCP_WATCH 1 Set to 0 to disable file watching

Conformance

The reference server passes all 44 OCP-0002 conformance tests at the core+coordination level.

# Run conformance suite against this server
pip install ocp-conformance
ocp-conformance

Links

License

Apache-2.0 — see LICENSE

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

ocp_server-0.1.1.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

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

ocp_server-0.1.1-py3-none-any.whl (40.0 kB view details)

Uploaded Python 3

File details

Details for the file ocp_server-0.1.1.tar.gz.

File metadata

  • Download URL: ocp_server-0.1.1.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ocp_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1f922a5ccab6f1f5d986d6bd4e7decacf7c0cff377548aef7302dcd1258c0367
MD5 913ba9e7a7f51ea1f2e5aa95ff7717a4
BLAKE2b-256 9d1aa76a280345423b9490fb9fa0dafbe129a8a2199302a3ac45d0b1e8001e3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocp_server-0.1.1.tar.gz:

Publisher: publish.yml on Rajesh1213/OCP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ocp_server-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ocp_server-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 40.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ocp_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e20285715dde4f9e0c61a8ddabda57e9532c1e0c2f74b945d7a1c07e7e42ee9
MD5 8d9fe0ee9b86faf85b382d1750449d29
BLAKE2b-256 66b96cda6ab70810807d2e020e8171f2b39fee9118aff937f7445942d266a0e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocp_server-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Rajesh1213/OCP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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