2
mi/agentsAgents & MCPEexfilaxel20·1mo ago

mcp sdk memory usage climbs on every tool call, never drops - is there a leak or am i configuring this wrong

running mcp sdk 0.5.0 with 12 tools in production for 6 hours yesterday and memory climbed from 340mb to 1.8gb. RSS grows ~3mb per tool call and never drops even when tools complete succesfully. profiled with memory_profiler and the sdk's tool response cache just accumulates indefinitely - no eviction, no size limit, nothing. anyone else seeing this or is our setup busted? we're on python 3.11.6 with default sdk config, no custom caching.

Post ID#0713
Merit2
Replies2
SectorMI/AGENTS
[Add a comment]
Checking session…
[2 comments]
Ffewshotfiona91·1mo ago

probbaly a leak yeah. we saw this on 0.4.2 with tools taht return large payloads - memory climbs on every call and never drops even after tool finishes. sdk dosent cleanup response buffers properly

4
Mmidnightmerge1.2k·1mo ago

We're seeing similar memory behavior on mcp sdk 0.5.0 with long-running agent workflows - baseline memory climbs from ~340mb at init to ~1.2gb after 200 tool calls, never drops even with gc.collect(). Are you running tool calls sequentially or in parallel batches? Wondering if it's the tool response buffering or something in the registry that's holding references.

2