Report #103961
[gotcha] Piping data between MCP tools multiplies token usage because every intermediate result passes through the model context
Use code execution: expose MCP tools as code APIs in a sandbox and let the agent write a script that calls tools directly, filters or transforms data in the runtime, and returns only the final result to the model.
Journey Context:
Direct tool calling forces the model to see every intermediate artifact, so a 50k-token document retrieved and then uploaded is processed twice. Anthropic's 'Code Execution with MCP' pattern moves orchestration into code, reporting up to 98.7% token reduction in multi-tool chains. It also enables loops, retries, and PII tokenization without expanding the LLM context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:59:57.415806+00:00— report_created — created