mcp-snapshot-filter

mcp-snapshot-filter

A proxy server that intercepts and filters content-heavy responses from chrome-devtools-mcp, reducing token consumption by 40-60% for browser automation tools like Claude Code.

Category
访问服务器

README

mcp-snapshot-filter

MCP proxy that sits between Claude Code and chrome-devtools-mcp, intercepting content-heavy responses and applying smart filtering to reduce token usage by 40-60%.

Claude Code  <--stdio-->  mcp-snapshot-filter  <--stdio-->  chrome-devtools-mcp

Why?

Browser MCP tools (especially take_snapshot) return massive accessibility trees that fill up the context window fast. A single snapshot of a data-heavy page can be 30-40KB of text. This proxy transparently filters that down without breaking any tool interactions.

Real-world results:

Page Original Filtered Reduction
GitHub repo page 29.5KB 22.8KB 23%
Portal with 36-row data table 38.5KB 17.3KB 55%

Setup

# Clone and build
git clone https://github.com/Akarda/mcp-snapshot-filter.git
cd mcp-snapshot-filter
npm install
npm run build

Add to ~/.claude.json (replace any existing chrome-devtools entry):

{
  "mcpServers": {
    "chrome-devtools": {
      "type": "stdio",
      "command": "node",
      "args": [
        "/path/to/mcp-snapshot-filter/dist/index.js",
        "--filter-level=moderate",
        "--",
        "npx", "-y", "chrome-devtools-mcp@latest"
      ]
    }
  }
}

Restart Claude Code to pick up the new config.

Filter Levels

Setting Light Moderate (default) Aggressive
maxNodes 1000 500 300
maxDepth 20 15 10
maxSimilarSiblings 5 3 2
Strip decorative nodes yes yes yes
Collapse navigation no yes yes
Focus main content only no no yes
Est. reduction 20-30% 40-60% 60-80%

Use --filter-level=off to disable all filtering and pass through raw responses.

What Gets Filtered

Snapshot filtering (biggest impact)

  • Decorative nodes removedrole=none/presentation/separator, empty text nodes, unnamed generic wrappers are stripped (children promoted up)
  • Similar siblings collapsed — after N consecutive siblings with the same role (e.g., 50 StaticText nodes in a table), keeps first N and shows ... [47 more StaticText elements collapsed]
  • Navigation collapsednavigation/banner/contentinfo/menu subtrees reduced to a single summary: [navigation: 21 items, 9 links]
  • Main content focus (aggressive only) — when role=main exists, sibling subtrees are summarized
  • Depth/node limits — prunes beyond maxDepth, caps total node count

Network request filtering

Strips image, font, stylesheet (and media in aggressive) entries from list_network_requests output. All xhr, fetch, document requests remain visible. get_network_request is never filtered — individual request details always pass through in full.

Console message filtering

Strips debug, verbose (and dir, trace at higher levels) from list_console_messages. Error and warning messages are always preserved.

Evaluate script & memory snapshot filtering

Large responses from evaluate_script and take_memory_snapshot are truncated:

  • JSON arrays — kept to first N items (100/30/10 depending on level)
  • HTML dumps — truncated at max text length
  • Plain text — truncated at max text length (100KB/50KB/20KB depending on level)

What Is NOT Filtered

  • Error responses — always passed through raw
  • Image content blocks — screenshots etc. are never touched
  • Unknown/new tools — only explicitly listed tools get filtered, everything else passes through
  • Individual request/message detailsget_network_request, get_console_message are unfiltered
  • Non-interactive toolsemulate, performance_*, screencast_*, etc. pass through as-is

UID Integrity

All UIDs of visible nodes are preserved in filtered output. After taking a filtered snapshot, you can click, fill, or hover any UID shown in the output — the proxy forwards these calls to the upstream server unchanged.

Session Stats

Each filtered response includes a stats line:

[cdp-filter-proxy: 20.7KB saved (55%) | session: 22.4KB saved across 2 calls (52%)]

How It Works

The proxy uses the MCP SDK's low-level Server class (not McpServer) to avoid JSON Schema to Zod conversion issues when proxying tool definitions. On startup it:

  1. Spawns the upstream chrome-devtools-mcp as a subprocess via StdioClientTransport
  2. Discovers all upstream tools via listTools()
  3. Re-exposes them via setRequestHandler(ListToolsRequestSchema) and setRequestHandler(CallToolRequestSchema)
  4. For calls to content-heavy tools, parses the response text into markdown sections (## Latest page snapshot, etc.), applies the appropriate filter to each section, and returns the filtered result

Compatibility with --slim mode

chrome-devtools-mcp supports a --slim flag that reduces the server to just 3 tools (navigate, evaluate, screenshot) for maximum token savings (~368 tokens). If the proxy detects --slim in the upstream args, it will warn that filtering has no effect — slim mode responses are already minimal. The proxy is designed for full mode where it preserves all tools while reducing response sizes by 40-60%.

Development

npm run build    # compile TypeScript to dist/

After rebuilding, restart Claude Code to pick up changes (MCP servers are long-lived processes).

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选