chrome-dev-mcp

v2.0.1
io.github.congzhou09/chrome-dev-mcp Checked 3 days ago Published 10 days ago

Debug an already-running Chrome tab: breakpoints, stepping, scope variables, console, network

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_tabs

List open Chrome page tabs with their targetIds, titles and URLs. `active` marks a tab showing on screen — the selected tab of a window that is not minimised or fully covered, so several windows mean several — and is absent if the tab did not answer. `connected` marks the tab this server acts on; selecting another tab in Chrome does not change it, only switch_tab does.

switch_tab

Connect this server to another Chrome tab, without bringing it to the front. Breakpoints this server set in the previous tab are removed. A pause there ends, unless DevTools is open on that tab. The console and network buffers are emptied and refilled from the new tab.

ParameterTypeDescription
targetId *stringTarget ID from list_tabs

get_page_info

Get the URL and title of the currently connected tab, as `{ url, title }`. Still answers while the page is not responding.

get_html

Get the full HTML source of the currently connected tab (`document.documentElement.outerHTML`). Truncated to 20000 characters for large pages; a truncated result ends with a `…` marker giving how much was cut and the real length of the document, so a short result is never ambiguous between "small page" and "cut off here".

evaluate_js

Evaluate a JavaScript expression in the page, in global scope, with the same semantics as the DevTools console. Returns the real value when it serialises; objects that cannot (DOM nodes, Errors, Maps, class instances) come back as a preview instead: class name plus a first level of properties, marked `…` where Chrome truncated it — readable, not parseable as the value. Top-level `await` works (30s max), but an expression that merely RETURNS a promise is NOT awaited — it comes back as a pending Promise, exactly as in the console. The call returns as soon as your expression finishes its sy…

ParameterTypeDescription
expression *stringJS source evaluated as-is. A function is not called — wrap it: `(() => { ... })()`

get_computed_style

Get computed CSS values for the given properties on the first element matching `selector`.

ParameterTypeDescription
properties *arrayCSS property names to return (kebab-case or camelCase)
selector *stringCSS selector for the target element

screenshot

Capture a PNG screenshot of the current viewport (the visible page area only — not the full scrollable page, not the browser chrome, not DevTools), or of one rectangle of it with `region`. Captured at the tab's native pixel size unless you cap it with `maxEdge`; a capture that was scaled or cut says so in a note beside the image, which for a `region` also gives the CSS rect the image covers and how many image pixels a CSS pixel became. A tab that is not painting is raised in its window first, which changes which tab is selected there.

ParameterTypeDescription
maxEdgeintegerLongest side of the returned image, counted in its own pixels rather than CSS pixels, so the same value gives the same image on a 1x and a 2x tab. Scales down `region` when one is given, the viewport…
regionobjectCapture only this rectangle instead of the whole viewport. CSS pixels, measured from the top-left of the visible area — the same space `getBoundingClientRect()` reports in, so an element's box can b…

get_inspected_element

Get the element marked for MCP inspection. To mark an element: select it in the Elements panel, then run `window.$0 = $0` in the DevTools console. Returns an error if no element is marked.

navigate_tab

Navigate the connected tab to a URL and wait up to 30s for the new page's load event — or for execution to pause first, e.g. on a breakpoint the new page hits during startup, in which case the call stack is returned. `outcome` is "loaded", "paused", "still-loading" (the new page is in place but its load event had not fired by the deadline), "same-document" (only the #hash changed; there is no load to wait for) or "download" (the URL was downloaded and the page did not change). Breakpoints carry over to the new page. Also works while paused, no need to resume first: the pause ends with the ol…

ParameterTypeDescription
url *stringAbsolute URL, including the scheme.

reload_tab

Reload the connected tab and wait up to 30s for the new page's load event — or for execution to pause first, e.g. on a breakpoint hit during startup, in which case the call stack is returned. `outcome` is "loaded", "paused" or "still-loading" (the new page is in place but its load event had not fired by the deadline). Breakpoints carry over to the reloaded page. Also works while paused, no need to resume first: the pause ends with the old page.

ParameterTypeDescription
ignoreCachebooleanBypass the HTTP cache, as Shift+F5 does.

get_debugger_state

Get the debugger state: whether execution is paused, the pause reason, hit breakpoints and the full call stack. A pause is reported whatever caused it. `hitBreakpoints` lists only breakpoints set through this server, so it is empty at a breakpoint set in DevTools. Positions are 1-based, and source-mapped where the script has a source map. A source-mapped frame also gives `compiledUrl`/`compiledLine`/`compiledColumn`, its position in the loaded script.

get_scope_variables

Inspect variable values in a call frame scope. Only works when execution is paused. Use get_debugger_state first to find available frame indices.

ParameterTypeDescription
frameIndexnumberCall frame index (0 = top frame)
scopeTypestringScope type to inspect

set_breakpoint

Set a breakpoint at a 1-based line (and column) of a file. Name the file with `source` — a path like "src/App.tsx", or the `url` of a frame get_debugger_state or get_console_logs reported. Either way the position is mapped through source maps into the code Chrome runs, so that code must already be loaded. `url`/`urlRegex` instead take a position in the script exactly as Chrome loads it, so a source-mapped position given to them lands on the wrong line or never binds; use a frame's `compiledUrl`/`compiledLine`/`compiledColumn`. The script need not be loaded yet: an empty `resolvedLocations` m…

