The Context Graph Protocol
An open wire protocol for context retrieval. A host asks providers for frames relevant to a goal, under a token budget; each provider returns frames that carry their own origin, their honest cost, and a human-readable citation label.
CGP specifies context retrieval: typed, budgeted, provenance-carrying, consent-gated, conformance-verified frames that a host composes into a prompt. The unit of exchange is a frame, never a blob. A frame states what it is, where it came from, what it costs, when it was true, and how to cite it.
The current revision is contextgraph/1.0-draft. The specification, reference implementation, conformance suite, and SDKs are dual-licensed MIT OR Apache-2.0 and developed in the open at macanderson/context-graph-protocol.
The seven guarantees
Every design decision in the protocol serves one of seven properties. They compose, and the combination is the point — remove any one and the trust model collapses back to the blob-pipe.
- Provenance. Frames carry a chain of origin records — file, URI, range, digest, derivation method — so every passage in a prompt can be traced to its source.
- Budget honesty.
token_costis computed by a canonical rule and the sum across frames must never exceed the query’smax_tokens. Hosts drop the frames of any provider that lies, with a loud report. - Consent enforcement. A provider declares its data flow — reads, writes, egress, egress scopes. A host must never auto-enable an egress provider or transmit a query before consent is recorded.
- Conformance. “CGP conformant” is a machine-checked claim, not a self-attestation.
- Citation. Every frame carries a human-readable
citation_label, so the host can attribute what it used. - Version stability. Versions interoperate if and only if they share a major family; additive changes are minor.
- Temporal validity. Frames may declare
valid_from/valid_to, and queries may pin retrieval to an instant withas_of.
Scope: CGP and MCP compose
CGP does not specify tool invocation — that is the Model Context Protocol’s scope, and CGP will not absorb it. MCP connects tools: an action protocol. CGP connects context: a retrieval-evidence protocol. An agent needing both composes them — CGP frames feed the prompt, MCP tools do the work.
The shape of a session
A host opens with a handshake, the provider answers with its identity and capabilities, and only then do queries flow. Everything is a single JSON envelope per message.
handshake → handshake_ack
query → frames (repeated; correlated by id)
verify → verified (optional, capability-gated)
shutdownContinue with Core concepts for the frame model, or jump straight to the SDK quickstarts to build a provider in TypeScript, Python, or Go.