Skip to content

fix(mcp): scope error teardown to the erroring session; serialize ref… - #3468

Open
joestump-agent wants to merge 1 commit into
charmbracelet:mainfrom
joestump-agent:upstream-pr/mcp-error-teardown-scope
Open

fix(mcp): scope error teardown to the erroring session; serialize ref…#3468
joestump-agent wants to merge 1 commit into
charmbracelet:mainfrom
joestump-agent:upstream-pr/mcp-error-teardown-scope

Conversation

@joestump-agent

Copy link
Copy Markdown
Contributor

…reshers

A StateError transition closed and deregistered whatever session was currently in the sessions map. When the error was reported by a stale path — a refresh whose list call failed after a renewal had already swapped in a fresh session — the teardown killed the healthy replacement and wiped its tool/prompt/resource registrations, leaving the server 'connected' with no capabilities until the next renewal.

updateState now closes exactly the session the error was reported against: if the registry holds a different (newer) session, it and its registrations are left alone. Error transitions with no specific session (connect failures) keep the old tear-everything behavior. The published state never carries a dead session pointer.

RefreshTools/RefreshPrompts/RefreshResources now run under the same per-server renew lock as session renewal, so the registered session cannot be swapped between their Get and their state update, and they report failures against the exact session that failed.

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

…reshers

A StateError transition closed and deregistered whatever session was
currently in the sessions map. When the error was reported by a stale
path — a refresh whose list call failed after a renewal had already
swapped in a fresh session — the teardown killed the healthy
replacement and wiped its tool/prompt/resource registrations, leaving
the server 'connected' with no capabilities until the next renewal.

updateState now closes exactly the session the error was reported
against: if the registry holds a different (newer) session, it and its
registrations are left alone. Error transitions with no specific
session (connect failures) keep the old tear-everything behavior. The
published state never carries a dead session pointer.

RefreshTools/RefreshPrompts/RefreshResources now run under the same
per-server renew lock as session renewal, so the registered session
cannot be swapped between their Get and their state update, and they
report failures against the exact session that failed.

Co-authored-by: Joe Stump <joe@stu.mp>
@charmcli

Copy link
Copy Markdown
Contributor

Thank you for your submission. We really appreciate it! Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request comment same as the below format.


I have read the Contributor License Agreement (CLA) and hereby sign the CLA.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants