Repository navigation
Refresh session components on re-registration in ClientSessionGroup - #3716
abhay-2108 wants to merge 1 commit into
Conversation
…odelcontextprotocol#3713) - Evict previous components registered by a session before aggregating new catalog - Exclude session's own components from duplicate collision checks - Guard exit stack cleanup against KeyError for caller-owned sessions - Update docs/client/session-groups.md to document connect_with_session refresh behavior - Add comprehensive tests asserting full internal and public invariants
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3713. If a maintainer assigns you to #3713, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
Fixes #3713
Problem
When re-registering an already-connected caller-owned session with a changed catalog via
connect_with_session(), the internal_sessions[session]reverse index was overwritten while previously registered names in_toolsand_tool_to_sessionwere left behind. Subsequent calls todisconnect_from_server(session)then left orphaned tools in the group.Changes
_aggregate_components(), when re-registering an existing session, its previously registered components are evicted before aggregating the new catalog.del self._session_exit_stacks[session]withif session in self._session_exit_stacks:so caller-owned sessions registering or refreshing to an empty catalog do not encounter aKeyError.docs/client/session-groups.mdunder Adding and removing servers and Recap describingconnect_with_session()refresh and collision behavior.tests/client/test_session_group.pyasserting full invariants acrosstools,prompts,resources,_tool_to_session,_sessions[session], routing, and error behavior.Verification
pytest tests/client/test_session_group.py: 18 passed in 0.40scoverage: 100.00% statement and branch coverage onsrc/mcp/client/session_group.pyruff check .&ruff format --check .: Cleanpyright: 0 errors, 0 warningsAssisted by AI (Antigravity), reviewed and verified by human contributor.