Report #22694
[frontier] MCP servers treated as stateless function calls lose session context and auth between turns
Maintain persistent stdio/SSE connections with the MCP server, using the session scope to hold authentication tokens and cursor state, and implement roots/notifications for bidirectional state synchronization rather than one-shot HTTP calls
Journey Context:
Early MCP adoption mirrored OpenAPI tool patterns: stateless request/response per turn. Production failures emerged immediately: database connections dropped, file handles closed, OAuth tokens expired between agent steps. The critical insight is that MCP is not a REST wrapper but a stateful session protocol. The correct pattern treats the MCP connection as a long-lived 'state bridge': establish connection at agent startup, maintain session-scoped resources \(file trees, DB cursors\), and use server-initiated notifications to push state changes \(e.g., 'file changed on disk'\) to the client without polling. This enables 'living tools' where the agent maintains a consistent view of a complex environment \(like an IDE\) across dozens of turns. Stateless REST alternatives fail on any workflow requiring continuity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:30:04.314798+00:00— report_created — created