Skip to main content
Glama

browser-mcp

browser-mcp is a small browser-runtime MCP server for coding agents. It connects directly to a Chrome DevTools Protocol (CDP) endpoint and exposes eight high-level tools instead of mirroring the very large CDP API.

Tools

Tool

Purpose

get_pages

List tabs, refresh the default to the focused page, and begin console/network capture

inspect_page

Return a compact, bounded DOM tree

inspect_element

Inspect one CSS-selected element, its box and computed style

pick_element

Highlight the page and block until the user clicks a visually referenced element

evaluate

Evaluate JavaScript, await promises, and test runtime mutations

screenshot

Return a viewport or full-page image to the agent

get_console

Read buffered console events or wait for the next matching event

get_network

Read buffered requests or wait for the next matching request

All potentially large outputs have hard limits. Network output intentionally excludes headers such as Authorization and Cookie.

Related MCP server: chrome-devtools-mcp

Requirements

  • Node.js 22 or newer

  • Chrome, Chromium, or Chrome for Testing with a CDP HTTP endpoint

  • Cursor or another MCP client that supports stdio servers

Chrome 136 and newer ignore --remote-debugging-port for the normal Chrome profile. Use a separate --user-data-dir, which is also the safer way to give an agent runtime access.

Install and build

npm install
npm run build

The ordinary settings are at the top of src/config.ts. The CDP endpoint defaults to http://127.0.0.1:9222; set BROWSER_CDP_URL only when a different local endpoint is needed.

Start Chrome with CDP

Close or leave your ordinary Chrome untouched, then start a separate debugging profile.

macOS:

open -na "Google Chrome" --args --remote-debugging-port=9222 --user-data-dir=/tmp/browser-mcp-profile

Linux:

google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/browser-mcp-profile

Windows PowerShell:

& "$env:ProgramFiles\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="$env:TEMP\browser-mcp-profile"

Open http://127.0.0.1:9222/json/list to verify that Chrome is exposing tabs.

Configure Cursor

Create or edit .cursor/mcp.json in the project that should use the tools. Replace the path with the absolute path to this project.

{
  "mcpServers": {
    "browser-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/browser-mcp/dist/server.js"],
      "env": {
        "BROWSER_CDP_URL": "http://127.0.0.1:9222"
      }
    }
  }
}

Restart or reload Cursor after changing the configuration. Cursor CLI users can verify the registration with agent mcp list-tools browser-mcp.

Suggested agent flow

The server sends model-facing instructions with its MCP initialization response. They tell the agent to treat the user as an active debugging partner and use page-runtime or two-phase coordination instead of guessing. No workflow depends on the client rendering an input or confirmation form.

For element work:

  1. get_pages

  2. inspect_page when the target is already identifiable

  3. For phrases such as “this logo”, the agent tells the user what to click and calls pick_element({ interaction_prompt: "Click the logo you mean · Esc to cancel" })

  4. The browser page displays that instruction, highlights hovered elements, and waits for a click

  5. The same tool call returns the clicked element's selector, tag, text, box, and clipped HTML; Escape cancels

  6. inspect_element, evaluate, and screenshot can then analyze, test, and verify the change

get_pages refreshes the default page on every call. It prefers the page for which document.hasFocus() is true and visibilityState is visible; if Chrome reports no focused page, it falls back to the first current /json/list page. Passing page_id targets only that tool call and never changes the default. Call get_pages again after the user opens or switches tabs when subsequent calls will omit page_id.

For a network action:

  1. get_pages

  2. The agent calls get_network({ capture_action: "start" }) and retains the signed captureId

  3. The agent tells the user in ordinary chat exactly what browser action to perform; the page displays a green capture-active banner

  4. After the user reports completion, the agent calls get_network({ capture_action: "finish", capture_id: "...", ...filters })

  5. The finish call returns only requests whose event sequence began after the start boundary

The same start/chat/finish transaction works for console output with get_console. Results include startedAt, finishedAt, and per-event sequence numbers. Filters are evaluated on the finish call, so repeat the desired filters there.

The older wait_for_next mode remains available when the desired endpoint is one specific event rather than a user-confirmed capture window. wait_until controls whether a network wait ends when the request starts, its response arrives, or loading finishes.

