Token budgets
Claude Code saved your fetch result to a file: MAX_MCP_OUTPUT_TOKENS
Find out which Claude Code limit sent a fetch result to a file: the 25,000-token default, the 50,000-character rule or the tool's own cap, and fix it in the right order.
By Lucian Dyer, FetchMCP team · Published
This article was drafted with AI assistance from the sources listed below and edited and published by the FetchMCP team. Disclosure: the FetchMCP API, which this article mentions, is this site's own product.
- 1Lower the tool's capAsk the fetch tool for fewer characters, for example max_characters at its default of 8,000.
- 2Fetch a narrower URLOne section or one release page instead of the whole document.
- 3Raise MAX_MCP_OUTPUT_TOKENSOnly for the token limit (default 25,000). It does not move the 50,000-character rule.
- 4Let the server declare a limitOnly the server can set anthropic/maxResultSizeChars, up to 500,000 characters.
You asked Claude Code to read a page through a fetch MCP tool. Instead of the page, the conversation shows a short message with a file path. The fetch worked. One of Claude Code's output limits moved the result to disk.
This post tells the limits apart, so you change the right one. Checked against the Claude Code MCP docs on 2026-11-21. For how a fetch tool's cap and the client limit fit together in general, start with the token budget guide.
What the file message means
Claude Code saves a tool result to a file instead of putting it in the conversation when all of this holds:
- The result is successful and has no image content.
- It is over the MCP output token limit, or it is a text result longer than 50,000 characters from a call that completed in the foreground.
The file goes in the session's tool-results directory under ~/.claude/projects/. The message in the conversation names the path, and Claude reads the file when it needs the content. Nothing is lost, but the page is no longer in context by default.
Which limit fired
Four of Claude Code's size rules for MCP output matter here. Only two of them write a file.
| Rule | Value | What happens |
|---|---|---|
| Warning | 10,000 tokens, fixed | The transcript viewer shows a warning. Nothing else changes. |
| Output limit | 25,000 tokens by default, set with MAX_MCP_OUTPUT_TOKENS | A successful result over it is saved to a file. |
| Character limit | 50,000 characters for text, foreground calls only | Saved to a file, whatever its token count. |
| Response size | 16 MiB per HTTP or SSE response | Claude Code stops reading and the request fails. |
MAX_MCP_OUTPUT_TOKENS moves only the second row. It applies to tools that do not declare their own limit. A tool that sets anthropic/maxResultSizeChars uses that value for text content instead, and tools that return image data stay under MAX_MCP_OUTPUT_TOKENS either way.
The character limit applies to a call that completes in the foreground. A call that Claude Code moved to a background task reports its result through the task notification instead. For the client settings that govern slow calls, see the timeout post.
Fix it at the tool first
max_characters, max_length or whatever your fetch tool calls its size option is the first thing to change. A cap at the tool stops the text before it reaches the client, so no client limit has to catch it.
The character rule makes this concrete. If your tool can return up to 100,000 characters and you ask for 80,000, any page that fills the cap is over 50,000 characters. It lands in a file even if you raised MAX_MCP_OUTPUT_TOKENS. Ask for less, or fetch a narrower URL: one docs section or one release page instead of the whole document.
Then raise the token limit, if you still need to
MAX_MCP_OUTPUT_TOKENS raises the token limit for the MCP tools in the session that do not declare their own. Set it in your shell before you start Claude Code:
export MAX_MCP_OUTPUT_TOKENS=50000
claude
To keep it, put it in the env block of your settings.json:
{
"env": {
"MAX_MCP_OUTPUT_TOKENS": "50000"
}
}
Two things stay the same after this change. A successful text result over 50,000 characters still goes to a file. And the warning still appears above 10,000 tokens, because that threshold is fixed.
A server can raise the character limit for one tool
_meta["anthropic/maxResultSizeChars"] in a tool's tools/list entry raises that one tool's file threshold. Claude Code accepts values up to a hard ceiling of 500,000 characters. This is a setting for server authors. Setting MAX_MCP_OUTPUT_TOKENS does not change the 50,000-character threshold.
What happens to the saved files
~/.claude/projects/<project>/<session>/tool-results/ holds the spilled results. The same directory also keeps full-size copies of images that MCP tools return.
cleanupPeriodDays decides how long these files stay. Claude Code deletes them once they are older than that setting. The default is 30 days and the minimum is 1:
{
"cleanupPeriodDays": 7
}
The docs describe the data Claude Code keeps under ~/.claude, transcripts included, as plaintext. A fetched page you would not want on disk for a month is a reason to lower the period. claude purge deletes the state Claude Code holds for one project; add --dry-run to see the plan first.
Try it with a real server
FetchMCP API's get_page_contents takes one public URL per call and a max_characters cap from 500 to 100,000, with a default of 8,000. That default sits well under the 50,000-character rule. Leave it there for a first read and raise it for one call when the answer is cut off.
claude mcp add --transport http fetchmcp https://fetchmcp.net/mcp --header "Authorization: Bearer $FETCHMCP_API_KEY"
"The MCP server registers 2 tools." The configs for other clients are in the MCP docs.
Frequently asked questions
Why did Claude Code save my MCP tool result to a file?
A successful text result went to a file because it was over the MCP output token limit (25,000 tokens by default) or, for a call that completed in the foreground, longer than 50,000 characters. Claude gets a message with the file path and reads the file when it needs the content.
Does setting MAX_MCP_OUTPUT_TOKENS stop results from being saved to a file?
Only for the token limit. A successful text result longer than 50,000 characters from a call that completes in the foreground is still saved to a file, whatever MAX_MCP_OUTPUT_TOKENS says, unless the tool itself declares anthropic/maxResultSizeChars.
Where does Claude Code put saved MCP tool results?
In the session's tool-results directory under ~/.claude/projects/<project>/<session>/tool-results/. Claude Code deletes these files once they are older than cleanupPeriodDays, which defaults to 30 days.
What does the 10,000-token MCP warning do?
It is only a warning. The transcript viewer shows it when an MCP tool output passes 10,000 tokens. The result still reaches the conversation unless it also crosses the output limit or the character limit.
Sources
- Connect Claude Code to tools via MCP (Claude Code docs) (Documentation)
- Explore the .claude directory (Claude Code docs) (Documentation)