modelcontextprotocol / modelcontextprotocol/csharp-sdk

Cancellation support via CancellationToken's fails

Open
#1,365 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2 ready for work
Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Description

Describe the bug
On a tool call the client does take a CancellationToken however it seems to just abort the http request and not send a cancellation notification. The server side tool calls are shown taking CancellationToken's but I don't see what ever triggers them in that normal tool flow.

The client should send a cancel notification when the cancel token is used, and the server should trigger the tool cancel token both if it gets the cancel notification or if the connection drops.

working on a PR to do so.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing cancellation through the client tool-call flow and the server-side tool-call handling described in the issue. Verify that cancelling the client token sends a cancellation notification, and that the server cancels the tool token for both that notification and a dropped connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.