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, andglobalscopes 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
- GitHub
- Protocol spec (OCP-0001)
- Usage guide
- Integrations
- ocp-client — Python async client SDK
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ocp_server-0.2.0.tar.gz.
File metadata
- Download URL: ocp_server-0.2.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fdb81dc27d3f0135192eaa5b61789930586eec2232a4c0608c3b068512b0fe5
|
|
| MD5 |
aba6a42be84a4872697ab7d880926fae
|
|
| BLAKE2b-256 |
869db0eba7d55057d0209202cf31ef947f785e15ab2cc9ceb0f31c20dad481c0
|
Provenance
The following attestation bundles were made for ocp_server-0.2.0.tar.gz:
Publisher:
publish.yml on Rajesh1213/OCP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ocp_server-0.2.0.tar.gz -
Subject digest:
6fdb81dc27d3f0135192eaa5b61789930586eec2232a4c0608c3b068512b0fe5 - Sigstore transparency entry: 1541583214
- Sigstore integration time:
-
Permalink:
Rajesh1213/OCP@940434aaf13245aacaae181acc3f0236d19b0377 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Rajesh1213
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@940434aaf13245aacaae181acc3f0236d19b0377 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ocp_server-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ocp_server-0.2.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67757771d5c95f6594552ac8fafef11328f07dc079c2afd28e52b8192cb5d986
|
|
| MD5 |
3bdd1ce7c182f38276533e073cc990c6
|
|
| BLAKE2b-256 |
9eaabe0e9f1446fdbe0348bdd89c695bff17c8c58f81b2e1adccc8aa8a70b808
|
Provenance
The following attestation bundles were made for ocp_server-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Rajesh1213/OCP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ocp_server-0.2.0-py3-none-any.whl -
Subject digest:
67757771d5c95f6594552ac8fafef11328f07dc079c2afd28e52b8192cb5d986 - Sigstore transparency entry: 1541583289
- Sigstore integration time:
-
Permalink:
Rajesh1213/OCP@940434aaf13245aacaae181acc3f0236d19b0377 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Rajesh1213
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@940434aaf13245aacaae181acc3f0236d19b0377 -
Trigger Event:
push
-
Statement type: