Skip to main content

Marchward — Python SDK

Runtime authority for AI agents. Gate every tool call through a cost cap, approval gates on irreversible actions, and a tamper-evident audit log.

Python is the primary Marchward SDK — the wedge persona builds on LangGraph / LangChain (both Python). Zero runtime dependencies (stdlib only).

Install

pip install marchward

Quickstart

from marchward import MarchwardClient

marchward = MarchwardClient(api_key="mw_...")   # or set MARCHWARD_API_KEY

decision = marchward.execute(
    service="github",
    tool_name="github.repos.delete",
    arguments={"owner": "acme", "repo": "old-experiment"},
    context={"env": "production"},
)

if decision.allowed:
    do_the_delete()
elif decision.escalated:
    print(f"Paused for approval — review {decision.review_id}")
elif decision.blocked:
    print(f"Blocked: {decision.reason_codes}")

With LangGraph (the persona's stack)

from langchain_core.tools import tool
from marchward import MarchwardClient

marchward = MarchwardClient()

@tool
def delete_repo(owner: str, repo: str) -> str:
    """Delete a GitHub repository."""
    d = marchward.execute(service="github", tool_name="github.repos.delete",
                          arguments={"owner": owner, "repo": repo})
    if not d.allowed:
        return f"Refused by Marchward ({d.outcome.value})."
    # ... real delete here ...
    return "deleted"

How it works (Model B)

You send a logical tool call — service + tool_name + arguments. Marchward resolves the real downstream HTTP request from its tool catalog, governs it, injects your stored credential server-side, and executes it. Your agent holds only MARCHWARD_API_KEY; it never touches downstream credentials. Connect those once in the dashboard (Settings → Connected services).

API

  • MarchwardClient(api_key=None, *, api_url=None, default_agent_id="python-sdk", timeout=30.0, poll_timeout=120.0, poll_interval=0.75)
  • .execute(*, service, tool_name, arguments=None, context=None, agent_id=None, request_id=None, wait=True) -> Decision
  • .get_job(job_id) -> dict — poll one async job manually (for wait=False).
  • Decision: .allowed / .escalated / .blocked / .executed, plus .outcome, .decision_id, .review_id, .reason_codes, .http_status, .raw, .job_id, .execution, .execution_error.

Contract

HTTP Outcome Meaning
200/202 + jobId ALLOW authorized; downstream runs async — the SDK polls the job and fills .execution (set wait=False to poll yourself)
202 + reviewId ESCALATE held for human approval; auto-executes on approve
403 BLOCK refused by policy
401 — MarchwardAuthError (bad/missing/revoked key)

.executed is True only when an ALLOW actually ran its downstream — an ALLOW with no connected credential, a failed downstream, or a still-pending job is allowed-but-not-executed.

Risk classification

Risk is classified by the resolved HTTP method, not the tool name — any DELETE (or a flagged destructive POST like stripe.charges.create) is treated as irreversible and gated, regardless of what the tool is named. So a custom-named destructive tool can't slip past the approval gate.

Tests

cd packages/sdk-python && python -m unittest discover -s tests

Metadata

Release files for marchward 0.1.4

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

Source distribution (sdist)

Source distribution for marchward 0.1.4
File Size Uploaded
marchward-0.1.4.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for marchward 0.1.4
File Interpreter ABI Platform
marchward-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / marchward-0.1.4.tar.gz

Download URL marchward-0.1.4.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
de49e3fef093844a2c314fa99db086f57784fb2ce35420e3ee29d05c6c9fb491
BLAKE2b-256 checksum
How to use checksums
e248ee30f032dc6cbf6951344e62c44a95a89bd6786c059295f36cd494bc040e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / marchward-0.1.4-py3-none-any.whl

Download URL marchward-0.1.4-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e12ba0e1bdc1eb963626ae2e8aa32273911649aa30c7a532f541cb3363ff94b5
BLAKE2b-256 checksum
How to use checksums
dbfd425e48892ead72676ce859a31eeeb4db410a7640c21a987fc11816a8d907
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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