Skip to content

Hold MCP connections only while work runs (fix DO hibernation / free-tier burn) - #13

Merged
DIodide merged 1 commit into
mainfrom
fix/mcp-hibernation
Aug 25, 2026
Merged

Hold MCP connections only while work runs (fix DO hibernation / free-tier burn)#13
DIodide merged 1 commit into
mainfrom
fix/mcp-hibernation

Conversation

@DIodide

@DIodide DIodide commented Aug 25, 2026

Copy link
Copy Markdown
Member

Live MCP client connections prevent Durable Object hibernation — objects stayed resident ~7h/day each with near-zero traffic, exhausting the free tier's 13,000 GB-s daily cap every day (verified by per-object analytics and a controlled experiment: removed connection → 0s active). Connections now open right before a turn or tool call, release when it ends, and are swept on wake.

https://claude.ai/code/session_01MKLJUWk6biNAKXupHTTWn5

A Durable Object holding live MCP client connections never hibernates:
it stays resident — and billed — around the clock even with zero
traffic, while an identical object without connections sleeps at once.
Measured on production: ~109,000 active seconds/day from a few hundred
requests, tripping the free tier's 13,000 GB-s daily cap every day
(each object ~7h/day); a controlled experiment showed 0s active for an
idle object whose connection had been removed vs 170–900s+ for ones
that kept it.

Connections are now opened just before a turn (setup(..., {connect}) —
called by the client before send/retry) or on demand for direct tool
calls, released when the turn ends (onChatResponse/onChatError, and
after callAppTool), and swept on every wake (onStart) to clear leftovers
restored from a previous isolate. A Google connection mid-consent is
kept, since its OAuth state rides on the connection row. My apps shows
"on" for engine apps (no live-connection claim) and "connected" for
Google once tokens exist.

Claude-Session: https://claude.ai/code/session_01MKLJUWk6biNAKXupHTTWn5
@DIodide
DIodide merged commit 2c36d91 into main Aug 25, 2026
2 checks passed
@DIodide
DIodide deleted the fix/mcp-hibernation branch August 25, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant