macp-sdk-python
Python SDK for the MACP Rust runtime.
What this package does
- Connects to the Rust runtime over gRPC
- Provides typed session helpers for all 5 standard coordination modes
- Maintains in-process projections for local state tracking
- Supports envelope builders, retry helpers, and structured logging
Important runtime boundary
This SDK calls the Rust runtime. The runtime does not call into this Python package. If you need runtime-driven business logic, run a Python agent/orchestrator as a separate process and let it communicate with the runtime over MACP transport.
Install
pip install macp-sdk-python
Quick start
Production (Bearer + TLS)
from macp_sdk import AuthConfig, DecisionSession, MacpClient
# TLS is the default; Bearer + expected_sender binds the session to this identity.
client = MacpClient(
target="runtime.example.com:50051",
auth=AuthConfig.for_bearer("tok-coord", expected_sender="coordinator"),
)
Local dev (runtime started with MACP_ALLOW_INSECURE=1)
client = MacpClient(
target="127.0.0.1:50051",
allow_insecure=True, # dev only
auth=AuthConfig.for_dev_agent("coordinator"),
)
Driving a decision
session = DecisionSession(client)
session.start(
intent="pick a deployment plan",
participants=["coordinator", "alice", "bob"],
ttl_ms=60_000,
)
session.propose("p1", "deploy v2.1", rationale="tests passed")
session.evaluate(
"p1", "approve", confidence=0.94, reason="low risk",
sender="alice", auth=AuthConfig.for_dev_agent("alice"),
)
session.vote(
"p1", "approve", reason="ship it",
sender="bob", auth=AuthConfig.for_dev_agent("bob"),
)
winner = session.decision_projection.majority_winner()
if winner and not session.decision_projection.has_blocking_objection(winner):
session.commit(
action="deployment.approved",
authority_scope="release-management",
reason=f"winner={winner}",
)
Supported modes
| Mode | Session Helper | Projection | Example |
|---|---|---|---|
| Decision | DecisionSession |
DecisionProjection |
examples/decision_smoke.py |
| Proposal | ProposalSession |
ProposalProjection |
examples/proposal_negotiation.py |
| Task | TaskSession |
TaskProjection |
examples/task_delegation.py |
| Handoff | HandoffSession |
HandoffProjection |
examples/handoff_escalation.py |
| Quorum | QuorumSession |
QuorumProjection |
examples/quorum_approval.py |
Development
# Setup
make setup # pip install -e ".[dev,docs]"
# Quality
make lint # ruff check + ruff format --check
make fmt # ruff format
make typecheck # mypy strict
make test # unit tests + coverage gate (85% branch, from pyproject)
make test-integration # integration tests (auto-skip without a running runtime)
make test-all # lint + typecheck + all tests
make coverage # HTML + terminal coverage report
# Build
make build # build sdist + wheel, then twine check
# Proto definitions (provided by macp-proto package)
make dev-link-protos # link local proto package for development
For local development against the runtime:
export MACP_ALLOW_INSECURE=1
cargo run # in the runtime repo
Since runtime v0.5.0, a runtime with no authentication configured
(MACP_AUTH_TOKENS_* / MACP_AUTH_ISSUER unset) refuses to start unless
MACP_ALLOW_INSECURE=1 is set, and the published Docker image no longer
bakes that env in — pass it explicitly for local dev (as above and in the
docker run command in CLAUDE.md).
Dev-agent auth rides the standard Authorization: Bearer header — the
runtime's dev_authenticate fallback binds the token value verbatim
as the sender.
Documentation
Full docs available in docs/ — build with mkdocs serve after make setup.
Architecture boundary
This SDK is a thin typed client library. It provides:
- Typed state models and action builders
- Session helpers (
propose(),vote(),commit()) - Local state projections (because
GetSessionreturns metadata only)
Business logic — voting rules, AI decision heuristics, policy enforcement — belongs in the orchestrator/agent layer above the SDK.
Known runtime limitations
GetSessionreturns metadata only (not mode state/transcript) — hence the local projection pattern; useStreamSession+send_subscribefor the full transcriptStreamSessionis scoped to one session per stream; useMacpStream.send_subscribe(session_id)(RFC-MACP-0006-A1, since SDK 0.2.3 /macp-proto 0.1.2) to replay accepted history before live broadcast- For cross-session observability, use
MacpClient.list_sessions()andSessionLifecycleWatcher(SDK 0.3.0) to enumerate active sessions and streamCREATED/RESOLVED/EXPIRED/CANCELLED/SUSPENDED/RESUMEDlifecycle events - Pause and cancel sessions with
MacpClient.suspend_session()/resume_session()/cancel_session()(SDK 0.4.0 /macp-proto 0.1.3). A suspended session is non-terminal and rejects messages until resumed; an acceptedcancel_session()now terminates asCANCELLED(previously surfaced asEXPIRED) ListRootscurrently returns an empty list andWatchRootsidles — the runtime does not yet populate roots- Business policy (majority, quorum, veto) belongs in your orchestrator/policy layer
Metadata
Release files for macp-sdk-python 0.13.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 | |
|---|---|---|---|---|
| macp_sdk_python-0.13.0.tar.gz | 93.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| macp_sdk_python-0.13.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 198.7 kB
Release files / macp_sdk_python-0.13.0.tar.gz
| Download URL | macp_sdk_python-0.13.0.tar.gz |
|---|---|
| Size | 93.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c69833451dd4ee9ebcd423ed70ad7acbcfcd399981762dc2d1eb4e863fe1fdb6
|
|
BLAKE2b-256 checksum How to use checksums |
f92908ce37b3e8b416232d53ac95d25add4a95993da9999f7e9fcfa3b9a19454
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 1, 2026.
Transparency logRelease files / macp_sdk_python-0.13.0-py3-none-any.whl
| Download URL | macp_sdk_python-0.13.0-py3-none-any.whl |
|---|---|
| Size | 104.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c6a910bc4360ef7862ed28b350882e8c948d67c15e9e1e1bce1606f7e94abe8
|
|
BLAKE2b-256 checksum How to use checksums |
e8df716fc3208369790ade752f5d100a0c0cf9698e08b9bd0744aa70f66a323b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 1, 2026.
Transparency logSecurity for macp-sdk-python 0.13.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 macp_sdk_python-0.13.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 Oct 1, 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.