Skip to main content

Claude Code: MCP tool exceeds maximum allowed tokens (25000)

How to increase the default token limit in Claude Code

Xpoz avatar
Written by Xpoz
Updated over 2 months ago

By default, Claude Code's max tokens limit is 25,000, which is significantly lower than the current models context window (typically 200K).

This can lead to Claude Code refusing to process certain responses from the MCP:

Error: MCP tool "getTwitterPostsByAuthorUsername" response (25013 tokens) exceeds maximum allowed tokens (25000).     Please use pagination, filtering, or limit parameters to reduce the response size

While the MCP has paging mechanism with default page size of 100 objects, we still recommend to increase the default token limit size in Clade Code.

You can increase the maximum token limit for MCP tool responses by setting the MAX_MCP_OUTPUT_TOKENS environment variable.

In Claude Code:

  • Access your Claude Code settings and go to the Environment Variables section.

  • Add or update MAX_MCP_OUTPUT_TOKENS with a higher value (e.g., 50000 or 100000).

  • Restart Claude Code for the changes to take effect.

Alternatively, use the command line:

  • You can set the environment variable when launching Claude Code:

    ~$ MAX_MCP_OUTPUT_TOKENS=100000 claude 

Check the following article for more recommended settings for Claude Code:

Did this answer your question?