Title: mcpx: takeover orphans a removed server's upstream HTTP session — never DELETEd, left to expire upstream · Issue #260 · developing-today/code · GitHub
Open Graph Title: mcpx: takeover orphans a removed server's upstream HTTP session — never DELETEd, left to expire upstream · Issue #260 · developing-today/code
X Title: mcpx: takeover orphans a removed server's upstream HTTP session — never DELETEd, left to expire upstream · Issue #260 · developing-today/code
Description: Summary In this repo's pkgs/mcpx copy, a daemon takeover (mcpx upgrade / mcpx daemon --takeover) orphans the upstream streamable-HTTP session of any server that was removed from the configuration between the old and new daemon: the succe...
Open Graph Description: Summary In this repo's pkgs/mcpx copy, a daemon takeover (mcpx upgrade / mcpx daemon --takeover) orphans the upstream streamable-HTTP session of any server that was removed from the configuration b...
X Description: Summary In this repo's pkgs/mcpx copy, a daemon takeover (mcpx upgrade / mcpx daemon --takeover) orphans the upstream streamable-HTTP session of any server that was removed from the configurati...
Opengraph URL: https://github.com/developing-today/code/issues/260
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: takeover orphans a removed server's upstream HTTP session — never DELETEd, left to expire upstream","articleBody":"## Summary\n\nIn this repo's `pkgs/mcpx` copy, a daemon takeover (`mcpx upgrade` / `mcpx daemon --takeover`) orphans the upstream streamable-HTTP session of any server that was removed from the configuration between the old and new daemon: the successor never sends the session-termination `DELETE`, so the session is left to expire on the upstream on its own. `pkgs/mcpx/TODO.md` line 6 records this as known-not-done.\n\nThis is the same defect that was filed as dezren39/nix#390 and fixed there by dezren39/nix PR #391 (merge 723e091); this repo's mcpx copy does not have that fix.\n\n## Evidence (verified on main 54c223ce)\n\n- `pkgs/mcpx/TODO.md:6` — \"An upstream session whose server is removed from the configuration during a takeover is not adopted and expires upstream on its own; it is not DELETEd.\"\n- `pkgs/mcpx/internal/pool/handoff.go` (`pool.Adopt`, ~line 193): HTTP instances are explicitly skipped — `if h.Stdio == nil { if h.HTTP != nil { continue } }` — so a handed HTTP session produces no `Adopted` at all.\n- `pkgs/mcpx/internal/daemon/registry_handoff.go` (`Registry.Adopt`): `AdoptSessions` is only called for pools that match the new configuration; for an unmatched pool only the stdio children become `orphans`, and the HTTP session is dropped on the floor. `Adoption.Attach` therefore has nothing to close for it.\n- `pkgs/mcpx/internal/mcpclient/http.go:588` — `HTTPHandoff` carries only `SessionID` + `Negotiated`: no endpoint URL or headers, so a successor could not construct a transport for the orphaned session even if it wanted to terminate it. `PoolHandoff` (`pool/handoff.go:38`) likewise has no server name for logging.\n- `grep -rn TerminateHTTPSession pkgs/mcpx` — no matches: the termination helper does not exist in this copy.\n- The primitive does exist: `HTTPTransport.Close()` (`mcpclient/http.go:566`) already sends exactly one `DELETE` for its session id — it is simply never invoked for a removed server's session, because no transport is ever built for it.\n\n## Why it matters\n\nStreamable HTTP upstreams hold per-session state (auth context, subscriptions, server-side resources). A config edit that removes a server followed by a routine `mcpx upgrade` silently leaks that session until the upstream's own expiry, and the leak is invisible — nothing is logged. The stdio side of the same handoff handles orphans correctly (children are closed post-commit), so the HTTP side is an asymmetric gap in an otherwise careful protocol.\n\n## Suggested fix (reference: dezren39/nix PR #391)\n\n1. Carry the endpoint in the handoff: add `URL` + `Headers` to `mcpclient.HTTPHandoff` (populated from the transport at `Detach` time; the handoff travels only over the takeover unix socket), and add a `Server` name to `pool.PoolHandoff`.\n2. In `Registry.Adopt`, record the HTTP sessions of pools with no match as orphan sessions (no upstream contact at adopt time).\n3. In `Adoption.Attach` (post-commit only), end each orphan session with exactly one `DELETE` via a `pool.TerminateOrphanedSession` helper built on `mcpclient`'s session termination; `Abort` must leave the predecessor's session untouched. Log success/failure (e.g. `upstream.session.terminated` / `upstream.session.orphaned` with server + session + reason).\n4. Remove the TODO.md line 6 entry.\n\n## Acceptance criteria\n\n- A daemon-level regression test (predecessor hands off a pool whose server is absent from the successor's config, with a live HTTP session) shows exactly one `DELETE` with that session id reaching the upstream after the handoff commits — and zero before the fix.\n- An aborted handoff sends no DELETE (the predecessor keeps its session).\n- A matched pool's sessions are adopted as today (no behaviour change; existing takeover/handoff tests pass).\n- `go test ./internal/pool/ ./internal/daemon/ ./internal/mcpclient/` green in `pkgs/mcpx`.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-18T08:55:01Z","url":"https://github.com/developing-today/code/issues/260"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:10f9af11-3cd0-315e-47e2-beb0f4c5ab50 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA96:1FD7D4:417C97:5813C8:6B061E6E |
| html-safe-nonce | d77370a0aadcfc8855600c5b24d5c9357d7a18f4b3fac904303b38c5402d6f0a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTk2OjFGRDdENDo0MTdDOTc6NTgxM0M4OjZCMDYxRTZFIiwidmlzaXRvcl9pZCI6IjY1Njc5MTY3OTc0NjE2Njc0MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 54fb60b5105c2fedeecdb7e4fd2a76d48dcb8bdb58c3b0404a24ffec9e0b31b6 |
| hovercard-subject-tag | issue:5907857074 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/260/issue_layout |
| twitter:image | https://opengraph.githubassets.com/90fe1c2ffb8e51fd42d317747365d4ebfd7a160e8557e8ecaec99a2a8df6f18b/developing-today/code/issues/260 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/90fe1c2ffb8e51fd42d317747365d4ebfd7a160e8557e8ecaec99a2a8df6f18b/developing-today/code/issues/260 |
| og:image:alt | Summary In this repo's pkgs/mcpx copy, a daemon takeover (mcpx upgrade / mcpx daemon --takeover) orphans the upstream streamable-HTTP session of any server that was removed from the configuration b... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9a7c5824b75ea2ec5e3de73a483229c7bb9f32a774ffd401f010dd9bacf1483d |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b25c3080e84402f75431d8dc7a96b2635219cec7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width