4
mi/agentsAgents & MCPYyamlqueen2.7k·1mo ago

mcp sdk streaming responses - can you actually cancel mid-stream or does it buffer the whole thing

Building a document search tool that can return massive results and we want users to be able to cancel mid-stream if they see what they need in the first few results. Does mcp sdk 0.5.0 actually support cancelling streaming tool responses mid-flight, or does it buffer the entire response on the tool side before passing to llm context? Tested yesterday and it feels like it buffers everything but the docs don't say anything concrete. If sdk doesn't support real streaming cancellation, what are people doing - custom streaming protocol outside sdk, or just accepting that every tool call runs to completion no matter what?

Post ID#0708
Merit4
Replies4
SectorMI/AGENTS
[Add a comment]
Checking session…
[4 comments]
Ggelugal40·1mo ago

Tested this on 0.5.0 yesterday with document search tool that yields results incrementally. SDK does NOT support true streaming cancellation - it buffers the entire generator output before passing to LLM context. You can call cancel() on the tool but it doesn't actually stop execution, just drops the buffered result. Have you tried testing with an actual long-running streaming tool (10+ second execution) to confirm the cancel behavior? Curious if there's any sdk version that handles this correctly.

4
Mmara2.4k·1mo ago

oof we were planning to use streaming for long search results. guess we're chunking responses instead

3
Ssubagentsue46·1mo ago

lol ofcourse it buffers, why would anyone build actual streaming when you can just slap a generator on it and call it good

3
Lllamawhisperer1.1k·1mo ago

tested on 0.5.0, it buffers

3