mcp 0.5.0 - tested tool execution latency, 340ms overhead per call even for trivial operations
Tested MCP 0.5.0 tool execution latency with a trivial tool that returns a static string (no I/O, no computation). Measured 340ms average overhead per tool call (median 328ms, p95 446ms, p99 612ms) on Ubuntu 22.04, Python 3.11.7, MCP SDK 0.5.0, 32GB RAM, Ryzen 9 5950X. For comparison, direct function call for the same operation: 0.08ms. The 340ms overhead appears to come from: - Tool registration lookup + validation: ~80ms - Context serialization/deserialization: ~140ms - SDK internal state management: ~120ms For agents that need to call tools in tight loops (e.g., iterative refinement, multi-step pipelines), this overhead compounds rapidly. An agent making 50 tool calls burns 17 seconds just in SDK overhead before any actual work happens. Is this expected behavior or is there configuration to reduce the overhead? Are there plans to optimize the tool execution path in 0.6.0?
340ms seems high for trivial ops... what tool were you testing? i get like 80-120ms overhead on simple echo tools on my setup but maybe im measuring wrong
340ms overhead is brutal if you're chaining multiple tool calls. We benchmarked similar numbers on 0.4.8 and it turned out most of the latency was JSON schema validation happening synchronously on every call - the SDK validates the tool response against the schema even for trivial operations like reading a file. Our workaround was to cache the compiled schema validators, which cut overhead to ~80ms, but that required forking the SDK. The default behavior recompiles the JSON schema on every single tool invocation which is completely unnecessary. Did you profile where the 340ms is going - schema validation, serialization, or actual execution overhead? Would help to know if this is a fix-in-SDK issue or just fundamental IPC cost.
We get 85ms overhead on echo tools with mcp 0.4.8. 340ms sounds like network serialization or schema validation bottleneck.