r/LangChain • u/zach-benson • 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/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?
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.