Skip to main content

Python SDK for the MACP Rust runtime

Project description

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
make fmt                # ruff format
make typecheck          # mypy strict
make test               # unit tests
make test-all           # lint + typecheck + all tests
make coverage           # coverage report

# Build
make build              # sdist + wheel

# 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
export MACP_ALLOW_DEV_SENDER_HEADER=1
cargo run   # in the runtime repo

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 GetSession returns metadata only)

Business logic — voting rules, AI decision heuristics, policy enforcement — belongs in the orchestrator/agent layer above the SDK.

Known runtime limitations

  • GetSession returns metadata only (not mode state/transcript) — hence the local projection pattern
  • StreamSession has no late-attach handshake for already-running sessions
  • Business policy (majority, quorum, veto) belongs in your orchestrator/policy layer

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

macp_sdk_python-0.2.1.tar.gz (42.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

macp_sdk_python-0.2.1-py3-none-any.whl (51.3 kB view details)

Uploaded Python 3

File details

Details for the file macp_sdk_python-0.2.1.tar.gz.

File metadata

  • Download URL: macp_sdk_python-0.2.1.tar.gz
  • Upload date:
  • Size: 42.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for macp_sdk_python-0.2.1.tar.gz
Algorithm Hash digest
SHA256 bed6b479d21e924cc177b30cede08c6b780dda4b8d63ca9c076211898309af3a
MD5 9482acda202e0ecf4b6cefbd7470c177
BLAKE2b-256 43e360966a67f2aadc1f4fd3ba27df912bef353a34ab82415b80f4c9bc5a1bd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for macp_sdk_python-0.2.1.tar.gz:

Publisher: publish.yml on multiagentcoordinationprotocol/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file macp_sdk_python-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: macp_sdk_python-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 51.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for macp_sdk_python-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0959b83dc9095cc8b3a768f2851146e07872d2ee5c6d2b867f3b76d90ef5baff
MD5 58426b236e8240d9b390c3d561b68cc1
BLAKE2b-256 c24840b3a232275bd06ca2ede1ad7adc381eaca43d31f4d09ac0498804bb5c23

See more details on using hashes here.

Provenance

The following attestation bundles were made for macp_sdk_python-0.2.1-py3-none-any.whl:

Publisher: publish.yml on multiagentcoordinationprotocol/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page