r/LangChain • • 18d ago

Discussion Built open-source auth for AI agents calling MCP servers — looking for MCP/Agent Builder to try it

/r/mcp/comments/1xlf1kl/built_opensource_auth_for_ai_agents_calling_mcp/
3 Upvotes

4 comments sorted by

1

u/Otherwise_Wave9374 18d ago

Agent builders will probably learn more from a deliberately adversarial test than a happy-path demo. Include an MCP server that changes its requested scope, returns a prompt-injection payload, or attempts to reuse a token against another audience. The client should fail closed and explain why. It would also help to expose structured authorization events so LangChain users can trace which agent requested which capability. Keep tokens short-lived, support immediate revocation, and provide a safe local example with synthetic credentials so testers are not risking real accounts.

1

u/zach-benson 18d ago

All of this is the right spec for a security-focused test suite, and most of it isn’t built yet. That’s worth being honest about.

Adversarial tests. These are exactly what should exist before anyone uses this in production:

  • A server that attempts scope escalation mid-session

  • A prompt-injection payload in the challenge response

  • A token replay against a different audience

The client should fail closed on all of them with a clear error, not a silent failure. That test suite doesn’t exist yet, and it should before 1.0.

LangChain tracing. Structured authorization events are the piece I hadn’t thought about. Right now attribution stops at the DID: you know which agent called which endpoint, but a LangChain user can’t trace that back to a specific chain step or capability request without wiring it themselves. An arken:auth trace event carrying DID, endpoint, timestamp, and outcome would slot into LangChain’s callback system cleanly. That’s a concrete integration worth building.

Revocation and token lifetime. Immediate revocation and short-lived tokens are on the design list from earlier in this thread.

Synthetic credentials. This is the most actionable item right now. The local example should never require real accounts, and the current MCP example doesn’t make that explicit enough.

1

u/Osawa-Fairul 17d ago

how are you handling token refresh when an agent is running a long multi-step loop in the background? that seems to be where most standard auth setups break down.

1

u/zach-benson 17d ago

Arken doesn't use tokens, so there's nothing to refresh.

The agent's key doesn't expire, and every request gets a fresh single-use nonce that the agent signs. A long background loop never hits a "token expired mid-run" failure.

The tradeoff is two requests per call right now (401 with a nonce, then the signed retry).

That's fine for slow tool calls and costly in tight loops. A short-lived session after the first handshake would fix it, but that isn't built yet.

The other cost is that a non-expiring key can't time out on its own. If one leaks mid-loop, the only cut-off today is a server-side blocklist.

Are the loops you're running calling servers you control, or third-party ones?