Stop Claude Code's Web Fetches from Burning 700K Tokens on HTML Junk

A new MCP server, token-enhancer, strips scripts, nav bars, and ads from web pages before they hit Claude's context, cutting token waste by 90%+.

GAlex Martin & AI Research Desk·11h ago·3 min read·4 views·AI-Generated
Share:
Source: reddit.comvia reddit_claudeSingle Source

The Problem: Your Web Fetches Are 99% Noise

When you ask Claude Code to fetch a web page—to read documentation, check an API, or summarize an article—it doesn't get clean text. It gets the full HTML dump: navigation bars, JavaScript bundles, ad scripts, tracking pixels, and footer links. One developer found a single page that was 700,000 tokens. The actual content? Just 2,600 tokens.

That's 99.6% waste. You're paying for Claude to process megabytes of irrelevant markup.

The Solution: An MCP Proxy That Cleans Before Context

The fix is token-enhancer, an open-source Model Context Protocol (MCP) server that acts as a proxy. When Claude Code fetches a URL through it, the server:

  1. Downloads the page
  2. Strips all HTML tags, scripts, styles, and non-content elements
  3. Returns clean, readable text
  4. Claude Code receives only the meaningful content

This follows Anthropic's push to expand Claude Code's capabilities through MCP servers, like the recent integrations for Terraform and Ansible we covered on March 25th.

Install It in 2 Minutes

# Clone the repository
git clone https://github.com/Boof-Pack/token-enhancer
cd token-enhancer

# Install dependencies (requires Node.js)
npm install

# Configure Claude Code to use it
# Add to your Claude Code config file (~/.config/claude-code/config.json):
{
  "mcpServers": {
    "token-enhancer": {
      "command": "node",
      "args": ["/path/to/token-enhancer/src/server.js"],
      "env": {}
    }
  }
}

Restart Claude Code. The agent will now use the cleaner automatically when fetching web content through the MCP protocol.

When This Matters Most

  • Research tasks: When Claude needs to read multiple documentation pages
  • Competitive analysis: Fetching competitor websites for comparison
  • API integration: Reading API documentation from vendor sites
  • Content summarization: Any task where Claude needs to understand web content

The savings compound quickly. If your agent fetches 10 pages daily at 100K tokens each (with 90% waste), you're burning 900K tokens daily on HTML junk. That's roughly $9/day with Claude 3.5 Sonnet pricing.

Check Your Own Waste

Run Claude Code with verbose logging to see what's actually hitting context:

claude code --verbose your-task-here

Look for the context window usage reports. If web fetches are consuming disproportionate tokens, you need this MCP server.

gentic.news Analysis

This development highlights a critical, often-overlooked aspect of agentic workflows: context hygiene. While most optimization focuses on prompt engineering, the data entering Claude's context window is equally important. The token-enhancer MCP server represents a growing category of tools that pre-process inputs before they reach the model, aligning with the trend of MCP servers for major IaC tools that became available in late March.

The 700K-to-2.6K token ratio isn't an outlier—it's typical of modern web pages. As Claude Code's usage grows (appearing in 138 articles this week alone), developers are discovering these hidden costs. This follows our March 25th coverage of running Claude Code locally with Ollama, where cost control was a primary motivation.

Looking forward, expect more MCP servers that optimize inputs: image compressors before vision analysis, code minifiers before refactoring, and data sanitizers before analysis. The Model Context Protocol, developed by Anthropic and used by Claude Code in 23 documented integrations, is becoming the pipeline where efficiency battles are won or lost.

AI Analysis

**Immediate Action:** Install token-enhancer today if your Claude Code workflows involve web fetching. The setup takes minutes and the savings begin immediately. Configure it alongside other essential MCP servers like claude-flow (covered March 25th) for a complete optimized pipeline. **Workflow Change:** Stop using Claude's built-in web fetch without filtering. Either use the MCP server or implement your own preprocessing. For one-off fetches, consider copying text manually or using browser extensions to extract clean content first. **Monitoring:** Add token usage tracking to your Claude Code sessions. The `--verbose` flag shows context consumption—watch for web fetch spikes. Consider setting up alerts for sessions exceeding expected token counts, as this often indicates unfiltered web content.
Enjoyed this article?
Share:

Related Articles

More in Opinion & Analysis

View all