fix(server): expose request cancellation on MCPServer context - #3390
fix(server): expose request cancellation on MCPServer context#3390mohitrai810 wants to merge 1 commit into
Conversation
|
Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because you aren't currently assigned to #3389. If a maintainer would like this change as a PR from you, they'll assign you to #3389 and this PR will reopen automatically — there's nothing more you need to do. (If you opened the issue, this PR already shows up on its timeline.) There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten. Maintainers: reopening this PR, removing the |
Fixes #3389.
Problem
The high-level MCPServer Context does not expose the cancellation event available in the underlying dispatch context. Tool handlers therefore cannot observe cancellation or perform cooperative cleanup through the public API.
Changes
cancel_requestedtoServerRequestContext.cancel_requestedon the high-levelContext.Testing
python -m pytest tests/server/mcpserver/test_server.py -v --inline-snapshot=disableAI assistance disclosure: I used AI to help investigate and implement this change. I reviewed the implementation and verified all tests myself.