v0.1.0 · Public release · Apache-2.0

A retrieval layer for AI agents.

OCP is an open protocol for sharing retrievable context, persistent state, and invalidation events across AI agents, models, frameworks, and organisations. It layers on top of MCP — every OCP server is an MCP server, every OCP client is an MCP client.

Vendor-neutral Self-hosted Model-agnostic
v0.1.0 RFC draft spec · Apache-2.0 · CC-BY 4.0 public
MCP native — zero migration from any MCP client
0 vendor lock-in — self-hosted, single binary
01 · Why

AI agents are powerful, but context is still fragile.

Most agent workflows repeatedly rediscover the same project knowledge. They scan files again, ask for rules again, and lose useful state when the session ends.

1

Repeated context is expensive

Large prompts, full repositories, tool schemas, and growing chat history consume the context window before the agent can make real progress.

2

State disappears between sessions

Checkpoints, agent handoffs, and session restores should be protocol-level primitives — not something each framework reinvents from scratch.

3

Knowledge should be portable

Teams should not recreate the same context layer separately for every IDE, model, agent, or workflow tool. One open protocol serves all of them.

02 · Where it fits

OCP works with MCP, not against it.

MCP provides transport and tool-call mechanics. OCP adds the context layer on top — workspaces, scoped state, session coordination, and invalidation events. Every OCP server is a valid MCP server.

Agent A / Agent B

Claude Code, Cursor, custom runtimes, any MCP client
Caller

OCP Client

ocp-client — speaks MCP on the wire
This project

OCP Server

ocp-server — exposes workspaces, state, sessions
This project

Storage

SQLite (default) · PostgreSQL + pgvector
Backend
MCP handles transport

Standard tool-call and server-discovery mechanics. OCP exposes itself as an MCP server so any compatible client works out of the box.

OCP adds context primitives

Workspaces with k-NN search, typed scoped state (agent / session / global), session coordination with checkpoints, and real-time invalidation events.

Multiple agents, shared state

Agent A and Agent B can connect to the same OCP server — same or different process — and share context safely through scoped namespaces.

No migration required

If you already run an MCP-compatible IDE or runtime, you already have everything you need to connect to an OCP server.

03 · What OCP adds

Five capabilities MCP doesn't provide.

OCP is not a replacement for MCP. It is a protocol layer that sits above transport to give agents durable, retrievable, multi-agent-safe context — and now automatic model routing.

Workspaces

Semantic search

Index repos, docs, and ticket archives. Query by intent with k-NN search across pluggable embedding backends.

Scoped state

Typed key-value store

Store and retrieve typed values at agent, session, or global scope. Namespaced, not a global blob.

Sessions

Coordination

Agent handoff, checkpoints, and restore. Pick up exactly where another agent left off — across processes.

Events

Invalidation

Real-time notifications when files change or state updates, so agents never work from stale context.

Routing · new

Hybrid routing

Routes simple tasks to a local model. Complex reasoning escalates to your paid provider. Works in any MCP-compatible IDE.

04 · How

The pipeline that makes code searchable by intent.

Index project knowledge, chunk it by meaning, retrieve what matters, and keep useful state available for future agent steps.

01 · Watch

Watch

Detect file and document changes without repeatedly reprocessing everything.

02 · Parse

Parse

Understand code structure at the level of symbols, modules, and useful boundaries.

03 · Chunk

Chunk

Create small context blocks that can be reused across agent steps.

04 · Embed

Embed

Represent meaning so agents can search by task intent, not just keywords.

05 · Store

Store

Keep vectors, metadata, permissions, and freshness state together.

06 · Retrieve

Retrieve

Return the smallest useful context for the current question.

05 · Install

One command to get started.

Run directly from PyPI with uvx, or install permanently. Requires Python 3.11+.

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

# Or install permanently
pip install ocp-server
pip install ocp-client

# Docker
docker pull ghcr.io/rajesh1213/ocp:latest
Python 3.11+ required SQLite works out of the box. For PostgreSQL + pgvector, set OCP_DATABASE_URL. A Docker Compose file is included in the repo.
PyPI — server

pypi.org/project/ocp-server

PyPI — client

pypi.org/project/ocp-client

Docker image

ghcr.io/rajesh1213/ocp:latest

Spec

RFC draft at spec/OCP-0001.md in the repo · CC-BY 4.0

06 · Routing

Stop paying for every AI request.

OCP scores each request by complexity and routes it automatically — simple tasks run on a local model in under 100ms, complex reasoning escalates to your paid provider. Your IDE works exactly the same.

Faster

Explain, search, summarise — answered locally in under 100ms. No round-trip to the cloud required.

$

Cheaper

Only tasks that genuinely need complex reasoning hit your paid API. Routine requests never leave your machine.

🔒

Private

Code never leaves your machine for simple tasks. Local model, local inference, local result.

07 · Integrations

Works with any MCP-compatible client.

