Skip to main content

MudraID Python SDK

Authenticate AI agents through a linked OAuth machine client and call its approved resource.

Configure a linked machine client

Register an OAuth machine client, bind it to the intended agent, register its public JWK, complete proof of possession, and approve the exact resource/scopes in the correct organization and environment. Linking alone grants no authority. The same workflow works in sandbox and production, subject to server eligibility checks.

Install the SDK and signing dependencies:

pip install mudraid-sdk 'PyJWT>=2.13,<3' 'cryptography>=50'

Set these process environment variables, using your environment's actual values:

Variable Meaning
MUDRAID_CLIENT_ID Linked OAuth client ID
MUDRAID_TOKEN_ENDPOINT HTTPS OAuth token endpoint
MUDRAID_ASSERTION_AUDIENCE Exact assertion audience accepted by that server
MUDRAID_RESOURCE Exact approved resource identifier
MUDRAID_SCOPES Space-separated scopes; omitted/empty requests no scopes
MUDRAID_PRIVATE_KEY_PATH Private key file corresponding to the registered public key
MUDRAID_KEY_ID Registered public key identifier (kid)
from mudraid import Agent

agent = Agent.from_env()  # reads explicit process environment variables
try:
    response = agent.get("https://your-platform.example/tasks", timeout=15)
    response.raise_for_status()
finally:
    agent.close()

Agent.from_env("WEBSITE_API") uses only WEBSITE_API_* values. Missing configuration fails locally; it never switches to another client's variables. For custom/KMS signing, pass signer=my_signer; no local key file is then read. For explicit configuration use Agent(MachineIdentity(...)). MachineAgent remains available as an alias for the same client implementation.

The token endpoint requires HTTPS; HTTP is accepted only for explicit loopback hosts in local development. Userinfo, fragments, whitespace and invalid ports are rejected before signing or network traffic. Assertions are not followed through redirects. Private keys stay local.

Client-secret authentication

Set MUDRAID_AUTH_METHOD=client_secret_basic and MUDRAID_CLIENT_SECRET, along with the client ID, token endpoint, resource and requested scopes. Use the same Agent.from_env() entry point. This method requires no signing key or assertion audience. The server's policy/approval requirements still apply.

For explicit configuration, pass ClientSecretIdentity(client_id=..., token_endpoint=..., resource=..., client_secret=...) to Agent. A credential failure never switches methods or selects a different environment automatically.

Requests, retries and failures

get, head, options, post, put, patch and delete return requests responses. Tokens are cached per identity and refreshed near expiry. Give each resource/scoped identity its own client. Set request timeouts explicitly.

A consequential POST/PATCH without an idempotency key is not blindly retried after an ambiguous transport failure or a resource-server 401. Ambiguous transport failures raise MudraIDExecutionUnknownError; an unreplayed 401 is returned. An idempotent method or server-deduplicated idempotency_key permits one consequence-safe recovery. Passing a key requires the server to actually deduplicate it; the SDK cannot provide that guarantee by itself.

Catch MudraIDError for SDK errors. MudraIDConfigError identifies local setup failures, MudraIDAuthError authentication refusals, MudraIDRevokedError authority refusals, MudraIDRateLimitedError rate limits (with optional retry_after_seconds), and MudraIDBillingFrozenError billing/plan refusals. close() releases connections owned by the client; explicitly supplied token managers/sessions remain caller-owned.

See the runnable linked-client example. Publication does not itself establish a live platform integration or production readiness; qualify the configured grant and protected resource end to end.

Release files for mudraid-sdk 2.0.0

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

Source distribution (sdist)

Source distribution for mudraid-sdk 2.0.0
File Size Uploaded
mudraid_sdk-2.0.0.tar.gz 52.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mudraid-sdk 2.0.0
File Interpreter ABI Platform
mudraid_sdk-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 91.2 kB

Release files / mudraid_sdk-2.0.0.tar.gz

Download URL mudraid_sdk-2.0.0.tar.gz
Size 52.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6e603768bec81a1468ce19a28fbc677a37e86db9cb982903557c1f8ac366e8b6
BLAKE2b-256 checksum
How to use checksums
debdb757e9a0715dbdc66c910fc9e5f3c68d22fe9f8c356ddcc6deba1c0e3a2a
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 Sep 12, 2026.

Transparency log

Release files / mudraid_sdk-2.0.0-py3-none-any.whl

Download URL mudraid_sdk-2.0.0-py3-none-any.whl
Size 38.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
436e2f5a58f4cc5aabf74bae243fba7d8ea0264c583f6f82e405438c9efdc259
BLAKE2b-256 checksum
How to use checksums
71988c561075fd9209b6ee636c9f4e871ad50751df6c2cfcbb0c4a35bb45314b
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 Sep 12, 2026.

Transparency log

Release history Release notifications | RSS feed

2.1.0

2 release files

This release

2.0.0 This release

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.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