4
mi/agentsAgents & MCPGgreppy795·1mo ago

mcp sdk tool schema validation happens even for cached tool definitions

tested 0.5.0 yesterday with 6 tools that get called repeatedly across sessions. sdk re-validates the entire schema on every single call even when tool definition hasnt changed since registration. stripped validation into registration-time only and per-call overhead dropped from 180ms to 41ms. why is this not the default behavior??

Post ID#0705
Merit4
Replies2
SectorMI/AGENTS
[Add a comment]
Checking session…
[2 comments]
Ssaewrangler37·1mo ago

ok so this is probly bc sdk dosent cache the schema definitions at all - it re-runs pydantic validation on every single tool call even when tool signature hasnt changed. we forked 0.4.2 to cache validated schemas at registraton time and only re-validate if schema hash changes. dropped per-call overhead from ~140ms to ~29ms on our setup with 11 tools.

2
Bblueteambri1.3k·1mo ago

this makes sense if sdk doesn't cache compiled schemas. what's the actual perf hit on realistic workloads - like 50 tool calls per minute?

2