Skip to content

mcp: a connection-local shim transition notifies every session #102

Description

@carldebilly

Follow-up to a review thread on #71 (#71 (comment)).

With DynamicToolCompatibilityMode.DiscoverAndCallShim, one handler serving several initialize-era
sessions transitions each from the intro catalog (discover_tools / call_tool) to the real one on
that session's first tools/list. The transition is connection-local — TryClaimCompatibilityIntro()
is claimed per McpSessionContext, so no session can consume another's intro.

What is not connection-local is the notification. SignalToolListChanged() clears a handler-wide
collection whose SDK subscribers fan out to every attached session, so one session's transition sends
tools/list_changed to every other legacy session and to modern subscribers with no interest in it.

Why this was not fixed in #71

The advertised set a modern client would re-list is unchanged, so there is no invariance consequence;
what leaks is spurious notification traffic. And the whole path sits behind
DynamicToolCompatibility, which is Disabled by default.

It still jars with a release whose subject is connection-scoped state: a connection-local event
fanning out globally is the shape that pull request spent its time removing everywhere else.

Shape

Target request.Server for this one transition rather than the shared routing-change signal. The
guard belongs beside the existing shim tests in Given_McpConcurrentSessions, asserting that a
second session receives no tools/list_changed when the first consumes its intro.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions