mcp-browser-dev-tools
v0.0.3
Published
Local MCP server for Chromium DevTools Protocol and Firefox WebDriver BiDi
Maintainers
Readme
mcp-browser-dev-tools
mcp-browser-dev-tools is a local MCP server that lets AI clients inspect browser state through Chromium DevTools Protocol or Firefox WebDriver BiDi.
It is designed for a local trust boundary:
AI client -> MCP over stdio -> local broker -> browser adapter -> page target
What You Get
- A stdio MCP server for local desktop and terminal clients
- Browser discovery and attach/detach for Chrome, Edge, other Chromium-family browsers, and Firefox
- Tab lifecycle tools to create and close browser tabs through MCP
- Inspection tools for DOM lookup, richer element details, cookies, storage, console messages, network requests, HAR-like exports, screenshots, tab listing, and buffered events
- Page interaction tools for navigation, reload, click, hover, type, select, key presses, scroll, and viewport overrides
- Wait conditions for selector visibility, URL changes, and document ready state
- One-shot debug bundle capture for page state, storage summary, recent console, recent network, and screenshots
- Optional JavaScript evaluation behind an explicit environment flag
- Helper commands to check browser connectivity, launch a debug-enabled browser, and relay CDP traffic across a local machine boundary
Requirements
- Node.js
24+ - A local browser exposing either CDP or BiDi, or permission for the broker to launch one locally
- Loopback endpoints by default; remote endpoints require an explicit opt-in flag
Quick Start
In normal use, the only thing a user should need to do is register this MCP server in their agent client. After that, let the agent drive the browser through MCP.
If you want the simplest local path, start with the default auto setup. The broker can auto-discover loopback CDP and BiDi ports, launch a compatible browser through MCP, and in WSL bootstrap the Windows Chrome or Edge relay when your config asks it to.
Codex
codex mcp add browser-devtools -- npx -y mcp-browser-dev-tools serveClaude Code
claude mcp add browser-devtools --scope user -- npx -y mcp-browser-dev-tools serveCursor
{
"mcpServers": {
"browser-devtools": {
"command": "npx",
"args": ["-y", "mcp-browser-dev-tools", "serve"]
}
}
}These commands intentionally do not include a profile flag. They only start the MCP broker. Browser launch options belong to the later ensure_browser or launch_browser call that the agent makes after the broker is running, and the broker can auto-create a temporary Chromium-family profile when that is needed.
After Setup
Once the server is registered, the normal workflow is to ask the agent for browser work directly:
- open a browser to a URL and inspect the page
- attach to the current tab and inspect DOM, console, or network state
- take a screenshot or capture a debug report
The agent should usually start with ensure_browser. That tool can confirm browser availability, launch one if needed, and optionally open the requested URL in one step.
If the agent launches Chrome or Edge without userDataDir, the broker checks whether the same browser family is already running. If it is, the broker automatically creates a temporary profile directory before launching so the new debug flags are not swallowed by the already-running profile.
Typical temporary profile locations:
- Windows broker:
%TEMP%\\mcp-browser-dev-tools-edgeor PowerShell$env:TEMP\\mcp-browser-dev-tools-edge - macOS broker:
$HOME/Library/Caches/mcp-browser-dev-tools-profile - Linux or WSL broker:
$HOME/.cache/mcp-browser-dev-tools-profile
Use a path that matches the OS running the broker process. If you want a stable or reusable profile path, still pass userDataDir explicitly. If a browser is already open and already exposing a debug endpoint, the broker can still attach to it. If Chrome or Edge is already open without a debug endpoint, the automatic temporary profile is the default safety path for launches initiated through ensure_browser, launch_browser, or the manual open command.
Example ensure_browser payload for Chrome or Edge:
{
"browserFamily": "edge",
"url": "https://example.com"
}Add userDataDir only if you want to force a specific profile path.
When the broker launches a browser, the result reports the selected userDataDir, profileStrategy, and existingBrowserProcess state so the agent can see whether a temporary profile was chosen automatically.
MCP Client Configuration
The same launch-profile advice applies to every MCP client config below: if you later ask the agent to launch Chrome or Edge, you can pass userDataDir to force a specific profile path, but if you omit it the broker can auto-create a temporary profile when an already-running Chromium-family browser would otherwise swallow the new debug flags. The config commands themselves still only launch serve; they do not carry browser launch arguments.
Codex
Minimal local setup:
codex mcp add browser-devtools -- npx -y mcp-browser-dev-tools serveEquivalent ~/.codex/config.toml entry:
[mcp_servers.browser-devtools]
command = "npx"
args = ["-y", "mcp-browser-dev-tools", "serve"]Claude Code
Minimal local setup:
claude mcp add browser-devtools --scope user -- npx -y mcp-browser-dev-tools serveOn native Windows, wrap npx with cmd /c:
claude mcp add browser-devtools --scope user --env MCP_BROWSER_FAMILY=auto --env CDP_BASE_URL=http://127.0.0.1:9223 --env FIREFOX_BIDI_WS_URL=ws://127.0.0.1:9222 -- cmd /c npx -y mcp-browser-dev-tools serveEquivalent .mcp.json shape:
{
"mcpServers": {
"browser-devtools": {
"command": "npx",
"args": ["-y", "mcp-browser-dev-tools", "serve"]
}
}
}Cursor
Minimal local setup:
{
"mcpServers": {
"browser-devtools": {
"command": "npx",
"args": ["-y", "mcp-browser-dev-tools", "serve"]
}
}
}Common Variants
The default broker mode is auto. If you want to pin the broker to one browser family or one set of endpoints, change the environment in your MCP client config.
Auto mode with both browsers attached to one MCP server:
{
"MCP_BROWSER_FAMILY": "auto",
"CDP_BASE_URL": "http://127.0.0.1:9223",
"FIREFOX_BIDI_WS_URL": "ws://127.0.0.1:9222"
}Firefox:
{
"MCP_BROWSER_FAMILY": "firefox",
"FIREFOX_BIDI_WS_URL": "ws://127.0.0.1:9222"
}Microsoft Edge:
{
"MCP_BROWSER_FAMILY": "edge",
"CDP_BASE_URL": "http://127.0.0.1:9222"
}Manual Windows browser relay into WSL:
{
"MCP_BROWSER_FAMILY": "chromium",
"MCP_BROWSER_ALLOW_REMOTE_ENDPOINTS": "1",
"CDP_BASE_URL": "http://<windows-host-ip>:9223"
}If you only want a single CDP browser, switch MCP_BROWSER_FAMILY back to chromium or edge and omit FIREFOX_BIDI_WS_URL.
Enable evaluate_js:
{
"MCP_BROWSER_ENABLE_EVAL": "1"
}Enable unsafe browser launch args for launch_browser and ensure_browser:
{
"MCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS": "1"
}If you use WSL with a Windows Chrome or Edge browser, prefer serve --bootstrap-wsl-relay in the configured args instead of manually wiring relay. If you use Windows Firefox from WSL, or auto mode with both Windows Firefox and Windows Chrome or Edge, run the broker on Windows instead. Full examples are in docs/setup.md.
Advanced Environment Options
MCP_BROWSER_FAMILYdefaults toauto; setchromium,edge, orfirefoxto pin the broker to one browser familyCDP_BASE_URLdefaults tohttp://127.0.0.1:9222; when left at that default the broker probes loopback ports9222through9226for a reachable CDP browser endpointFIREFOX_BIDI_WS_URLdefaults tows://127.0.0.1:9222; when left at that default the broker probes loopback ports9222through9226, and when pointed at the root Firefox remote debugging port it connects to the/sessionwebsocket and creates a BiDi session there- in
automode, assign CDP and Firefox different ports so both browsers can run at once MCP_BROWSER_EVENT_BUFFER_SIZEsets the per-session buffered event limitMCP_BROWSER_LOG_LEVELcontrols diagnostic logging tostderr:error,warn,info, ordebugMCP_BROWSER_DEBUG_STDIO=1emits raw MCP stdio transport diagnostics tostderrMCP_BROWSER_ENABLE_EVAL=1enablesevaluate_jsMCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS=1exposes theunsafeArgslaunch option onlaunch_browserandensure_browserMCP_BROWSER_ALLOW_REMOTE_ENDPOINTS=1allows non-loopback CDP or BiDi endpointsMCP_BROWSER_ALLOW_REMOTE_CDP=1is still accepted as a legacy aliasMCP_BROWSER_WINDOWS_NODEoptionally overrides the Windowsnodeexecutable used byserve --bootstrap-wsl-relayMCP_PROTOCOL_VERSIONoverrides the advertised MCP protocol version
Exposed Tools
browser_statusreturns broker metadata too:serverNameandserverVersionInautomode it also includes per-browser adapter status underbrowsersProtocol adapters may also includeattemptedEndpointwhen discovery retries or fallback probing occurensure_browserEnsures a compatible browser is reachable, launches one if needed, and can open a tab for the requested URL in a single MCP call Inautomode, passbrowserFamilyFor Chrome or Edge launches,userDataDiris optional; if omitted, the broker auto-creates a temporary profile when an already-running browser process makes that necessary WhenMCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS=1, this tool also acceptsunsafeArgsas an array of browser flags. Broker-managed launch flags such as the debug port and profile path still cannot be overridden.launch_browserLaunches a local debug-enabled browser that matches the current broker configuration and can return an inline doctor report Inautomode, passbrowserFamilyFor Chrome or Edge launches,userDataDiris optional; if omitted, the broker auto-creates a temporary profile when an already-running browser process makes that necessary WhenMCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS=1, this tool also acceptsunsafeArgsas an array of browser flags. Broker-managed launch flags such as the debug port and profile path still cannot be overridden.list_tabsInautomode eachtargetIdis namespaced aschromium:<id>orfirefox:<id>new_tabInautomode, passbrowserFamilyclose_tablist_sessionsInautomode eachsessionIdis namespaced the same wayattach_tabdetach_tabget_page_statecompare_page_statecompare_selectorget_cookiesget_storagecapture_debug_reportcapture_session_snapshotrestore_session_snapshotget_harwait_fornavigatereloadclickhovertypeselectpress_keyscrollset_viewportget_console_messagesget_network_requestsget_documentinspect_elementtake_screenshotget_events
evaluate_js is intentionally disabled by default. Enable it only when you want the broker to allow page-side code execution.
Unsafe browser launch flags are also disabled by default. If you enable MCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS=1, pass only full flag strings such as --remote-allow-origins=http://localhost:9222. This does not enable evaluate_js, and it still does not let callers replace broker-managed launch flags like --remote-debugging-port or --user-data-dir.
For tools that take sessionId, call attach_tab first and reuse the returned session.
Locator Syntax
Interaction and inspection tools accept these locator forms:
- CSS selectors such as
#app button.primaryorcss=.modal button - visible-text lookup such as
text=Open settings - role plus accessible name such as
role=button[name="Open settings"] - accessible-name lookup such as
name=Open settings
inspect_element returns layout and accessibility-focused metadata including bounding box, visibility flags, interactivity flags, accessible name, inferred role, and a subset of computed styles. Invalid CSS selectors now return an explicit locator error instead of a generic DOM failure.
Screenshot Output
take_screenshot returns base64 image data plus metadata such as mimeType, byteLength, and scope. Pass selector to capture a single element instead of the full page.
Session Snapshots
get_cookiesreturns bounded page-visible cookies from the attached page contextget_storagereturns boundedlocalStorageandsessionStorageentries and can filter to one storage areacapture_debug_reportbundles page state, cookie/storage summaries, recent console messages, recent network requests, and an optional screenshotcapture_session_snapshotexports bounded page-visible cookies plus local and session storage for later reuserestore_session_snapshotrestores a captured snapshot onto the current origin and can optionally clear storage firstget_harexports buffered network activity in a bounded HAR-like JSON structurecompare_page_stateandcompare_selectorcompare bounded state across two attached sessions, which is especially useful inautomode
Browser Notes
- Chromium uses the standard DevTools endpoints at
/json/versionand/json/list - Firefox support expects a direct BiDi websocket endpoint
- In WSL, Linux browser executables are preferred before Windows fallback paths
- For Windows Chrome or Edge + WSL, prefer the broker-managed relay path over changing the browser's remote debugging bind
Why Not Playwright?
Playwright is still the stronger choice for deterministic browser automation and end-to-end tests. It has a more mature locator model, assertions, waiting semantics, tracing, and CI story.
mcp-browser-dev-tools solves a different problem:
- it is MCP-native, so AI clients call a bounded tool surface instead of generating and executing Playwright scripts
- it can inspect an already-open browser tab or create a fresh one, then inspect the current session state, cookies, login state, extensions, console, and network history
- it is designed for local AI debugging workflows, including loopback-only defaults, opt-in evaluation, and the Windows-to-WSL relay path
- it presents one MCP interface across Chromium CDP and Firefox BiDi instead of requiring the AI client to know browser protocol details
Use Playwright when you want reproducible automation. Use this project when you want an AI assistant to inspect and manipulate a live browser session through MCP.
Debugging Notes
attach_tabnow seeds network history from the Performance API so already-loaded pages still show useful requests- console buffers include source URL, line and column where the browser reports them, plus stack frames when available
get_page_statereports the current URL, title, viewport, and scroll position without enablingevaluate_js- broker diagnostics write to
stderrsostdoutstays reserved for MCP protocol traffic
Safety Defaults
- The broker only allows loopback browser endpoints unless you opt in
- The default tool surface is read-focused
- Arbitrary page evaluation is opt-in
- Clients interact with a bounded MCP tool surface instead of raw browser protocol calls
Development
corepack enable
pnpm install
pnpm run check
pnpm run pack:checkThe repository uses pnpm for local development and CI. End-user installation and publish flows still target the npm registry.
Additional docs:
