Skip to content

mcp: add per session list changed notifications - #1511

Merged
guglielmo-san merged 4 commits into
mainfrom
serob/add-per-session-list-changed-notifications
Nov 9, 2026
Merged

guglielmo-san merged 4 commits into
mainfrom
serob/add-per-session-list-changed-notifications

Conversation

@nahapetyan-serob

Copy link
Copy Markdown
Contributor

fixes #1480

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nahapetyan-serob nothing here blocks a merge from my side. With notifyListChanged stubbed to return nil, both new tests fail.

non-blocking: deleting server.go:1749 (ctx := context.WithValue(ctx, idContextKey{}, id)) keeps all of ./mcp green. Only Streamable HTTP routes by that ID (streamable.go:2093), and the tests use in-memory transports. Without it, a notify from inside a tool handler would go out on the tool call's stream, not the listen. A Streamable HTTP test that notifies from a handler would pin it.

$ go test ./... -count=1        # 4325744, go1.27.3 darwin/arm64, GOTOOLCHAIN=local
ok  	github.com/modelcontextprotocol/go-sdk/mcp	39.043s
(all 14 packages ok; go vet ./mcp clean)

$ (notifyListChanged returning nil first) go test ./mcp -run TestNotifyListChanged -count=1
--- FAIL: TestNotifyListChanged_OnlyChosenSession (15.01s)    # tool, prompt, resource
--- FAIL: TestNotifyListChanged_WhenSent (5.11s)               # legacy

$ (server.go:1749 replaced by `_ = id`) go test ./mcp -count=1
ok  	github.com/modelcontextprotocol/go-sdk/mcp	36.084s
# not run: a real HTTP client against a listen stream

Can that test go in with this PR?

Comment thread mcp/server.go Resolved
…thub.com:modelcontextprotocol/go-sdk into serob/add-per-session-list-changed-notifications
@nahapetyan-serob

Copy link
Copy Markdown
Contributor Author

Thanks @chrikrah, added TestNotifyListChanged_StreamableStateless

@guglielmo-san
guglielmo-san merged commit 0e849cb into main Nov 9, 2026
10 checks passed
@guglielmo-san
guglielmo-san deleted the serob/add-per-session-list-changed-notifications branch November 9, 2026 13:08
Tangerg added a commit to Tangerg/go-sdk that referenced this pull request Dec 2, 2026
Brings the fork up to upstream main at 723d70e, which is v1.9.0 plus
fourteen later commits. Upstream changes: modelcontextprotocol#1238, modelcontextprotocol#1511, modelcontextprotocol#1515, modelcontextprotocol#1517,
modelcontextprotocol#1521, modelcontextprotocol#1523, modelcontextprotocol#1524, modelcontextprotocol#1527, modelcontextprotocol#1533, modelcontextprotocol#1537, modelcontextprotocol#1539, modelcontextprotocol#1540, modelcontextprotocol#1544, modelcontextprotocol#1547,
modelcontextprotocol#1549, modelcontextprotocol#1550, modelcontextprotocol#1553, modelcontextprotocol#1554, modelcontextprotocol#1558, modelcontextprotocol#1560, modelcontextprotocol#1561, modelcontextprotocol#1562.

Fork-side adaptations:

- internal/jsonrpc2: the -32600 reply to a duplicate in-flight ID
  (modelcontextprotocol#1550) is written off the read loop and holds its admission slot
  until written, like every other reply under MaxIncomingRequests.
- mcp: ClientSession.initialize takes the session state lock that
  upstream added, and still projects the negotiated version to the
  connection.
- mcp: the fork's copies of hintomitempty, nowrapinvalidparams and
  nomethodnotfoundcodeinerror go away with upstream's removal (modelcontextprotocol#1533).
- extensions/skills: reads the protocol version from the fork's
  json.RawMessage Meta.
- Tests: the duplicate-ID admission test drains the new reply, and the
  client cancellation test runs on 2025-11-25 only, because 2026-07-28
  clients reject every standalone server request (modelcontextprotocol#1537, modelcontextprotocol#1540, modelcontextprotocol#1554).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: list_changed can only be broadcast; a server cannot notify one session (2026-07-28 subscriptions/listen)

3 participants