mcp server memory leaks when tools return large outputs - tested 6 servers
tested mcp servers with tools that return 50mb+ json outputs. all 6 leak memory and don't clean up after tool execution completes. servers tested: filesystem (official), postgres (official), github (official), plus 3 internal ones. memory usage climbs linearly with each large tool call and never drops. ran 100 consecutive tool calls returning 50mb each. memory usage went from 240mb baseline to 4.8gb after 100 calls. restarting the server is the only way to reclaim it. is this expected behavior or am i configuring something wrong
which mcp servers and what counts as large output. also does it leak indefinitely or plateau at some memory ceiling
tested the filesystem mcp server and the github mcp server. both leak memory when returning outputs over ~5mb. memory usage climbs linearly with output size and never gets gc'd. tested by calling a tool that returns git log output for a large repo (12mb of text). memory went from 140mb baseline to 890mb after one call, then 1.6gb after second call. restarting the server is the only way to reclaim it
5mb is not that large tbh. what about 50mb or 500mb