Skip to main content

HCP — Harness Context Protocol

MCP standardized how an agent talks to a tool. HCP standardizes the harness around the agent: state that outlives the context window, verification that doesn't trust the agent's own report, least-privilege scope, and a session lifecycle that survives a process restart.

pip install hcp-protocol && python -m hcp.demo

All four HCP subsystems running for real, in under a second

That's real code, not staged output — scope denying by default, a false claim caught by independent verification next to a real fix that passes, and a brand-new process recovering a session's task and findings given nothing but a session id. Source: src/hcp/demo.py.

Full spec: spec/SPEC.md. Two reference SDKs: Python (this package) and TypeScript — both implement the same four interfaces against the same JSON wire format, so a state file is byte-identical in shape regardless of which SDK wrote it, and interop/ proves a session can actually hand off between them.

The four interfaces

Interface Module Answers
State hcp.state.StateStore Where does session state live outside the model's context?
Verification hcp.verification.Verifier Who checks the agent's work is actually correct?
Scope hcp.scope.ScopeEnforcer What is this session allowed to touch, and who enforces it?
Lifecycle hcp.lifecycle.SessionLifecycle How does a session start, checkpoint, and end?

Each is an abstract interface with reference implementations under hcp.reference — a local JSON file store, an in-memory scope table, a lifecycle built on top of the state store, and two verifiers: SubprocessVerifier (run a local command, check its exit status — good for "does the test suite pass") and HttpVerifier (hit a live endpoint, check its status and response body — good for "did the patched service actually stop leaking data"). Swap any of them out without touching the others.

Development setup

pip install -e ".[dev]"
python examples/minimal_harness.py
pytest
from hcp.reference import JsonFileStateStore, SubprocessVerifier, TableScopeEnforcer, FileLifecycle
from hcp.validator import validate

state = JsonFileStateStore("state.json")
harness = {
    "state": state,
    "verification": SubprocessVerifier(),
    "scope": TableScopeEnforcer(),
    "lifecycle": FileLifecycle(state),
}

report = validate(harness)
assert report.conformant

Status

v0.1 draft. The interfaces are the contract; the reference implementations are intentionally minimal and meant to be replaced (a git-backed StateStore, a sandboxed ScopeEnforcer, a CI-integrated Verifier, etc.) without breaking anything that depends on the interface alone.

The TypeScript SDK mirrors this one field-for-field on the wire (snake_case duration_s, session_id, etc., even though that's not idiomatic TS) but checks conformance differently: Python's validate() does a nominal isinstance check via ABCs; TypeScript's does structural duck-typing, since interfaces are erased at runtime.

interop/ now proves cross-language interop for all four interfaces, not just two: steps 1-3 hand off a real session between Python and Node.js through nothing but shared state.json (StateStore, SessionLifecycle); steps 4-5 have Python grant a Scope and run real Verifier checks, then have Node independently reconstruct the scope and re-evaluate it — including a check Python's script never ran — and assert both VerificationReports decode with the right types. What's still open: interop across different agent runtimes, not just these two reference SDKs of the same protocol (see Open Problem #4 in the course site).

License

MIT

Metadata

Release files for hcp-protocol 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hcp-protocol 0.1.1
File Size Uploaded Provenance Actions
hcp_protocol-0.1.1.tar.gz 71.2 kB With provenance Details for hcp_protocol-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hcp-protocol 0.1.1
File Interpreter ABI Platform Actions
hcp_protocol-0.1.1-py3-none-any.whl Python 3 none any Details for hcp_protocol-0.1.1-py3-none-any.whl

Total release size: 84.7 kB

Release files / hcp_protocol-0.1.1.tar.gz

Download URL hcp_protocol-0.1.1.tar.gz
Size 71.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e196896c2c416d65fef0f5f770707b3c5c5eaca2c676d0aced0324586f092ab8
BLAKE2b-256 checksum
How to use checksums
fb60405d4e1965ad85bd2f9ab3431052ffd7d3a1efab336c65b342f0a6decb19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 27, 2026.

Transparency log

Release files / hcp_protocol-0.1.1-py3-none-any.whl

Download URL hcp_protocol-0.1.1-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d25f834e61c722e123565511515f4eab1f88803a12f430a63b92749656ccc36c
BLAKE2b-256 checksum
How to use checksums
b78179fbd63f86fd9f9cebff31a533942d5be98040f4c00d3130a4263e5ed057
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 27, 2026.

Transparency log

Security for hcp-protocol 0.1.1

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.

Select from 2 files

Attestation for hcp_protocol-0.1.1.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 Oct 27, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page