Skip to content

Add transport-level cancellation support and proper cancellation token propagation (client->server)#1377

Draft
mitchcapper wants to merge 1 commit intomodelcontextprotocol:mainfrom
mitchcapper:fix_cancel_token_support_pr
Draft

Add transport-level cancellation support and proper cancellation token propagation (client->server)#1377
mitchcapper wants to merge 1 commit intomodelcontextprotocol:mainfrom
mitchcapper:fix_cancel_token_support_pr

Conversation

@mitchcapper
Copy link

Closes #1365

Propagate HTTP request cancellation tokens to tool executions via JsonRpcMessageContext having the server able to handle the cancel notification directly or the server to detect the broken request.

The server should properly trigger the cancel token for any tools taking it if either of the above two happen allowing for the server to properly kill any long running tasks.

Motivation and Context

Right now it looks like cancelling works but it does nothing from a server perspective.

How Has This Been Tested?

Breaking Changes

Shouldn't, technically its a behavior change but I would assume most implementations that take the token would not have a reason for it to not cancel when the client request aborts.

Types of changes

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • [ x] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • [x ] I have read the MCP Documentation
  • [x ] My code follows the repository's style guidelines
  • [x ] New and existing tests pass locally
  • [x ] I have added appropriate error handling
  • [ x] I have added or updated documentation as needed

Additional context

Unable to figure out how to do a proper socket closure in a test case that would be helpful for the 3rd situation.

…n propagation (client->server)

Propagate HTTP request cancellation tokens to tool executions via JsonRpcMessageContext having the server able to handle the cancel notification directly or the server to detect the broken request
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.

Cancellation support via CancellationToken's fails

1 participant