Deploy a boundary adapter PEP
Goal: enforce policy at a boundary you control, for an agent you do not control or can't modify, such as a third-party agent or a managed connector. Pick the strongest mode your boundary allows. Enforcement point tradeoffs covers when a boundary adapter beats a sidecar or gateway.
Every decision a boundary adapter makes carries a guarantee_level, so a weaker mode is never
mistaken for full enforcement in the audit log:
| Level | Meaning |
|---|---|
full | Every hop is decided before dispatch |
connector | Only calls through the agent's tool connector are seen |
network | Enforced on the agent's network path (the egress mode, below) |
consent_only | Only consent, identity and revocation, with no per-call decision |
1. Resource-server mode (strongest): you own the tool
The agent's cooperation is irrelevant here. Your tool admits a call only if it carries all of:
- a valid grant for this exact target
- the calling agent's verified identity
- for a privileged tool, a transaction token bound to the exact parameters sent
Add the middleware to your own ASGI app (FastAPI, Starlette):
from agentic_auth.boundary.resource import RequireAgenticAuth
from agentic_auth.verify import HttpAnchors, HttpJwks, InMemoryReplay, Verifier
verifier = Verifier(
issuer_jwks=HttpJwks(f"{CONTROL_PLANE}/.well-known/jwks.json"),
anchors=HttpAnchors(base_url=CONTROL_PLANE, token=AUDIT_READ_TOKEN,
agents=["balance-agent"]),
replay=InMemoryReplay(),
)
await verifier.bootstrap() # once, at startup; every admit after this is offline
app.add_middleware(
RequireAgenticAuth,
verifier=verifier,
target_for=lambda scope: f"mcp://accounts.internal{scope['path']}",
privileged={"mcp://accounts.internal/terminate_account"},
)
A refused call never reaches your handler. It gets a 401 when a credential is missing or
invalid, and a 403 otherwise, either way naming the reason, such as GRANT_MISSING,
IDENTITY_MISSING or TXN_PARAMS_MISMATCH.
Enroll and verify agent identity covers where the
identity comes from. Install with pip install 'authzai[server]'; the verifier underneath
needs only the base authzai.
2. Connector mode: you control the agent's MCP connector
Point the agent's MCP connector at the proxy instead of at the MCP server. The agent's code
doesn't change. The proxy decides every tools/call before forwarding it, and filters
tools/list down to the tools the agent's manifest declares, so the agent never plans around
a tool it can't call.
agentic-auth-boundary mcp-proxy mcp-proxy.yaml
The config has the same shape as the gateway's: pdp_url,
listen_addr and a route_table mapping a path to the real MCP server. A refusal comes back
as a JSON-RPC error carrying the reason, whether it is recoverable, and
guarantee_level: connector.
Methods other than tools/call, such as initialize and tools/list, are relayed without a
decision. From 0.4.0 the proxy strips the client's Authorization, Cookie and
Proxy-Authorization headers from them. If the MCP server needs a credential on those
methods, give the route one of its own:
route_table:
"|/mcp":
url: https://kb.internal
data_class: kb.public
relay_authorization: "Bearer <a credential the MCP server issued to you>"
To let a standard MCP client sign in with your IdP and call through the proxy, see Connect a standard MCP client with OAuth.
3. Network mode (egress proxy): not available yet
A TLS-inspecting egress proxy that is the agent's only route out, for when you control the
network but nothing else. agentic-auth-boundary egress-ca generates the certificate authority
the agent's runtime would trust. The proxy itself does not run yet: egress-proxy says so and
exits. Use connector mode, or resource-server mode where you own the tool.
4. Consent and identity only (weakest)
When you control nothing on the call path, you still have:
- coarse scoping at consent time
- revocation, which verifiers honour within their freshness window
- the audit log at the edge
Report it honestly: decisions made this way carry guarantee_level: consent_only. Say so in
your own integration's documentation too.
Related
- PEP — Boundary adapters
- Verifier library: what
RequireAgenticAuthchecks - Enforcement point tradeoffs
- Enroll and verify agent identity: the identity half of resource-server mode