MCP file tools silently eat your context window.I built one that doesnt
FrameworkFreeHi, I am Anthony.Every token your filesystem tools consume is context the model cannot use for reasoning. Most MCP file servers are O(file size) on every operation: reads return the whole file, edits rewrite the whole file. The context window fills up before the agent gets anything meaningful done,
Capabilities6 decomposed
context-aware file reading with token budgeting
Medium confidenceImplements file reading operations that track and report token consumption before returning content, using a token counter (likely tiktoken-based) to estimate context window impact. Unlike standard MCP file tools that silently consume context, this capability exposes token costs upfront, allowing clients to make informed decisions about whether to read files or use alternative strategies like summarization or chunking.
Embeds token cost visibility directly into the MCP file tool protocol response, returning both content and token metadata in a single operation, rather than treating token consumption as a hidden side effect. This architectural choice makes context budgeting a first-class concern in the tool interface.
Solves the 'silent context window exhaustion' problem that standard MCP file tools create by making token costs explicit and queryable before file content is consumed by the LLM.
selective file chunking with token-aware boundaries
Medium confidenceProvides file reading strategies that split large files into token-bounded chunks rather than returning entire files, using token counts to determine chunk boundaries instead of arbitrary line counts. The implementation likely uses a sliding window approach that respects semantic boundaries (e.g., function/class definitions) while staying within token budgets, allowing clients to incrementally load only the portions of files they need.
Uses token counts rather than line numbers or byte offsets as the primary chunking dimension, with optional semantic boundary awareness to avoid splitting logical code units. This is architecturally different from naive line-based chunking or fixed-size byte chunking used in standard file tools.
Enables efficient incremental file loading that respects both token budgets and code structure, whereas standard MCP file tools force all-or-nothing file reads that either waste context or fail to load necessary context.
token budget tracking and enforcement across mcp operations
Medium confidenceMaintains a session-level token budget that tracks cumulative consumption across multiple file read operations, enforcing limits before operations exceed the budget. The implementation likely uses a state machine or middleware pattern to intercept file tool calls, check remaining budget, and either allow, deny, or suggest alternative operations (like summarization) based on available tokens.
Implements budget enforcement at the MCP server level as a cross-cutting concern, tracking state across multiple tool invocations rather than treating each file read as independent. This architectural pattern is typically found in API gateway or middleware layers, not in individual file tools.
Provides predictable, enforceable token budgets for entire agent sessions, whereas standard MCP tools have no budget awareness and can silently consume all available context across multiple operations.
token cost estimation and reporting for file operations
Medium confidenceCalculates and returns token cost estimates for file operations before execution, using a tokenizer matched to the target LLM model. The implementation likely pre-tokenizes file content or uses heuristic estimation (characters × 1.3 for English text) to provide instant cost feedback without actually reading the file, enabling cost-benefit analysis before committing to expensive operations.
Provides token cost estimation as a separate, fast operation distinct from actual file reading, allowing clients to query costs without I/O overhead. Most file tools conflate cost with content delivery; this separates concerns to enable cost-aware decision making.
Enables informed file selection decisions before reading, whereas standard MCP file tools provide no cost visibility until after content is already loaded into context.
directory traversal with cumulative token budgeting
Medium confidenceImplements directory listing and recursive file discovery operations that calculate and report cumulative token costs for all files in a directory tree. The implementation likely walks the file system, collects file metadata, estimates tokens for each file, and aggregates costs, allowing clients to understand the full token impact of loading an entire directory before committing to the operation.
Aggregates token costs across entire directory trees and presents cumulative budgeting information, treating directories as first-class budgeting units rather than collections of independent files. This enables project-level token planning rather than file-by-file decisions.
Provides visibility into total token impact of loading entire directories, whereas standard MCP file tools require manual iteration and have no aggregation or budgeting support.
model-specific tokenizer selection and switching
Medium confidenceAutomatically selects and switches between tokenizers based on the target LLM model identifier, ensuring token estimates and counts match the actual model's tokenization scheme. The implementation likely maintains a registry of model-to-tokenizer mappings (e.g., gpt-4 → tiktoken, claude-3 → sentencepiece) and dynamically loads the appropriate tokenizer, with fallback heuristics for unknown models.
Maintains a model-to-tokenizer registry and dynamically selects tokenizers based on model identifiers, treating tokenization as a pluggable, model-aware concern rather than a fixed implementation. This architectural pattern enables multi-model support without client-side tokenizer management.
Provides accurate, model-specific token counts automatically, whereas standard MCP file tools either use a single fixed tokenizer (inaccurate across models) or require clients to manage tokenizers separately.
Capabilities are decomposed by AI analysis. Each maps to specific user intents and improves with match feedback.
Related Artifactssharing capabilities
Artifacts that share capabilities with MCP file tools silently eat your context window.I built one that doesnt, ranked by overlap. Discovered automatically through the match graph.
MCP server gives your agent a budget
As a consultant I foot my own Cursor bills, and last month was $1,263. Opus is too good not to use, but there's no way to cap spending per session. After blowing through my Ultra limit, I realized how token-hungry Cursor + Opus really is. It spins up sub-agents, balloons the context window, and
tokenomy
Surgical Claude Code hook that transparently trims bloated MCP tool responses and clamps oversized file reads — stop burning tokens on tool chatter.
@langchain/mcp-adapters
LangChain.js adapters for Model Context Protocol (MCP)
everything-claude-code
The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
pro-workflow
Claude Code learns from your corrections: self-correcting memory that compounds over 50+ sessions. Context engineering, parallel worktrees, agent teams, and 17 battle-tested skills.
mcp-framework
Framework for building Model Context Protocol (MCP) servers in Typescript
Best For
- ✓LLM application developers building agents that interact with file systems
- ✓teams managing context-constrained workflows with Claude, GPT-4, or other token-limited models
- ✓developers building MCP servers who want transparent resource accounting
- ✓developers building code analysis agents that work with large repositories
- ✓teams using context-window-constrained models (Claude 100K, GPT-4 8K) on large codebases
- ✓applications that need to balance comprehensiveness with token efficiency
- ✓developers building cost-conscious LLM agents that need predictable token usage
- ✓teams running agents on token-metered APIs (OpenAI, Anthropic) with strict budgets
Known Limitations
- ⚠Token estimation accuracy depends on tokenizer choice — may differ from actual model tokenization by 5-15%
- ⚠No built-in caching of token counts across repeated reads — recalculates on each operation
- ⚠Requires explicit token budget configuration per session; no automatic budget enforcement
- ⚠Does not handle multi-byte character encoding edge cases that some tokenizers struggle with
- ⚠Semantic boundary detection (functions, classes) requires language-specific parsing — may not work well for all file types
- ⚠Chunk boundaries may split logical units if token budget is very small relative to semantic units
Requirements
Input / Output
UnfragileRank
UnfragileRank is computed from adoption signals, documentation quality, ecosystem connectivity, match graph feedback, and freshness. No artifact can pay for a higher rank.
About
Show HN: MCP file tools silently eat your context window.I built one that doesnt
Categories
Alternatives to MCP file tools silently eat your context window.I built one that doesnt
Search the Supabase docs for up-to-date guidance and troubleshoot errors quickly. Manage organizations, projects, databases, and Edge Functions, including migrations, SQL, logs, advisors, keys, and type generation, in one flow. Create and manage development branches to iterate safely, confirm costs
Compare →Are you the builder of MCP file tools silently eat your context window.I built one that doesnt?
Claim this artifact to get a verified badge, access match analytics, see which intents users search for, and manage your listing.
Get the weekly brief
New tools, rising stars, and what's actually worth your time. No spam.
Data Sources
Looking for something else?
Search →