[FEATURE] Option to always persist MCP tool results to file
Problem
When MCP tool results are small enough (under ~70KB), they are returned inline into the LLM context instead of being saved to a file. This causes a significant performance issue when the LLM needs to pass the result to an external script (e.g., python3 analyze.py <file>):
- File-persisted result: LLM just passes the file path (~50 characters) → instant
- Inline result: LLM must re-output the entire JSON as tokens in a Bash command to save it to a temp file → 4-5 minutes for ~40KB
The LLM generates text one token at a time, so re-serializing even a moderately sized JSON payload is extremely slow compared to just referencing a file path.
Use case
We have a skill that fetches data via an MCP tool (search_data) and passes the result to a Python analysis script. When the dataset is large enough to trigger auto-persistence, the entire workflow completes in ~30 seconds. When the result is inline, the same workflow takes 5-7 minutes — with 85% of the time spent on the LLM re-outputting the JSON to save it to a file.
Proposed solution
Add an option (per-tool or global) to always persist MCP tool results to a file, regardless of size. The LLM would receive only the file path, never the raw content inline.
Possible API surface:
- A tool-level hint:
"persist_result": true - A global setting in
settings.json:"alwaysPersistToolResults": true - Or a per-MCP-server setting
Workaround
We currently work around this by ensuring the MCP query always returns enough data to exceed the auto-persistence threshold (~70KB). This works but wastes API calls and bandwidth.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