agentid-mcp (Python)
Drop-in middleware for Python MCP servers that verifies AgentID passports and enforces tool-level authorization locally, before a tool handler runs.
Install
Not yet published. From the repository root:
python3 -m venv .venv && source .venv/bin/activate
python -m pip install -e ./sdks/python -e ./middleware/mcp-python
For local development from this repo:
cd middleware/mcp-python
python -m venv .venv && source .venv/bin/activate
pip install -e ../../sdks/python -e ".[dev]"
pytest
Usage
from agentid_mcp import AgentIDMiddleware, ToolPolicy
middleware = AgentIDMiddleware(
resolve_key=keyring.get, # issuer id -> Ed25519 public key
audience="mcp://tools.acme.internal",
policies={
"sql_read": ToolPolicy(capability="tool:sql_read"),
"sql_write": ToolPolicy(
capability="tool:sql_write",
require_human_approval=True,
),
},
)
decision = middleware.authorize(
tool="sql_read",
headers={"X-Agent-Passport": passport_token},
)
if not decision.allowed:
raise PermissionError(f"{decision.code}: {decision.error}")
Credentials are read from HTTP-style headers (X-Agent-Passport,
X-Delegation-Chain) or, when headers are unavailable, from the MCP request
_meta object under agentid.passport and agentid.chain.
Guarding a handler
@middleware.guard("sql_read")
def sql_read(payload, *, decision=None):
return run_query(payload["q"])
The decorator authorizes before the handler runs and raises PermissionError
on denial.
Behavior
- Fail-closed: any verification failure denies the call with a stable
ErrorCode(see SPEC.md §7). - Unknown tools are denied unless a
default_policyis configured. - Caveats from the delegation chain are evaluated against trusted request
context (
tool,region,calls). The actual tool name is set by middleware. - Human approval requires a server-owned
approve_request(subject, tool)callback; a request field such ashuman_approveddoes not grant approval. - Region policies require a server-supplied region and deny missing regions.
Metadata
Release files for agentid-mcp 0.1.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 |
|---|---|---|---|---|
| agentid_mcp-0.1.0.tar.gz | 6.4 kB | With provenance | Details for agentid_mcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentid_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for agentid_mcp-0.1.0-py3-none-any.whl |
Total release size: 12.6 kB
Release files / agentid_mcp-0.1.0.tar.gz
| Download URL | agentid_mcp-0.1.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a13d2b35f5f624d39060da757c2a6d344ed5c471d544ec7d8f237662bd85cc2
|
|
BLAKE2b-256 checksum How to use checksums |
3fd9752c4a806b3893ef07239dcfbe31c92b39301d23419f707e7fa1222989f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 6, 2026.
Transparency logRelease files / agentid_mcp-0.1.0-py3-none-any.whl
| Download URL | agentid_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
287c7dec48db3d4cf43d6a876a08cbec4718ffa323a276c2348bad729f831186
|
|
BLAKE2b-256 checksum How to use checksums |
670d6bdba4449298160fb2c3295602dfe82ab727ef090000eba2f408e866d518
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 6, 2026.
Transparency logSecurity for agentid-mcp 0.1.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
Both files in this release have been uploaded with provenance metadata.
Attestation for agentid_mcp-0.1.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 Dec 6, 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.