Skip to main content

AXG Python SDK

Verify AXG Passports before executing an AI-proposed action.

A Passport is AXG's signed proof that an action was authorized for one app, one tenant, one action and one exact payload. This SDK checks all of that, plus the signature, validity window and single use. See Passport for the concepts.

Installation

pip install axg-python-sdk

Requires Python 3.11+ (PyJWT with cryptography is installed with it).

Verify a Passport

Verify against the actionable_payload returned by AXG, and execute exactly that payload.

from axg_python_sdk import AxgVerificationError, InMemoryReplayCache, verify_passport

replay_cache = InMemoryReplayCache()  # share one store (e.g. Redis SET NX) across replicas

try:
    claims = verify_passport(
        passport,
        actionable_payload,
        app_id="support",                       # must match the Passport audience
        tenant_id="acme",                       # optional, recommended
        allowed_action_types=["issue_refund"],  # optional, recommended
        jwks_url="https://axg.example.com/.well-known/jwks.json",
        replay_cache=replay_cache,              # optional: reject a Passport used twice
    )
except AxgVerificationError as exc:
    reject(exc.code)  # never execute on failure
else:
    issue_refund(**actionable_payload)

verify_passport returns the claims (sub, aud, tenant_id, action_type, policy, azp, jti…). Pass public_key= (PEM) instead of jwks_url to verify offline.

Async services

AxgClient keeps a cached JWKS client (keys are refetched only for an unknown kid) and runs the check in a worker thread:

from axg_python_sdk import AxgClient

axg = AxgClient("https://axg.example.com")
claims = await axg.verify_passport(passport, actionable_payload, app_id="support", tenant_id="acme")

MCP tools

Inside an MCP tool, check that AXG authorized exactly this tool call. The gateway puts the Passport and the authorized payload in params._meta (io.axg/passport, io.axg/actionable_payload); every argument the tool received must match the authorized payload.

from axg_python_sdk import verify_mcp_tool_call

claims = verify_mcp_tool_call(
    meta=params_meta,
    tool_name="issue_refund",
    arguments=arguments,
    app_id="support",
    jwks_url="https://axg.example.com/.well-known/jwks.json",
)

Approvals

When AXG answers CONFIRM or SUGGEST, the response carries an approval ticket. After the right person approves, exchange it for a Passport (Human approvals):

from axg_python_sdk import AxgApprovalError, submit_approval

result = submit_approval(
    "https://axg.example.com", api_key,
    ticket=approval["ticket"], actionable_payload=payload,   # exactly what the approver saw
    approver_id="ana", approver_role="end_user",              # outcome="deny" to refuse
)
passport, to_execute = result["passport"], result["actionable_payload"]

AxgClient(base_url, api_key=...).submit_approval(...) is the async variant. Refusals raise AxgApprovalError with AXG's status_code (403 wrong approver, 409 payload or policy changed, 503 AXG unavailable).

Errors

AxgVerificationError.code is one of:

Code Meaning
JWT_ERROR Bad signature, wrong issuer or audience, expired or not yet valid
DECISION_NOT_ALLOWED The token does not carry ALLOW
TENANT_ID_MISMATCH, ACTION_TYPE_MISMATCH Issued for another tenant or action
MISSING_PAYLOAD_HASH, PAYLOAD_TAMPERED The payload is not the one AXG authorized
MISSING_JTI, PASSPORT_REPLAYED The token cannot be checked for replay, or was already used
MISSING_PASSPORT, ARGUMENTS_MISMATCH MCP: no Passport in _meta, or arguments differ from the authorized payload
VERIFICATION_FAILED Any other failure

Compatibility

Verifies Passport v2 (current) and v1 (issued before AXG 0.2). The payload hash uses the same canonical JSON as AXG and the Node SDK, checked against shared test vectors.

Development

pip install -e . && pip install pytest pytest-asyncio
pytest

Metadata

Release files for axg-python-sdk 0.4.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 axg-python-sdk 0.4.1
File Size Uploaded Provenance Actions
axg_python_sdk-0.4.1.tar.gz 15.7 kB With provenance Details for axg_python_sdk-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for axg-python-sdk 0.4.1
File Interpreter ABI Platform Actions
axg_python_sdk-0.4.1-py3-none-any.whl Python 3 none any Details for axg_python_sdk-0.4.1-py3-none-any.whl

Total release size: 28.1 kB

Release files / axg_python_sdk-0.4.1.tar.gz

Download URL axg_python_sdk-0.4.1.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
67f5b00398f6e0d8b8b66a4d61c6db6d23d225c31059d8d3ee71167bd940f192
BLAKE2b-256 checksum
How to use checksums
d94bb50f2e22d67179e3583d0a52fcc01099faf38b2832dd1ba05cdcbb191a9e
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 24, 2026.

Transparency log

Release files / axg_python_sdk-0.4.1-py3-none-any.whl

Download URL axg_python_sdk-0.4.1-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3864043a2805f61f25a84c28c917ce5c76a014aee3ca7e1971f14509b7f638cf
BLAKE2b-256 checksum
How to use checksums
467ae50589ed089a0f030b89f0901badffdaf662787a340b60428e3824e2d237
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 24, 2026.

Transparency log

Security for axg-python-sdk 0.4.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 axg_python_sdk-0.4.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 24, 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.4.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