Skip to main content
guidesSource-backedReview first Safety Privacy

Controlling MCP Result Size And Context Pressure

Reduce Claude Code context pressure from MCP tools using MAX_MCP_OUTPUT_TOKENS, anthropic/maxResultSizeChars annotations, tool search deferral, alwaysLoad discipline, and pagination patterns from official MCP documentation.

by kiannidev·added 2026-06-16·
HarnessClaude Code
Review first review before installing

Open the source and read safety notes before installing.

Safety notes

  • Raising output limits increases context cost and may hide the need to paginate server responses.
  • alwaysLoad: true on large servers loads every tool schema at session start—use sparingly.
  • Truncated MCP output can omit fields needed for security review; verify critical data separately.

Privacy notes

  • Large MCP payloads may contain secrets; shrinking output does not redact—sanitize at the server.
  • Tool search defers schemas but invoked tools still return full results into context.
  • Shared CI logs pasted through MCP can expose internal URLs in truncated previews.

Prerequisites

  • One or more MCP servers returning large JSON, logs, or file dumps.
  • Ability to set environment variables for Claude Code sessions.
  • Optional access to MCP server source to add pagination or size annotations.
  • Understanding of your project's context budget for long sessions.

Schema details

Install type
copy
Reading time
8 min
Difficulty score
55
Troubleshooting
Yes
Breaking changes
No
Full copyable content
When MCP tools flood context, set MAX_MCP_OUTPUT_TOKENS, prefer servers with maxResultSizeChars, enable tool search defaults, and avoid alwaysLoad on large tool catalogs unless every turn needs them.

About this resource

TL;DR

Claude Code warns when MCP tool output exceeds 10,000 tokens. Control pressure with MAX_MCP_OUTPUT_TOKENS, server-side anthropic/maxResultSizeChars, tool search deferral, and careful alwaysLoad settings.

Prerequisites & Requirements

  • {"task": "Large-output tools identified", "description": "Servers returning logs, queries, or file dumps are listed"}
  • {"task": "Env access", "description": "You can export variables before launching Claude Code"}
  • {"task": "Server ownership", "description": "Know whether you can patch MCP server pagination"}
  • {"task": "Context budget", "description": "Team agrees on acceptable MCP share of the window"}

Core Concepts Explained

Default warning at 10k tokens

MCP documentation states Claude Code displays a warning when MCP tool output exceeds 10,000 tokens, signaling context pressure.

MAX_MCP_OUTPUT_TOKENS

Set the environment variable to raise or lower the cap—for example MAX_MCP_OUTPUT_TOKENS=50000. Applies to tools without their own declared limit.

maxResultSizeChars annotation

Tools that set anthropic/maxResultSizeChars use that value for text content independently of the env var. Prefer server-side annotations over globally raising limits.

Tool search deferral

Tool search loads MCP tool definitions on demand, keeping session-start context lower when many servers are configured. ENABLE_TOOL_SEARCH=auto uses a 10% context threshold mode.

alwaysLoad tradeoff

Setting alwaysLoad: true forces a server's tools into context every turn—only for small always-needed toolsets.

Step-by-Step Implementation Guide

  1. Reproduce the warning. Note which MCP tool triggers the 10k token alert.

  2. Try server pagination first. Ask the server author to page large responses.

  3. Add maxResultSizeChars if you maintain the server.

  4. Tune MAX_MCP_OUTPUT_TOKENS temporarily while paginating—document the value in team runbooks.

  5. Review alwaysLoad flags. Disable on catalog servers with dozens of tools.

  6. Confirm tool search is on. Default deferral helps multi-server setups.

  7. Monitor /context. Verify MCP share drops after changes.

Configuration Examples

export MAX_MCP_OUTPUT_TOKENS=25000
claude
{
  "mcpServers": {
    "analytics": {
      "type": "stdio",
      "command": "analytics-mcp",
      "alwaysLoad": false
    }
  }
}

Troubleshooting

Warning persists after raising env var

Check whether the tool declares anthropic/maxResultSizeChars or returns images subject to token limits separately.

Claude cannot complete task with truncated output

Paginate server responses or split tools instead of only raising limits.

Context still tight with few tools

Inspect alwaysLoad servers and upfront built-in tools; use tool search auto mode.

Source Verification Notes

Verified against Claude Code MCP documentation on 2026-06-16: 10k token warning, MAX_MCP_OUTPUT_TOKENS, anthropic/maxResultSizeChars, tool search defaults, ENABLE_TOOL_SEARCH=auto, and alwaysLoad behavior.

Duplicate Check

Complements sparse-context-setup-for-large-codebases (general context strategy) and MCP threat-model guides. No guides entry documents MCP output token limits and tool search deferral together.

References

Source citations

