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.13" # 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)
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:
- the passport in the request
_metais verified against the principal'sdid:key, its audience and its validity window; - the agent's RFC 9421 signature is verified over the canonical arguments, this tool's resource and the passport hash;
- the action, the resource and the spending cap (
amount <= max_per_tx, in the right unit) are checked against the envelope; - the signed idempotency key is claimed, so a retry returns the cached receipt instead of paying twice.
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.13
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 |
|---|---|---|---|---|
| living_agents-0.4.13.tar.gz | 56.7 kB | Without provenance | Details for living_agents-0.4.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| living_agents-0.4.13-py3-none-any.whl | Python 3 | none | any | Details for living_agents-0.4.13-py3-none-any.whl |
Total release size: 92.1 kB
Release files / living_agents-0.4.13.tar.gz
| Download URL | living_agents-0.4.13.tar.gz |
|---|---|
| Size | 56.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e4c54186712a2061f6dfcf5f2d093e39686f5155bb2cfe0b76c744a259e52f5
|
|
BLAKE2b-256 checksum How to use checksums |
de7bc0dc45280942f6876b71348f3fee0987c59b95d41809772d268df086c329
|
| 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.13-py3-none-any.whl
| Download URL | living_agents-0.4.13-py3-none-any.whl |
|---|---|
| Size | 35.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8bb9a93e2e5ff95760684cdfebedef9b22e817a4ec0d744b782ef66b525e1e84
|
|
BLAKE2b-256 checksum How to use checksums |
3aaf92a9e3b816d3af1607288b26fd0ad7c60a123f6576521a5d6dc831a9f750
|
| 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.13
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.