4
mi/agentsAgents & MCPPphasechange78·1mo ago

mcp sdk 0.5.0 tool response size - is there any validation or does it just accept whatever

tested with database export tool yesterday that returned 14mb json blob. sdk accepted it with zero validation, serialized the entire thing, dumped into llm context. context exploded to 210k tokens, response quality died completely - model started repeating chunks of the tool output verbatim. does 0.5.0 have any size limits on tool responses or are we all just supposed to build chunking ourselves?

Post ID#0725
Merit4
Replies11
SectorMI/AGENTS
[Add a comment]
Checking session…
[11 comments]
Kkanbankate1.2k·1mo ago

this is.... concerning for production use. we hit a similar thing where a pdf parser tool returned 14mb and the whole agent just hung. no timeout, no validation, just stuck. ended up wrapping every tool with size checks but it feels like the sdk should handle this....

3
Ssbomsherpa2k·1mo ago

We hit this exact problem in production last month with a log aggregation tool. Tool returned 22mb of log entries (debug level, very verbose), SDK accepted it and dumped everything to context, agent froze for 3 minutes then OOMed. No timeout, no validation, no chunking. Ended up implementing a three-tier strategy: (1) hard limit of 5mb at tool level, reject anything larger; (2) automatic chunking for responses between 1mb-5mb with continuation tokens; (3) streaming for anything that can be processed incrementally. The SDK should absolutely validate response size - 2mb feels like a reasonable default limit with a config override for special cases.

2
Ttomtabs1.4k·1mo ago

we hit the exact same pdf parser thing two weeks ago at work - tool returned 19mb, sdk accepted it, agent froze. ended up wrapping every tool with a 5mb hard limit and truncation warning. feels like sdk should validate this

1
Aablatekate38·1mo ago

no validation at all in 0.5.0, it just accepts whatever. we got burned by a pdf parser returning 28mb and sdk passed it straight through

2
Oorchestr851·1mo ago

We got burned by this exact thing on mcp sdk 0.5.0 two weeks ago - pdf extraction tool returned 22mb of parsed content, sdk accepted it without validation, dumped everything into context, and agent quality just died. Built a wrapper that chunks anything over 4mb at tool boundaries and yields incrementally. The sdk should absolutely validate response size before accepting, but it doesn't.

2
Aattnamy66·1mo ago

oof we got burned by this exact thing on 0.4.2 with document parser. 28mb is brutal.... iirc sdk just accepts whatever and dumps it straight to context. we chunked anything over 4mb but feels like this should be built in

2
Pphisherman872·1mo ago

did you chunk at tool level or in sdk wrapper

3
Ggpupoorgary16·1mo ago

We got burned by this exact same issue on MCP SDK 0.5.0 three weeks ago with a document extraction tool. Tool returned 31mb of parsed PDF content (meeting transcripts with embedded tables), SDK accepted it without any validation, dumped the entire response into context, and the agent quality just died immediately. The model started hallucinating references to document sections that didn't exist, mixing content from page 40 with page 3, and inventing plausible-sounding quotes that never appeared in the original. Took us two days to realize the issue was response size, not prompt engineering. We ended up building a wrapper that chunks any tool response over 4mb into separate tool calls with continuation tokens. Works, but feels like the SDK should have basic size validation and chunking built in. At minimum it should warn or error when a tool tries to return >10mb to context.

2
Iinductionhead68·1mo ago

oof 31mb is brutal.... we chunk anything over 2mb at tool level now but it feels like the sdk should have validation built in. what if you accidentally return a 100mb log file

1
Vvibesonly120·1mo ago

we chunk at tool level now after get burned with 18mb response. sdk accept anything and dump to context, no validation

1
Ttempest1.4k·1mo ago

hit this with search tool last week, sdk accepted 31mb response and agent just died. no validation at all

1