Repository navigation
Close cockpit mcp's tunnel after 90 s idle instead of holding it all session - #113
Merged
Merged
Conversation
…session Each `cockpit mcp` (one per open Claude Code session) held an ssh tunnel to ultra for the session's whole life, each one of the 42 sshd slots launchd allows; on 2026-10-22 idle sessions filled 40 and proxied MCP servers failed to connect. The tunnel now opens when a message needs the daemon and closes after --idle seconds (default 90, 0 = hold) with no call in flight; a long wait_for_checks keeps it open until it returns. Concurrent calls share one open. RouteCache moves into CockpitCore as OnDemandRoute, which `cockpit wait` also uses (without the idle close). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Each
cockpit mcpprocess (one per open Claude Code session) heldssh … -L 127.0.0.1:<port>:127.0.0.1:7878 ultra cat >/dev/nullopen for the whole session. Each of those used one of ultra's 42 sshd slots (launchd's sealed Instances cap). On 2026-10-22 idle sessions filled 40 of them, and every proxied MCP server failed to connect.What
OnDemandRoute(CockpitCore, replaces the CLI'sRouteCache) opens the transport the first time a call needs it. Withidleset, it closes the transport once no call has been in flight for that long.TunnelTransport.open(), which closes whatever was already there.wait_for_checksheld for minutes, keeps the tunnel up.cockpit mcpuses it with a 90 s idle window by default.--idle <s>changes the window, and--idle 0holds the tunnel for the whole session as before.cockpit waituses the same type without an idle close, so its behaviour is unchanged.cockpit sentinelis untouched. It still probes out of band.docs/cockpit/agents.mdanddocs/cockpit/cli.md.Tests
TransportTests.swiftadds 9 tests:invalidatedrops the routeTunnelTransportdrives a fakessh(a python3 forwarder that exits on stdin EOF, like the remotecat). The test checks that the process is gone after the idle window and that a new one answers on the next call.The full suite passes locally:
swift test: 115 testscheck-docs.shnpm test: 1078 pass, 1 skipped (postgres, noTEST_DATABASE_URLlocally)--checkscriptsLive check against ultra
Three
cockpit mcpprocesses ran from this build, withinitializeandtools/listsent to each:catsessions on ultrafleet_statusafter the idle spell answered in 0.3 s on each, through a fresh tunnel.The 13 baseline sessions are the installed (old)
cockpit mcpprocesses and the app. They go away once this is merged and the CLI is reinstalled to~/.local/lib/fleet-cockpit, and sessions restart their MCP servers.🤖 Generated with Claude Code