Calling pick_element without interaction_prompt uses the default page banner. Supplying it changes only the banner text; both paths use the same blocking page-runtime picker. A client's tool-permission prompt merely authorizes execution and is not treated as interaction completion. For less common DOM events, evaluate can install a one-shot event listener and return a Promise that resolves after the user action.

Console and network capture begin when get_pages (or the first page-specific tool) attaches to the tab. They cannot reconstruct events that Chrome no longer has after a disconnected session.

v0.5.0 boundaries

  • Direct CDP-over-WebSocket connection only. Chrome 144's consent-based --autoConnect flow for attaching to an ordinary running profile is not implemented in this version.

  • The main frame and open shadow roots are inspectable. Cross-origin iframe contents require a later multi-target implementation.

  • get_network returns metadata, not response bodies or WebSocket frames.

  • pick_element waits up to two minutes; click an element or press Escape.

  • evaluate is intentionally powerful and can mutate the page or read data available to page JavaScript. Use a dedicated debugging profile.

Development

npm test

The test suite covers the MCP tool catalog, CDP command/event transport, output limits, selector interpolation safety, and an end-to-end fake-CDP flow through all eight runtime operations.

References

Available Tools

8 tools
evaluateEvaluate JavaScriptA
Destructive

Evaluate JavaScript in the selected page's main runtime. Supports promises and mutations, so an expression can install a one-shot DOM event listener and resolve after the user acts. Results must be serializable.

Inputs: expression (required), page_id, await_promise.

get_consoleGet console eventsA

Read console events or coordinate a user action without client forms. For collaboration: call capture_action=start, retain captureId, ask the user to reproduce the event in chat, then call finish with capture_id and filters.

Inputs: clear, level, limit, page_id, +5 more.

get_networkGet network requestsA

Read requests or coordinate a user action without client forms. For collaboration: call capture_action=start, retain captureId, ask the user to perform the action in chat, then call finish with capture_id and filters.

Inputs: clear, limit, method, page_id, +9 more.

get_pagesGet browser pagesC
Read-only

List Chrome page tabs, refresh the default to the currently focused tab, and start console/network capture. Call again after the user switches or opens a tab.

Inputs: no named parameters.

inspect_elementInspect one elementA
Read-only

Inspect the first element matching a CSS selector: stable selector, attributes, box, selected computed styles, relatives, text and clipped outer HTML.

Inputs: selector (required), page_id.

inspect_pageInspect page structureA
Read-only

Return a compact, visibility-aware DOM tree with useful attributes and short text. Prefer this over dumping document HTML. If the user's visual reference remains ambiguous, stop guessing and use pick_element with an interaction prompt.

Inputs: page_id, max_depth, max_nodes, include_hidden.

pick_elementPick an element interactivelyA

Resolve visual phrases such as 'this logo' with the page-runtime picker. Tell the user what to click before calling. The call blocks while the page highlights hovered elements, then returns the clicked element; Escape cancels. interaction_prompt changes only the page banner and never opens a client form.

Inputs: page_id, interaction_prompt.

screenshotCapture screenshotA
Read-only

Capture the viewport or full page and return it as MCP image content for visual verification.

Inputs: format, page_id, quality, full_page.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 8 tools

    Disambiguation4/5

    Most tools target distinct resources (tabs, screenshots, console, network, DOM, JS runtime). The main overlap is between inspect_page (page-level DOM tree) and inspect_element (single element by selector), and to a lesser degree pick_element, which all deal with element resolution. Descriptions clarify the intended boundaries, so misselection is possible but manageable.

    Naming Consistency4/5

    Mostly follows a verb_noun or clear verb pattern (get_pages, get_console, get_network, inspect_page, inspect_element, pick_element). A few bare forms (screenshot, evaluate) deviate slightly but remain unambiguous and readable. Convention is consistent enough to predict tool behavior.

    Tool Count5/5

    Eight tools is a well-scoped surface for browser automation. Each tool earns its place across observation, inspection, interaction, and collaboration workflows without redundancy.

    Completeness4/5

    Covers observation (screenshot, console, network, DOM) and interaction (evaluate, pick_element) well, but lacks a dedicated navigation tool and direct click/type actions. These are workable via evaluate, so gaps are minor rather than blocking.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers