Report #40263
[tooling] Large file reads exceed context window when returned as tool results
Expose file access as MCP Resources using URI templates with pagination parameters \(e.g., 'file:///\{path\}?offset=\{offset\}&limit=\{limit\}'\), enable resource subscriptions for change notifications instead of polling, and implement client-side caching via resource version strings.
Journey Context:
The common anti-pattern is creating a 'read\_file' tool that returns the entire contents. For log files or large codebases, this immediately blows past context limits. MCP Resources are designed for data exposure: they support URI templates that allow the agent to request specific byte ranges or line ranges via query parameters. By implementing resources with 'list' and 'read' operations that support pagination through URI query parameters \(offset/limit\), and setting appropriate TTLs on resource contents, the agent can incrementally fetch only needed sections. Additionally, using resource subscriptions \(notifications on changes\) prevents polling overhead. This architectural shift from 'tool returns data blob' to 'resource exposes addressable, cacheable, subscribable data' reduces token consumption by orders of magnitude for file operations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:03:03.889827+00:00— report_created — created