ParameterTypeDescription
lineNumber *integerLine number (1-indexed)
columnNumberintegerColumn number, 1-indexed (optional)
conditionstringJS expression; breakpoint triggers only when truthy
sourcestringFile to break in, as in your project: a path like "src/App.tsx" — more of it when the name alone matches several loaded files — an absolute path, or a source-mapped url. lineNumber and columnNumbe…
urlstringExact URL of the script as Chrome loaded it. Provide this, urlRegex or source; if both url and urlRegex, urlRegex takes precedence.
urlRegexstringRegex on the URL of the script as Chrome loaded it. Provide this, url or source; if both url and urlRegex, urlRegex takes precedence.

remove_breakpoint

Remove a breakpoint by ID. The ID is invalidated; use set_breakpoint to restore (returns a new ID).

ParameterTypeDescription
breakpointId *string

list_breakpoints

List breakpoints set through `set_breakpoint`. Breakpoints set in DevTools or by another CDP client are not listed.

pause_execution

Pause JavaScript at the next statement that runs, and return the call stack if that happens within 2s. On an idle page nothing runs, so the pause stays pending until script next does — a timer, an event, a click — and get_debugger_state reports it once it lands.

resume_execution

Resume execution while paused; it runs until the next breakpoint or pause. Returns at once rather than waiting for one.

ParameterTypeDescription
terminatebooleanResume, but skip the rest of the paused function and of its callers, finally blocks included, e.g. to stop an endless loop. The page may be left half-updated; reload_tab gives a clean state.

step_over

While paused, run the current statement without stepping into the functions it calls, and pause at the next statement. After an event handler or timer callback returns, the step stays in effect: it pauses at the first statement of whatever script runs next, which may be unrelated code. Returns the new call stack, or a note if execution has not paused again within 5s.

step_into

While paused, step into the function the current statement calls, or to the next statement if it calls none. After an event handler or timer callback returns, the step stays in effect: it pauses at the first statement of whatever script runs next, which may be unrelated code. Returns the new call stack, or a note if execution has not paused again within 5s.

evaluate_at_frame

Evaluate a JavaScript expression in the scope of a paused call frame — it reads local variables, closure variables and the current `this`, which evaluate_js cannot. Only works while execution is paused: when it is not, this returns an error rather than silently falling back to global scope. Results come back as a preview — class name plus a first level of properties, marked `…` where Chrome truncated it — readable, not parseable as the value. Use get_debugger_state to find frame indices.

ParameterTypeDescription
expression *stringJS source evaluated as-is. A function is not called — wrap it: `(() => { ... })()`
frameIndexnumberCall frame index (0 = top frame); use get_debugger_state to find available frames

step_out

While paused, run the rest of the current function and pause in its caller. An event handler or timer callback has no caller, so stepping out of one pauses in whatever script runs next. Returns the new call stack, or a note if execution has not paused again within 5s.

get_console_logs

Return browser console messages and uncaught exceptions, including the history already visible in DevTools before this server connected. Exceptions are reported with their full stack trace (source-mapped when available). Reloading or navigating the page does NOT clear this buffer: output from the old document stays and the new one is appended to it, so an entry carries `from` when it predates the document showing now. Replayed entries carry no `timestamp` — Chrome hands its backlog over without one.

ParameterTypeDescription
levelstringFilter by log level / type. Omit to return all levels.
limitintegerMaximum number of most-recent entries to return
sincestringHow far back to read: a lower bound rather than a label to match, since each value INCLUDES the newer ones. `current-page-load` is only the document showing now, which answers "did my change introduce…

get_network_requests

Return HTTP requests captured from the connected tab — method, URL, resource type, status, transferred size, duration, initiator, and failure reason. Capture starts when this server connects to the tab: requests issued before that are NOT visible (unlike get_console_logs, which replays pre-connect history). Requests belonging to a previous page are pruned on navigation, mirroring the DevTools Network panel default; the new document request itself is kept. A redirect chain appears as one record per hop, sharing a requestId and distinguished by `hop`. WebSocket frames are not captured. In a bu…

ParameterTypeDescription
headerKeysarrayReturn only these headers, matched case-insensitively, on both requestHeaders and responseHeaders. Omit to return no headers. Pass ["*"] for every header — that is bounded only by `limit`, so use it…
limitintegerMaximum number of most-recent requests to return
requestIdstringReturn only this request, including every hop of its redirect chain. Pair with headerKeys to inspect one request in full.
resourceTypestringFilter by CDP resource type. Any casing is accepted.
statusstringFilter by response status class, or by outcome: `failed` = network error/blocked, `pending` = still in flight.
urlFilterstringCase-insensitive substring match on the full (untruncated) request URL

get_network_response_body

Fetch the response body for one requestId from get_network_requests. Bodies are never buffered by this server — they are read from Chrome on demand, and Chrome discards them on navigation or when its own buffer limits are exceeded, so fetch promptly and before navigating away. Chrome stores at most one body per requestId, so for a redirect chain only the final hop has a body. Returns a JSON metadata block, then the body as a separate text block — kept separate so a large body is not JSON-escaped. Metadata carries requestId, `base64Encoded` (boolean; true when the body is base64, as CDP rep…

ParameterTypeDescription
requestId *string

clear_captures

Discard the buffers this server holds, so a following get_console_logs / get_network_requests shows only what happens next. Affects this server only: nothing is cleared in Chrome or in the DevTools UI, and capture keeps running — no reconnect or reload is needed. Cannot be undone. Console entries are gone for good, because Console.enable() replays history only at attach time. Cleared network requestIds still resolve in get_network_response_body for as long as Chrome itself holds the body; once Chrome drops it the error says the data was discarded rather than that the id is unknown. Works wit…

ParameterTypeDescription
targetsarrayWhich buffers to clear. Defaults to both.