Skip to main content

Authorization for AI agents: verifiable, scoped, revocable capability tokens (mandates) with attenuable delegation, for MCP and A2A. The reference implementation of agent authority — zero-dependency TypeScript & Python.

Project description

agent-authority (Python)

Authorization for AI agents — the reference implementation of agent authority (project name: Behalf). Verifiable, scoped, time-bound, revocable capability tokens (mandates) with attenuable, macaroon/biscuit-style delegation, plus MCP and agent-to-agent (A2A) middleware. Capability-based security, OAuth 2.1 on-behalf-of–style grants, and SPIFFE/SVID-style agent identity for multi-agent / LLM systems.

Identical API shape to the TypeScript library, zero dependencies (standard library only). The optional cryptography extra enables a constant-time Ed25519 backend and sealed credentials:

pip install agent-authority          # core, dependency-free
pip install "agent-authority[seal]"  # + sealed credentials / hardened crypto

The five verbs

from agent_authority import create_behalf

b = create_behalf()

# 1. GRANT
mandate = b.grant(
    principal="alice",
    agent="research-agent",
    can=["read:calendar", "spend:usd<=50"],
    expires_in="1h",
)

# 2. AUTHORIZE — raises AuthorizationError if denied
mandate.authorize("spend:usd=20")

# 3. ATTENUATE — narrow for a sub-agent; can only shrink
child = mandate.attenuate(can=["read:calendar"], expires_in="10m")

# 4. REVOKE — kills the mandate and its downstream chain
b.revoke(mandate.id)

# 5. AUDIT — every authorize() wrote a hash-chained record
trail = b.audit(mandate.id)

MCP / A2A middleware

from agent_authority.mcp import with_behalf

server = with_behalf(
    my_tool_server,  # exposes call_tool(name, args, ctx=None)
    policy={
        "send_email": "write:email",
        "read_calendar": "read:calendar",
        "transfer_funds": lambda args: f"spend:usd<={args['amount']}",
    },
    on_denied="throw",  # or "prompt" with on_prompt=...
)

# Pass the caller's mandate on the context:
server.call_tool("read_calendar", {}, {"mandate": mandate})

agent_authority.mcp.behalf_mcp_tools() returns the three discovery tools (request_mandate, present_mandate, check_authority).

Develop

python3 -m unittest discover -s tests   # 28 tests

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

agent_authority-0.1.0.tar.gz (46.0 kB view details)

Uploaded Source

Built Distribution

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

agent_authority-0.1.0-py3-none-any.whl (41.1 kB view details)

Uploaded Python 3

File details

Details for the file agent_authority-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for agent_authority-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1fe53d43b48a6aabfcc03c24397577340ad167b1e0d7ed5f88ffa85c6f5e1f4e
MD5 098285315790ebfbb35ab2e2605d01b3
BLAKE2b-256 40be03b2a2eb904d0d360c7aa1a35158d7b623338560d1648760810a9ac3e853

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_authority-0.1.0.tar.gz:

Publisher: release.yml on novaai0401-ui/agent-authority

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

File details

Details for the file agent_authority-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for agent_authority-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f799cd94007bbb262e5a190eb45a160db2f9ace35d637ce63e2aa7e852053b6f
MD5 a3773fd0971f1b731dd15ee106e23d48
BLAKE2b-256 c75b687892b88886f0e7d7e0e6765041df572132e5aacb545e9bef21d1582d8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_authority-0.1.0-py3-none-any.whl:

Publisher: release.yml on novaai0401-ui/agent-authority

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