MCP Shipyard
← Guides

MCP tool responses too large: size limits and how to stay under them

The documented result-size limits in Claude and Claude Code, what OpenAI does and does not document, and server-side patterns that keep tool output small: limits, cursors, field selection and links.

tokensresponse-sizepaginationclaude-codecontextperformance
<!-- Evidence of demand (checked 2026-12-03 via WebSearch "MCP tool response exceeds maximum allowed tokens 25000"): Figma's MCP clients-issues page documents the error "response (351378 tokens) exceeds maximum allowed tokens (25000)"; a DEV Community post "A single MCP call returned 278,649 tokens, here's the proxy I built to stop it"; another DEV post "Solving AI's 25,000 token wall"; an Atlassian community thread "How to limit responses" for its remote MCP server; a Claude Code GitHub issue (#12241, not opened). None opened except as noted; technical claims below are from the official docs cited inline. -->

MCP tool responses too large: size limits and how to stay under them

A tool that returns a whole table works in testing and fails in a real account. In Claude Code the result gets written to a file, and the model reads the file or gives up. In any client, a huge result fills the context window and pushes out the user's conversation. This guide lists the limits that are documented, the ones that are not, and how to design tools that never hit them.

The documented limits

Anthropic's connector build guide lists the limits for hosted Claude and for Claude Code:

Limitclaude.ai and DesktopClaude Code
Maximum tool result sizeabout 150,000 characters25,000 tokens, configurable with MAX_MCP_OUTPUT_TOKENS

Claude Code's MCP docs add the details:

  • Warning. The transcript viewer warns when any MCP tool output exceeds a fixed 10,000 tokens.
  • Over the token limit. A successful result with no image content that exceeds it is saved to a file, and the conversation gets a message naming the path.
  • Character threshold. For a tool that does not declare its own limit, a text result longer than 50,000 characters is saved to a file whatever its token count. Setting MAX_MCP_OUTPUT_TOKENS does not change this.
  • Per-tool override. A tool can set _meta["anthropic/maxResultSizeChars"] in its tools/list entry. Claude Code raises that tool's threshold to the value, up to a ceiling of 500,000 characters. Image results remain subject to the token limit.
  • Hard stop. When an HTTP or SSE server response passes 16 MiB (after decompression, per JSON body or per event), Claude Code stops reading and the request fails.
  • Error text. For a result marked isError: true, text longer than about 11,000 characters keeps only the first 5,000 and last 5,000 characters, with a marker between them.

The override looks like this:

{
  "name": "get_schema",
  "description": "Returns the full database schema",
  "_meta": { "anthropic/maxResultSizeChars": 200000 }
}

Use the override only for output that is large and necessary, such as a schema, and which the model needs whole. The docs give database schemas and file trees as examples. It is not a way around a bloated list endpoint.

What is not documented

OpenAI's Apps SDK server guide states no size limit for tool results. Its guidance is qualitative: structuredContent should be "concise data the model can inspect and use in later calls." The app submission guidelines say, in section 6.4, "Tool responses must contain only data directly relevant to the user's request and the tool's stated purpose." We found no character or token cap on either page. Anthropic's review criteria also leave the number open: reviewers ask that responses are "reasonably sized for the task" and say not to return a full database dump when a summary was requested.

So the only hard numbers are Claude's. Because token counts differ by model, we do not convert characters to tokens here. Measure instead (see the end).

Design tools that return a page, not a table

Add limit and a cursor, and say so in the description

MCP's own pagination is defined for tools/list, resources/list, resources/templates/list and prompts/list. It does not paginate the results of your tools, so you design the arguments. Follow its conventions: an opaque cursor, a server-chosen cap, and -32602 (Invalid params) for a bad cursor.

server.registerTool('list_orders', {
  description:
    'List orders, newest first. Returns at most `limit` rows (default 20, max 100) and a next_cursor ' +
    'when more exist. Filter by status or customer_id before paging.',
  inputSchema: {
    status: z.enum(['open', 'shipped', 'cancelled']).optional(),
    customer_id: z.string().optional(),
    limit: z.number().int().min(1).max(100).default(20),
    cursor: z.string().optional().describe('Opaque cursor from a previous next_cursor'),
  },
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
}, async ({ status, customer_id, limit, cursor }) => {
  const page = await db.orders.page({ status, customer_id, limit, cursor });
  const body = { orders: page.rows.map(slim), next_cursor: page.next ?? null, total: page.total };
  return { content: [{ type: 'text', text: JSON.stringify(body) }] };
});

Put the caps in the schema (max(100)), not only in prose, so a model cannot ask for 10,000. Include total so the model can decide whether to keep paging.

Return fewer fields

slim above should drop internal ids, audit columns and anything the model cannot act on. Offer a fields argument or a second tool, such as get_order, for the full record. We prefer several purpose-built tools to one get_everything tool, because each result stays small and each description stays specific. See writing tool descriptions.

Summarize first, detail on request

For analytics-style tools, return aggregates (counts, top 10, min and max) and let the model ask for rows with a filter. A tool that says "12,481 rows match, here are the top 20 by amount" is more useful than 12,481 rows it cannot read.

If a result is genuinely a file, such as an export, return a short summary and a download link or a resource, not the bytes. Claude's build guide covers file transfers, which are in beta, for returning files outside the tool result.

Truncate on purpose and say so

When you must cap, cap in your code and tell the model, so it does not treat partial data as complete:

const MAX_CHARS = 40_000;
let text = JSON.stringify(body);
if (text.length > MAX_CHARS) {
  body.orders = body.orders.slice(0, Math.floor(body.orders.length / 2));
  body.truncated = true;
  body.hint = 'Result was cut to fit. Narrow with status or customer_id, or pass the next_cursor.';
  text = JSON.stringify(body);
}

A real implementation should loop until the text fits, since halving once may not be enough. The numeric choice is yours. Staying under 50,000 characters keeps you below Claude Code's persist-to-disk threshold, and well under 150,000 keeps you inside the hosted limit.

Return errors that are short and specific

Because of the error-text trimming above, put the useful part first: what was wrong and what to change, in a sentence or two. Do not dump a stack trace.

Measure it in CI

Check sizes the way a client sees them. The Inspector CLI prints JSON you can measure:

npx @modelcontextprotocol/inspector --cli https://your-server.example.com/mcp --transport http \
  --method tools/call --tool-name list_orders --tool-arg limit=100 --format json \
  | jq '[.result.content[] | select(.type=="text") | .text | length] | add'

Fail the build if the number for your worst-case valid call passes a budget you pick, for example 40,000. Include a call with the largest allowed limit and the widest filter. The CLI's JSON envelope and the .result path are described on its CLI page. See testing an MCP server in CI for the rest of a pipeline.

The context cost of your tool list is separate. In our December 2026 crawl, tool descriptions had a median length of 277 characters and a p90 of 936, and 171 of 1,908 tools (9.0%) exceeded 1,000 characters. Those definitions load into the model's context on every request.

Checklist

  • Every list-like tool has limit with a schema maximum
  • Results include next_cursor or a truncated flag
  • Records are trimmed to fields the model can use
  • The worst valid call stays under 50,000 characters
  • Large-but-necessary outputs declare anthropic/maxResultSizeChars
  • A CI check measures the size of the worst valid call

Check your server

Run the free scan at /scan. It measures tool description length and parameter descriptions, which are the part of context you pay for before any tool runs.

Check your server against these rules

Scan runs the checks from this guide against a live URL and lists each failing rule with its fix.

Scan a server