Add this badge to your README

Show that Controlling MCP Result Size And Context Pressure is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/guides/controlling-mcp-result-size-and-context-pressure.svg)](https://heyclau.de/entry/guides/controlling-mcp-result-size-and-context-pressure)

How it compares

Controlling MCP Result Size And Context Pressure side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

FieldControlling MCP Result Size And Context Pressure

Reduce Claude Code context pressure from MCP tools using MAX_MCP_OUTPUT_TOKENS, anthropic/maxResultSizeChars annotations, tool search deferral, alwaysLoad discipline, and pagination patterns from official MCP documentation.

Open dossier
Claude Code MCP Server Setup Guide

Connect existing MCP servers to Claude Code with claude mcp add: stdio, HTTP, and SSE transports, local/project/user scopes, .mcp.json, and /mcp OAuth.

Open dossier
Auditing MCP Client Configuration Before Team Rollout

Source-backed checklist for reviewing Claude Code MCP client configuration before a team rollout, covering scopes, transports, commands, secrets, allowlists, denylists, approvals, and rollback.

Open dossier
OAuth Patterns For MCP Server Authentication

Implement OAuth patterns for MCP servers in Claude Code: Dynamic Client Registration, pre-configured client IDs, oauth.scopes pins, authServerMetadataUrl overrides, and keychain token storage from official MCP documentation.

Open dossier
Trust
Install riskReview firstReview firstReview firstReview first
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
Categoryguidesguidesguidesguides
Sourcesource-backedsource-backedsource-backedsource-backed
AuthorkiannidevJSONboredYB0ykiannidev
Added2026-06-162025-10-272026-06-102026-06-16
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notesRaising output limits increases context cost and may hide the need to paginate server responses. alwaysLoad: true on large servers loads every tool schema at session start—use sparingly. Truncated MCP output can omit fields needed for security review; verify critical data separately.Local stdio servers run their command with your user privileges, and remote servers expose model-controlled tools, so connect only servers you trust and review the command, URL, and headers first.Local stdio MCP servers execute commands with the user's privileges, so review the exact command, arguments, package runner, file paths, and network behavior before sharing a config. Remote MCP servers can expose model-controlled tools for production systems; require least-privilege scopes, explicit approval for write tools, and a rollback path before team rollout. Do not rely on server names alone for enforcement because names are user-assigned labels; use command or URL allowlist entries when policy must control what actually runs.Pin oauth.scopes to least privilege; widen only when tools return insufficient_scope. Client secrets belong in keychain/credentials storage—not committed .mcp.json. Static Authorization headers bypass OAuth discovery—verify tokens separately.
Privacy notesLarge MCP payloads may contain secrets; shrinking output does not redact—sanitize at the server. Tool search defers schemas but invoked tools still return full results into context. Shared CI logs pasted through MCP can expose internal URLs in truncated previews.Server URLs, command paths, header names, and tool results can expose internal hosts and private data; keep API keys and tokens out of shared `.mcp.json` and use environment-variable expansion or `/mcp` OAuth instead.MCP client configuration can reveal server URLs, internal hostnames, command paths, environment-variable names, header names, OAuth client IDs, and tool availability. Do not store API keys, bearer tokens, client secrets, tenant IDs, or personal credentials in shared `.mcp.json`, managed-mcp.json, PR bodies, issue comments, logs, or screenshots. Tool arguments, tool results, resources, prompts, logs, traces, and OAuth metadata can expose private repositories, tickets, databases, user identities, and workspace data.OAuth tokens in keychain still grant server access—revoke via /mcp Clear authentication. Redirect URIs must match registered localhost callback ports exactly.
Prerequisites
  • One or more MCP servers returning large JSON, logs, or file dumps.
  • Ability to set environment variables for Claude Code sessions.
  • Optional access to MCP server source to add pagination or size annotations.
  • Understanding of your project's context budget for long sessions.
  • Claude Code installed and signed in, with the `claude` CLI on your PATH.
  • The connection details for the server you are connecting: its transport (stdio command, HTTP/SSE URL), any required header or environment variable, and its trust/source information.
  • A draft `.mcp.json`, `~/.claude.json` entry, plugin-provided MCP server, claude.ai connector plan, or managed-mcp.json deployment to review.
  • The server documentation, package or repository source, expected transport, command or URL, environment variables, headers, OAuth behavior, and tool list.
  • A test machine or disposable Claude Code profile where the configuration can be loaded with non-production data.
  • A named owner who can approve the rollout, publish the final configuration, and revoke credentials or block servers if the rollout fails.
  • Remote HTTP MCP server requiring OAuth per server documentation.
  • Developer portal access to register OAuth apps when DCR is unsupported.
  • Team policy for scope pins and credential storage.
Install
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.