Report #51547
[gotcha] Large tool result displacing system prompt from context window \(context exhaustion attack\)
Enforce maximum size limits on tool results at the client level before they enter the LLM context. Truncate or summarize large results. Implement streaming with early termination for tools that may return large datasets. Place critical safety instructions at both the beginning and end of the system prompt to survive partial context eviction.
Journey Context:
MCP tools can return arbitrarily large results — a log file reader or database query can return megabytes of text. When injected into the LLM's context window, this can push out the system prompt containing safety instructions and behavioral constraints, causing the agent to lose its guidelines. This is not just a performance issue — it is a security issue. An attacker who controls tool input \(e.g., a malicious file being read\) can craft content that fills the context window, displacing safety instructions and making the agent susceptible to manipulation via the remaining tool output. The MCP spec places no limits on result size. Most clients do not truncate results. The agent silently degrades from constrained to unconstrained behavior.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:00:55.840612+00:00— report_created — created