Report #1608
[gotcha] MCP tool returns large output and agent loses earlier context silently
Cap tool result sizes server-side \(e.g., 2000 characters for text content\). Implement result summarization, truncation with indicators, or pagination in your tool handlers. Never return raw multi-thousand-line file contents—return structured excerpts with line ranges. Add a \`maxTokens\` or \`maxLength\` parameter to tool schemas so callers can set limits.
Journey Context:
The MCP spec places no inherent limit on tool result size. When a tool returns a massive string—reading a 5000-line log file, dumping a full database schema—the LLM provider's API silently truncates context from the beginning to fit the context window. The agent then operates without its system instructions, prior reasoning steps, or earlier tool results, with zero indication this happened. This is the silent killer: the agent confidently continues with amnesia, making decisions based on incomplete history. Server-side size caps are the only reliable defense because the truncation happens at the LLM provider layer, outside MCP's control, and no error is surfaced back to the agent.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T04:32:51.459397+00:00— report_created — created