Error: File content (28375 tokens) exceeds maximum allowed tokens (25000). Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.

Resolved 💬 31 comments Opened Jul 20, 2025 by peixotorms Closed Dec 2, 2025
💡 Likely answer: A maintainer (catherinewu, contributor) responded on this thread — see the highlighted reply below.

I am using sonnet and claude code.
Reading some files I get something like this:

Error: File content (28375 tokens) exceeds maximum allowed tokens (25000). 
Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.

While I understand there is some reasoning for this, why is the limit 25000 when Sonnet supports 64000 and Opus 32000? Shouldn't it detect which model is in use and let it use it up to the limit, or ate least higher for Sonnet?

How about context?
We have a 200k context, but is it used by claude code?
I am loading a small codebase that should be not anywhere near the 200k but apparently, it fills context very quickly.

Kindly allow us to use the full context and max_tokens available, don't hardcode those things.

View original on GitHub ↗

31 Comments

Antonytm · 11 months ago

The same here. And previously, bigger files were not the problem. Was something changed?

Anubhav-Rai · 11 months ago

facing the same issue

blevinson · 11 months ago

Same. Please advise! This is a severe limitation! We can't even get playright screenshots for that small???
playwright - Wait for (MCP)(time: 3) ⎿ Error: MCP tool "browser_wait_for" response (45599 tokens) exceeds maximum allowed tokens (25000). Please use pagination, filtering, or limit parameters to reduce the response size.

Baldman-JYH · 11 months ago

same issue

hqman · 11 months ago

same issue

mahmoudmoravej · 11 months ago

I hade the same issue but with MCP tools. I could assume context provider MCPs encounter this limit more often.

<img width="720" height="136" alt="Image" src="https://github.com/user-attachments/assets/0da9f165-9e3e-4ab8-a730-2338aa4b90df" />

mrrobotke · 11 months ago

This is really frustrating, makes using mcp feel useless. I'm on claude max 20x
<img width="959" height="147" alt="Image" src="https://github.com/user-attachments/assets/b9047b50-a60c-46ea-ae51-3d11c3631c7f" />

jaens · 11 months ago

RTFM, the MCP maximum token limit can be configured in the env configuration section.

hqman · 11 months ago

Hello, how do I set it up through env?

RTFM, the MCP maximum token limit can be configured in the env configuration section.
shubhamgupta731 · 11 months ago

export MAX_MCP_OUTPUT_TOKENS=50000 or whatever limit. I read somewhere the 5x Max plan has - 88K token limit and 20x Max - 200K token limit

zurferr · 11 months ago

please allow us to manually set it higher if you don't want to increase the default 🙏 50k would already help a lot in my case.

namenmalkav · 11 months ago

previously was a env var to set the context size why it was removed? pls add it again

EvolvingSoftware · 11 months ago

I've the same issue. Unfortunately working on a C driver and have limitations breaking the file up. Claude scanning through without being able to load the whole file, makes it look like it really doesn't understand what the file is doing and makes significantly more mistakes. Qwen code for instance, handles this totally fine.

dunktra · 10 months ago

same issue 😡

7manudev · 10 months ago

what we do about this now?

artnikbrothers · 10 months ago

same - whenever I start a simple project my context already filled in with 50,000 tokens. I didn't see this issue before

mrrobotke · 10 months ago
export MAX_MCP_OUTPUT_TOKENS=50000 or whatever limit. I read somewhere the 5x Max plan has - 88K token limit and 20x Max - 200K token limit

this works fro MCP tools, but we need one for files and context

csaftoiu · 10 months ago

Given 1M token context size, it should really allow larger files if user wants to pay

Mon-ius · 10 months ago

we have paid the MAX plan, it still limit our file read token!!!!

mitar · 10 months ago

I just did:

cd ~/.npm-global/lib/node_modules/@anthropic-ai/claude-code
sed -i 's/25000/100000/g' cli.js

And then in claude:

/model sonnet[1m]

And it looks like it works for me.

fleetingforest · 10 months ago

Same issue

codejq · 9 months ago

For windows users, you just need to add the CLAUDE_CODE_MAX_OUTPUT_TOKENS in environment variable screen as shown in the screen shot

<img width="1050" height="727" alt="Image" src="https://github.com/user-attachments/assets/13cadc07-7e82-4793-a0f5-c1e31cf67b83" />

KennyDizi · 9 months ago
I just did: `` cd ~/.npm-global/lib/node_modules/@anthropic-ai/claude-code sed -i 's/25000/100000/g' cli.js ` And then in claude: ` /model sonnet[1m] `` And it looks like it works for me.

You're clever.

HitoshiroKyoka · 9 months ago

I'm really struggling too. I'm unable to fully utilize Sonnet 4.5's performance.

ciefa · 9 months ago
I just did: `` cd ~/.npm-global/lib/node_modules/@anthropic-ai/claude-code sed -i 's/25000/100000/g' cli.js ` And then in claude: ` /model sonnet[1m] `` And it looks like it works for me.

If you change the model to sonnet[1m] you an only use Sonnet 4 though, right?

ruanun · 7 months ago

I've encountered the same issue, which may be related to the Opus 4.5 model.

40tude · 7 months ago

Bonjour
Same issue here. I try to read ms_rust_core_guidlines.txt from Microsoft in a SKILL. It reports :

Error: File content (25630 tokens) exceeds maximum allowed tokens (25000). Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.

I contacted the guys maintening the core guidelines and they already said that the file will grow not shrink
I use Windows 11, Powershell and VSCode with Claude Code in a Pro Plan
I don't know what to do because I don't know if the advises above are still valid today
Regards

catherinewu contributor · 7 months ago

Hi - Wanted to explain our reasoning for this behavior. We limit the number of lines that Claude Code can read at a time since we noticed that sometimes Claude Code would read extremely long files that would eat up the entire context window and cause compaction, which frustrated users. To mitigate this, we warn Claude Code when it's going to read a long file so that it can decide either to read a subset of the file or to read the whole thing. It can still read the entire file by sending more than one read file request with different line start/end points. Hope that helps explain it!

If you're having issues with MCP, could you open a new issue so that we can keep this thread focused? Thank you!

mitar · 7 months ago

@catherinewu Could this limit be a setting? Or even to confirm with the user? I would prefer that if I ask Claude Code to read the whole file before continuing, that it can do that. Not that it is unable to do it. Maybe get a confirmation from me like it gets when running extra tools.

mitar · 7 months ago

This is also related to #5644. With #5644 we would not have to worry so much about "eating whole context" at all.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.