Skip to main content

Living Agents Protocol (LAP) — Python Reference & FastMCP Middleware

Official Python implementation of the Living Agents Protocol (LAP):

  • LIP-1 Agent Passport: Ed25519 JWS identity documents with responsible-human principal binding.
  • LIP-3 Scope Algebra (v0.4): capability attenuation, a registered action DAG, segment-wise resource matching with terminal-only wildcards, two-dimensional caps, and exact-integer budget conservation.
  • LIP-4 Micro-Core: server-side authorization middleware, RFC 9421 request signature validation, signed tripartite receipts, and the MCP extension binding io.github.atharnouman/lap-microcore (passport and call signature in request _meta, receipt in result _meta, idempotent retries) for the official MCP SDK, 1.x and 2.x.

Zero runtime dependencies beyond cryptography.


Installation

pip install living-agents            # the library (one dependency: cryptography)
pip install "living-agents[mcp]>=0.4.14"   # plus the official MCP SDK, 1.x or 2.x (0.4.12 added the MCP extension binding; 0.4.13 refuses negative and non-integer amounts at the cap; 0.4.14 recognises a retried key before the envelope and refuses a key reused for a different request)

From a checkout, for development:

cd lap-python
pip install -e ".[dev]"

MCP tool server integration (one decorator)

Works with FastMCP (mcp 1.x) and MCPServer (mcp 2.x) alike; the MCP SDK is imported lazily, so import living_agents stays dependency-free.

Complete runnable example (server + client, verified in CI on both SDK lines): ../examples/mcp-server/, the 15-minute tutorial. Specification: the MCP extension draft (io.github.atharnouman/lap-microcore).

from mcp.server.fastmcp import FastMCP          # mcp 1.x; on mcp 2.x: from mcp.server.mcpserver import MCPServer
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from living_agents import IdempotencyCache, did_key_from_raw_public_key, lap_tool

mcp = FastMCP("billing-tools")
server_key = Ed25519PrivateKey.generate()                 # signs receipts; persist it in production
server_did = did_key_from_raw_public_key(server_key.public_key().public_bytes_raw())

@lap_tool(
    mcp,                                                  # registers the tool, in place of @mcp.tool()
    action="finance:pay",
    resource="mcp://tools.example.com/billing/pay",
    amount_param="amount",
    unit_param="unit",
    server_private_key=server_key,
    server_did=server_did,
    expected_aud="did:web:tools.example.com",             # the audience every passport must name
    idempotency_cache=IdempotencyCache(),                 # a mutating tool: a signed idempotency key is mandatory
)
def pay_invoice(invoice: str, amount: int, unit: str = "USD") -> dict:
    """Pay a vendor invoice up to authorized envelope limits."""
    return {"status": "paid", "invoice": invoice, "amount": amount}

When an agent calls pay_invoice, before your function runs:

  1. the passport in the request _meta is verified against the principal's did:key, its audience and its validity window;
  2. the agent's RFC 9421 signature is verified over the canonical arguments, this tool's resource and the passport hash;
  3. the action, the resource and the spending cap (amount <= max_per_tx, in the right unit) are checked against the envelope;
  4. the signed idempotency key is recognised before the envelope and claimed before execution, so a retry returns the stored receipt (marked replayed) instead of paying twice, even after the passport was replaced; the same key for a different request is refused.

A refusal reaches the caller as a tool error with its typed LAP_ERR_* reason. A success returns a CallToolResult whose _meta carries a receipt signed by the server; the client verifies it with verify_receipt. The transport-independent decorator @verify_envelope remains available for servers that carry the passport and signature in HTTP headers (LIP-4).


Running Cross-Language Tests

Run the complete test suite:

pytest tests/ -v

The test suite validates byte-for-byte reproducibility against the shared deterministic test vectors (output/lip/test-vectors/vectors.json), ensuring full interoperability with the Node.js reference implementation.


License

Apache-2.0. Part of the Living Agents Protocol project.

Metadata

Release files for living-agents 0.4.14

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

Source distribution (sdist)

Source distribution for living-agents 0.4.14
File Size Uploaded Provenance Actions
living_agents-0.4.14.tar.gz 70.9 kB Without provenance Details for living_agents-0.4.14.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for living-agents 0.4.14
File Interpreter ABI Platform Actions
living_agents-0.4.14-py3-none-any.whl Python 3 none any Details for living_agents-0.4.14-py3-none-any.whl

Total release size: 113.0 kB

Release files / living_agents-0.4.14.tar.gz

Download URL living_agents-0.4.14.tar.gz
Size 70.9 kB
Tags Source
SHA-256 checksum
How to use checksums
21c4fbf13a0f8e578cd24512c6dc715743af5229edc26b5196d5fac1ccffa48c
BLAKE2b-256 checksum
How to use checksums
55e6070249229847ab1891021d8c68e9553057f6e7eee448874a400ee77fc2e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.6

Release files / living_agents-0.4.14-py3-none-any.whl

Download URL living_agents-0.4.14-py3-none-any.whl
Size 42.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
913f0b05a43d083e139a284ec0d561a7855ca88f785a79bae1e2c3842f9b1531
BLAKE2b-256 checksum
How to use checksums
1471c82cd127bbe58699bd83d6189684bfba99f48dd61e76d397b4472c151138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.6

Security for living-agents 0.4.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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