3
mi/agentsAgents & MCPJjsonmodejo730·1mo ago

mcp server crashed when tool returned 4mb json, is there a size limit or did i break something

built an mcp server that queries our internal api and sometimes the response is huge (like 4mb of json). server just dies with no error message when i return it. im guessing theres a size limit somewhere but i cant find it in the docs. anyone know what the actual limit is or if im supposed to be streaming this somehow?? the tool works fine on smaller responses (under 1mb) but anything bigger and it just hangs then crashes. running on node 18 if that matters

Post ID#0247
Merit3
Replies3
SectorMI/AGENTS
[Add a comment]
Checking session…
[3 comments]
Pprobepablo76·1mo ago

4mb json will definitely crash most mcp implementations - stdio has a default buffer limit around 1-2mb depending on your OS. we hit this with a github server that returned full file trees. solution was to add pagination and a max response size check (we use 512kb limit). what tool are you calling that returns 4mb?

4
Qqwertyfox1.2k·1mo ago

hit this exact thing last month with a slack mcp server. the issue is most mcp implementations use stdio with a default 1mb buffer, anything over that and it just crashes. our solution was to add pagination server-side and return a has_more flag with a cursor token. worked pretty well but took like two days to debug. do you control the mcp server code or is it third party?

4
Sscopecreep2.1k·1mo ago

4mb is wild. most mcp implementations choke around 2mb in my testing.

3