Copy-paste config snippets exist for the most common runtimes. Full guide in docs/integrations.md.

⌨️

Claude Code (VS Code / JetBrains)

Add to .mcp.json in the project root.

{ "mcpServers": { "ocp": { "command": "uvx", "args": ["ocp-server"], "env": { "OCP_DB_PATH": "${workspaceFolder}/.ocp.db", "OCP_LOCAL_MODEL": "llama3.2", "OCP_OLLAMA_URL": "http://localhost:11434", "OCP_ROUTE_THRESHOLD": "0.5" } } } }
🖥️

Claude Desktop

Add to claude_desktop_config.json.

{ "mcpServers": { "ocp": { "command": "uvx", "args": ["ocp-server"], "env": { "OCP_LOCAL_MODEL": "llama3.2", "OCP_OLLAMA_URL": "http://localhost:11434", "OCP_ROUTE_THRESHOLD": "0.5" } } } }
🖱️

Cursor

Add to .cursor/mcp.json — Cursor picks it up automatically.

{ "mcpServers": { "ocp": { "command": "uvx", "args": ["ocp-server"], "env": { "OCP_LOCAL_MODEL": "llama3.2", "OCP_OLLAMA_URL": "http://localhost:11434", "OCP_ROUTE_THRESHOLD": "0.5" } } } }
🌐

HTTP / SSE

Remote agents connect via Docker over SSE. Pass env vars in the container.

# Docker with routing enabled docker run \ -e OCP_LOCAL_MODEL=llama3.2 \ -e OCP_OLLAMA_URL=http://host.docker.internal:11434 \ -e OCP_ROUTE_THRESHOLD=0.5 \ -p 8000:8000 \ ghcr.io/rajesh1213/ocp:latest

Embedding & storage backends

Swap backends without changing your application code.

Embedding backends

Hash n-gram Built-in, no extra deps, keyword-level quality Default
FastEmbed BAAI/bge · pip install fastembed Semantic
OpenAI Set OCP_EMBEDDER=openai + OPENAI_API_KEY Semantic

Storage backends

SQLite Zero config, single file, works immediately Default
PostgreSQL + pgvector Set OCP_DATABASE_URL · Docker Compose included Production
08 · Economics

Less repeated context means lower cost and more useful reasoning.

The numbers below illustrate the shape of the savings using a worked scenario, not a measured benchmark. They show why a retrieval layer matters structurally.

~95%

Less repeated input

Agents retrieve focused context instead of receiving the full codebase every step.

27×

More steps

Reducing repeated input leaves more room for multi-step planning and execution.

Index once

The indexing cost is amortised across many future sessions and agents.

Token budget per agent step — illustrative example

A medium codebase, one agent step. Output tokens not included.

Illustrative scenario, not a benchmark Assumes a ~65k-token codebase dump replaced by ~2.2k of retrieved chunks, GPT-4-class input pricing of $3 / 1M tokens, and a 200k-token context window. Your repo and model will shift these numbers. Real benchmarks will follow as the project matures.
ComponentWithout OCPWith OCPNotes
Codebase dump65,0000Replaced by retrieved chunks
Retrieved chunks0~2,200Fetched on demand per step
Tool schemas12,000600Only called tools included
System prompt2,000400No code context needed in prompt
Session summary0300Replaces growing history
Conversation history3,000600Offloaded to session state
Total per step82,0003,700−95.5%
Cost per 100 steps$24.60$1.11$23.49 saved
Steps before 200k limit25427× more
09 · Open

Vendor-neutral, self-hosted, model-agnostic.

OCP is designed to be a practical open context layer — not a closed memory silo tied to any model provider, agent framework, or cloud vendor.

A

Open specification

RFC draft at spec/OCP-0001.md. CC-BY 4.0. Any team can implement or extend it.

B

Free reference implementation

Self-hosted, single-binary install. Apache-2.0. Inspect, run, and adapt it freely — no cloud dependency for the core server.

C

Model-neutral

Works across hosted models, local models, IDEs, and any MCP-compatible client — today and with future clients you haven't tried yet.

10 · Roadmap

Context first. Governance follows naturally.

Because OCP sits in the retrieval path, every chunk of context an agent used can be logged, attributed, and audited. That makes it a natural foundation for AI Act compliance work — which is where a paid governance layer comes in later.

Protocol ✓ Done Spec v0

Minimal, vendor-neutral surface — endpoints, scopes, session state. RFC draft at spec/OCP-0001.md.

Server ✓ Done Reference impl

Free, self-hosted, single-binary install. Inspect and adapt freely. 44/44 conformance tests passing.

Integrations ✓ Done MCP server

Plugs into any MCP-compatible IDE or agent runtime. Config snippets for Claude Code, Claude Desktop, and Cursor.

Governance Later Audit & AI Act

Paid layer for compliance trails, risk flags, and regional checks. Context first — compliance follows naturally.