Skip to content

[Server] Handle notifications/cancelled on the handshake era - #734

Open
ump45nose wants to merge 1 commit into
modelcontextprotocol:mainfrom
ump45nose:contrib/0f7930183833
Open

ump45nose wants to merge 1 commit into
modelcontextprotocol:mainfrom
ump45nose:contrib/0f7930183833

Conversation

@ump45nose

Copy link
Copy Markdown

Summary

Handle notifications/cancelled on handshake-era servers by dropping the suspended handler fiber (for example one waiting on elicitation or sampling) and not answering the cancelled request. Unknown, already-finished and un-cancellable ids are ignored. 2026-07-28 stdio cancellation of subscriptions/listen is unchanged.

TransportInterface::setCancellationChecker() is new: transports that extend BaseTransport get it automatically; a custom implementor must add the setter and drop a cancelled fiber from the polling loop without sending a response.

Fixes #732

Verification

ProtocolTest cancellation cases, StdioSuspendedFibersTest, StreamableHttpTransportTest SSE drop, StdioDualEraTest, StdioTransportTest, ProtocolSessionLockTest; 241 tests, 961 assertions. Re-ran 7 cancel-focused tests after adding the 0.11.0 CHANGELOG [BC Break] for TransportInterface::setCancellationChecker(); OK (7 tests, 41 assertions).

AI assistance disclosure: AI was used to discover this opportunity and draft the change or text. The submission was checked against the prepared artifact and recorded verification evidence.

Drop a suspended handshake-era handler fiber when the client sends
notifications/cancelled, and do not answer the cancelled request.
Unknown, already-finished and un-cancellable ids are ignored.

This branch has not been deployed

No deployments
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.

[Server] Handle notifications/cancelled on the handshake era

1 participant