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
Metadata
Release files for ocp-server 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ocp_server-0.3.0.tar.gz | 33.9 kB | With provenance | Details for ocp_server-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ocp_server-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for ocp_server-0.3.0-py3-none-any.whl |
Total release size: 76.9 kB
Release files / ocp_server-0.3.0.tar.gz
| Download URL | ocp_server-0.3.0.tar.gz |
|---|---|
| Size | 33.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b9a1498dc54d5001b262b58ff8d601a0887880ee66b894bb7485b564486f817
|
|
BLAKE2b-256 checksum How to use checksums |
5c91534ab112451a69219da170979bde3bcbee43a21c1eab7abef2ffa8cb995c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logRelease files / ocp_server-0.3.0-py3-none-any.whl
| Download URL | ocp_server-0.3.0-py3-none-any.whl |
|---|---|
| Size | 43.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb94db5e0380a3ace605e88017ba264f862516a886b027aab1db773ee22b6232
|
|
BLAKE2b-256 checksum How to use checksums |
d7cc72889d555e36d21da5b384e2416b2d791a02b05950bf02f4a24d580c8063
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logSecurity for ocp-server 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ocp_server-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.