Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chrome DevTools Pattern Detector

An MCP server that groups repeated browser errors and slow or failed requests, compares page performance against a saved baseline, and flags approximate heap growth.

New in 1.1.0: ordinary pages no longer need the demo's custom globals. Collection failures are reported as errors, and cached results are labeled explicitly.

Requirements and connection

  • Node.js ^20.19.0 || ^22.12.0 || >=23 and npm/npx.
  • Chrome with a dedicated debugging profile, accessible on localhost.
  • The adapter runs the pinned chrome-devtools-mcp@1.10.1 through npx. Its first invocation needs network access to install that package. Usage statistics and performance CrUX requests are disabled for this child process.

For example, on macOS:

"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
  --remote-debugging-port=9222 \
  --user-data-dir="$HOME/Library/Application Support/pattern-detector-chrome"

Open the site you want to inspect in that Chrome instance. This dedicated profile is separate from your normal Chrome profile. Keep the debugging endpoint on localhost.

Configure your MCP client:

{
  "mcpServers": {
    "pattern-detector": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-pattern-detector@1.1.0"],
      "env": {
        "PATTERN_DETECTOR_BROWSER_URL": "http://127.0.0.1:9222"
      }
    }
  }
}

For local development, run npm ci in the checkout and use node with the absolute path to mcp-server.js instead.

Inspection workflow

  1. Ask the MCP client to run detect_console_patterns with page_url set to the exact URL of your open page. This establishes the persistent DevTools connection.
  2. Reproduce the behavior in the browser.
  3. Run the relevant detector again. Repeat inspections replace console/network snapshots instead of counting the same records twice.

Example tool arguments:

{"page_url":"http://localhost:3000/","threshold":3,"format":"json"}

Use page_url for reliable targeting. It must match exactly one open tab, including query and fragment. page_id can disambiguate duplicate URLs; the returned MCP _meta.pageId identifies the inspected tab within this detector's DevTools session. IDs from a separate DevTools server are not guaranteed to match. With neither argument, the adapter uses its upstream session's selected page, which may differ from the foreground browser tab. It does not select the last tab or change tabs automatically. Navigation during collection is an error; retry after the page settles.

The upstream connection stays open between requests and closes when this MCP server closes. Earlier console/network activity may be unavailable: connect before reproducing the problem. Restart the MCP server if its Chrome connection is lost.

Tools

All detectors accept page_url, optional page_id, collect_fresh (default true), and format (text or json). Thresholds must be nonnegative.

Tool Signal and defaults
detect_console_patterns Repeated error messages; threshold: 3
detect_network_patterns Resource Timing entries exceeding threshold_ms: 2000, min_occurrences: 3
detect_failed_requests Repeated HTTP 4xx/5xx or transport failures; min_occurrences: 2
detect_resource_failures Failed image, stylesheet and script requests; min_occurrences: 2
detect_performance_degradation LCP/FCP/CLS change against the exact URL's baseline; lcp_threshold_ms: 1000, fcp_threshold_ms: 500, cls_threshold: 0.1; optional reset_baseline
detect_memory_leaks Compatibility tool name; reports heap growth, not a confirmed leak. Requires at least two inspections on one navigation; growth_threshold_mb: 10, growth_threshold_pct: 20
get_pattern_history Last saved console-pattern result for required page_url; no browser connection

For cached inspection, supply both collect_fresh: false and page_url. Cached observations do not prove the page is currently healthy. A failed fresh collection returns isError: true; it never substitutes old observations. MCP _meta records the page, collection mode, and coverage limitations. Text responses also identify fresh versus cached inspection.

Coverage and interpretation

  • Console/network results cover retained DevTools records since attachment, not a complete historical log. Observation timestamps are collection times, not original event times. Console locations currently identify the inspected page, not a source-code line.
  • Timing uses the browser's current Resource Timing buffer; evicted entries and cross-origin restrictions limit coverage. Method and status are left unknown rather than inferred from timing data.
  • Performance observers use buffered entries where available and continue observing after first inspection. LCP/CLS may still change, and earlier evicted entries may be absent. Compare equivalent page states. FCP and TTFB are supporting metrics; this is not a complete Core Web Vitals audit (INP is not implemented).
  • Heap samples use Chrome's approximate performance.memory, which may be quantized or unavailable. At most 120 samples are retained for the current navigation. Growth can be legitimate allocation; use heap profiling to investigate. JSON findings use type: "heap_growth".
  • Suggestions are rules of thumb, not established causes. No patterns above a threshold does not prove the absence of a problem.

Local state

State is keyed by a SHA-256 hash of the full page URL. Observations, the latest console result, and performance baselines are kept separately per URL; heap series reset on navigation. Tabs sharing a URL share the same saved baseline/cache. Cached mode reads that URL's last stored result, not a specific tab.

Default state location:

  • macOS: ~/Library/Application Support/chrome-devtools-pattern-detector
  • Other platforms: $XDG_STATE_HOME/chrome-devtools-pattern-detector, or ~/.local/state/chrome-devtools-pattern-detector
  • Override: PATTERN_DETECTOR_STATE_DIR

These files may contain URLs and console messages. They stay on disk until removed; there is no automatic age-based deletion. Stop the server before deleting its state directory to clear observations and baselines. Legacy 1.0.x files inside the installed package are not imported automatically because their page provenance is not reliable.

Development and verification

npm ci
npm test
npm run test:smoke
npm run test:live
npm audit --omit=dev
npm pack --dry-run

Unit tests cover adapter formats, pagination, errors and page identity. The smoke test exercises all seven tools with isolated cached state and checks that stdout remains MCP JSON. The live test launches a separate headless Chrome and ordinary local HTTP fixture, exercises fresh collection and cache isolation, then removes its temporary profile and state. Set CHROME_PATH when Chrome is not at the platform default. It never needs the demo's globals or your normal browser profile.

test-page.html remains an optional manual demonstration. Older phase documents and live-test-p4.mjs/live-test-p6.mjs describe the original instrumented demo and are not release acceptance tests.

See CHANGELOG.md for compatibility changes and PHASE7-ROADMAP.md for remaining work.

MIT license · jptrp on GitHub

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages