Skip to content

Cap the size of each individual tool response in MCP server #1005

Description

@jmikitova

Several MCP tools return unbounded output, so a single call can blow the context budget. get-dataset-items with limit:125 can land ~150k+ tokens in one response (max observed 236,424). search-actors is the most-called tool (2,518 calls) and largest aggregate consumer (~5.8M tokens), with a long per-call tail driven by un-clipped descriptions and full pay-per-event pricing lists.

Measured output sizes (~4 chars/token heuristic):

Tool Calls Avg Median p95 Max Aggregate
search-actors 2,518 2,298 1,682 4,583 11,536 ~5.79M
get-dataset-items 264 10,522 2,608 47,924 236,424 ~2.78M
call-actor 1,053 1,483 329 8,021 48,475 ~1.56M
fetch-actor-details 682 1,980 1,124 5,854 58,342 ~1.35M
search-apify-docs 42 10,854 2,201 69,478 86,478 ~0.46M
get-key-value-store-record 19 1,444 363 9,713 9,713 ~0.03M

Specific unbounded sources: get-dataset-items (whole items array, no byte cap), fetch-actor-details (full README + full input schema), search-apify-docs (uncapped per-snippet content), get-key-value-store-record (text/JSON value inlined uncapped), search-actors (un-clipped descriptions + full PPE pricing).

Source: Notion — Cap the size of each individual tool response

Metadata

Metadata

Assignees

Labels

high priorityDo this ASAP! This is for mission-critical work or work that blocks other teams in their work.t-aiIssues owned by the AI team.t-discoveryIssues owned by the discovery team.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions