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 @ git+https://github.com/pinheirodps/axg@v0.4.0#subdirectory=sdks/axg-python-sdk"
The PyPI package (pip install axg-python-sdk) is prepared by the release workflow; the changelog announces its first upload.
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.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 | Actions |
|---|---|---|---|---|
| axg_python_sdk-0.4.0.tar.gz | 15.8 kB | With provenance | Details for axg_python_sdk-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| axg_python_sdk-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for axg_python_sdk-0.4.0-py3-none-any.whl |
Total release size: 28.4 kB
Release files / axg_python_sdk-0.4.0.tar.gz
| Download URL | axg_python_sdk-0.4.0.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77e705101d38df9bee984f6c715e2c941d758bf07a8c9750f152cbd4a30bea7a
|
|
BLAKE2b-256 checksum How to use checksums |
50c36011a851c11dc4acf04fc5cf7c421e692b4029e32c19a0caa899d27c1d33
|
| 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 logRelease files / axg_python_sdk-0.4.0-py3-none-any.whl
| Download URL | axg_python_sdk-0.4.0-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9dcdfb68c41c97f03404f3a01e09d0148bf236c7a702339087b70dcf1071ba25
|
|
BLAKE2b-256 checksum How to use checksums |
c5761070fcaa28c727a70340a77daa0e1668b9d449b979ba20a99a00bf9f1f94
|
| 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 logSecurity for axg-python-sdk 0.4.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 axg_python_sdk-0.4.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 24, 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.