Skip to content

Streamable proxy forwards notifications/cancelled with the client id, so cancellations never reach stdio servers #7480

Backlog

Description

@ar70n

Bug description

The streamable-http proxy that thv run puts in front of stdio servers (the default --proxy-mode streamable-http) rewrites each request id to a per-request composite key (<session>|<uuid>, in createWaiter) before writing it to the server, and restores it on the response. notifications/cancelled takes a different path: handleNotificationOrClientResponse forwards it unchanged, so params.requestId still carries the client's id, which the server never saw. The server ignores the unknown id and the tool runs to completion, so a client's cancellation never reaches a stdio server.

The SSE proxy already rewrites this id (rewriteCancelledRequestID, #6702), and #7342 did the equivalent for vMCP backends; the streamable proxy doesn't have it.

Steps to reproduce

A stdio server that logs what it receives, with a tool slow that answers after 20 s unless it sees a notifications/cancelled for the id it was given.

thv run --foreground --transport stdio --proxy-port 3743 --name spy <image>
# initialize, then on the same session:
POST /mcp {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"slow","arguments":{}}}
# ~1.5 s later, same session:
POST /mcp {"jsonrpc":"2.0","method":"notifications/cancelled","params":{"requestId":1}}   -> 202

What the server actually received — the call under a composite id, the cancellation still under the client's id:

{"jsonrpc":"2.0","id":"314edacc-…|d0fe61a2-…","method":"tools/call",...}
{"jsonrpc":"2.0","method":"notifications/cancelled","params":{"requestId":1,...}}

With --proxy-mode sse the same steps work: the cancellation arrives as "requestId":"<session>|n:1" and the tool stops.

Expected behavior

The cancellation reaches the server for the request it refers to and the tool stops, as it does through the SSE proxy.

Actual behavior

The tools/call returns its full result after 20 s; the server never sees a cancellation it can act on, and keeps doing the work.

Environment (if relevant)

  • OS/version: Linux
  • ToolHive version: reproduced on a build from fc81f63; the affected code (pkg/transport/proxy/streamable) is unchanged on current main.

Additional context

Related, for 2026-07-28 clients: on Streamable HTTP, closing the response stream is the cancellation signal, and over stdio the client must send notifications/cancelled. When a modern client disconnects, doRequest returns on ctx.Done() without telling the server, so the call also keeps running (verified the same way: no cancellation reaches the server, result emitted 20 s later). That part can be handled separately.

I have a fix for the legacy id-rewrite part with a test and am opening a PR for it.

Activity

  1. added
    needs-triage
    bug
    cli
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclimcpneeds-triageproxytransport

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions