Skip to main content
Glama
mcp-snapshot-filter

mcp-snapshot-filter

by Akarda

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%

Related MCP server: playwright-slim-mcp

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 removed — role=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 collapsed — navigation/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 details — get_network_request, get_console_message are unfiltered

  • Non-interactive tools — emulate, 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).

Available Tools

29 tools
clickC

Clicks on the provided element

Inputs: uid (required), pageId (required), dblClick, includeSnapshot.

close_pageA

Closes the page by its index. The last open page cannot be closed.

Inputs: pageId (required).

dragB

Drag an element onto another element

Inputs: pageId (required), to_uid (required), from_uid (required), includeSnapshot.

emulateB

Emulates various features on the target page.

Inputs: pageId (required), viewport, userAgent, colorScheme, +4 more.

evaluate_scriptB

Evaluate a JavaScript function inside the target page. Returns the response as JSON, so returned values have to be JSON-serializable.

Inputs: pageId (required), function (required), args, filePath, +2 more.

fillB

Type text into an input, text area or select an option from a element.

Inputs: uid (required), value (required), pageId (required), includeSnapshot.

fill_formA

Fill out multiple form elements (inputs, selects, checkboxes, radios) at once. ALWAYS prefer this tool over multiple individual 'fill' or 'click' calls when interacting with forms. It is significantly faster, more reliable, and reduces turn count. Example: Fill username, password, and check "Remember Me" in one call.

Inputs: pageId (required), elements (required), includeSnapshot.

get_console_messageA
Read-only

Gets a console message by its ID. You can get all messages by calling list_console_messages.

Inputs: msgid (required), pageId (required).

get_network_requestA

Gets a network request by an optional reqid, if omitted returns the currently selected request in the DevTools Network panel. Useful for inspecting request headers (including 'Cookie') and response headers (including 'Set-Cookie' and directives).

Inputs: pageId (required), reqid, requestFilePath, responseFilePath.

handle_dialogA

If a browser dialog was opened, use this command to handle it

Inputs: action (required), pageId (required), promptText.

hoverB

Hover over the provided element

Inputs: uid (required), pageId (required), includeSnapshot.

lighthouse_auditA

Get Lighthouse score and reports for accessibility, SEO, best practices, and agentic browsing. This excludes performance. For performance audits, run performance_start_trace

Inputs: pageId (required), mode, device, outputDirPath.

list_console_messagesA
Read-only

List all console messages for the target page since the last navigation.

Inputs: pageId (required), types, pageIdx, pageSize, +3 more.

list_network_requestsA
Read-only

Lists the most recent requests for the target page since the last navigation.

Inputs: pageId (required), pageIdx, pageSize, resourceTypes, +1 more.

list_pagesA
Read-only

Get a list of pages open in the browser.

Inputs: no named parameters.

new_pageC

Open a new tab and load a URL. Use project URL if not specified otherwise.

Inputs: url (required), timeout, background, isolatedContext.

performance_analyze_insightA
Read-only

Provides more detailed information on a specific Performance Insight of an insight set that was highlighted in the results of a trace recording.

Inputs: pageId (required), insightName (required), insightSetId (required).

performance_start_traceA

Start a performance trace on the target webpage. Use to find frontend performance issues, Core Web Vitals (LCP, INP, CLS), and improve page load speed.

Inputs: pageId (required), reload, autoStop, filePath.

performance_stop_traceB

Stop the active performance trace recording on the target webpage.

Inputs: pageId (required), filePath.

press_keyA

Press a key or key combination. Use this when other input methods like fill() cannot be used (e.g., keyboard shortcuts, navigation keys, or special key combinations).

Inputs: key (required), pageId (required), includeSnapshot.

resize_pageB

Resizes the page's window so that the page has specified dimension

Inputs: width (required), height (required), pageId (required).

select_pageA
Read-only

Select a page as a context for future tool calls.

Inputs: pageId (required), bringToFront.

take_heapsnapshotA

Capture a heap snapshot of the target page. Use to analyze the memory distribution of JavaScript objects and debug memory leaks.

Inputs: pageId (required), filePath (required).

take_screenshotC

Take a screenshot of the page or element.

Inputs: pageId (required), uid, format, quality, +2 more.

take_snapshotA

Take a text snapshot of the target page based on the a11y tree. The snapshot lists page elements along with a unique identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot. The snapshot indicates the element selected in the DevTools Elements panel (if any).

Inputs: pageId (required), verbose, filePath.

type_textA

Type text using keyboard into a previously focused input

Inputs: text (required), pageId (required), submitKey.

upload_fileC

Upload a file through a provided element.

Inputs: uid (required), pageId (required), filePaths (required), includeSnapshot.

wait_forB
Read-only

Wait for the specified text to appear on the selected page.

Inputs: text (required), pageId (required), timeout.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 29 tools

    Disambiguation4/5

    Most tools target a clear, distinct browser action or data source, such as navigation, input, console messages, network requests, or performance tracing. The main ambiguity is between fill, fill_form, and type_text, though the descriptions reduce the risk of misselection.

    Naming Consistency3/5

    Most names follow a readable snake_case verb_noun pattern like list_pages, navigate_page, and take_snapshot. However, bare verbs such as click, fill, hover, and drag, plus deviations like lighthouse_audit, new_page, and wait_for, break the otherwise consistent style.

    Tool Count2/5

    At 29 tools, the surface is too large for a tightly scoped server and crosses the 25+ threshold. Several specialized debugging capabilities like heap snapshots, Lighthouse audits, and performance tracing could be separated into their own servers or grouped more compactly.

    Completeness4/5

    The tool set covers the full browser workflow well: page lifecycle, navigation, interaction, forms, dialogs, console and network inspection, screenshots, accessibility audits, performance tracing, and memory analysis. Minor gaps like direct cookie/storage manipulation or an explicit scroll helper can be worked around with evaluate_script or emulate.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers