-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Description
Summary
The MCP server only returns console output as plain strings (via browser_console_messages and the console updates in snapshots). When pages log objects or emit multiple messages, MCP clients cannot see structured arguments, timestamps, or clear/limit the history. This makes debugging from agents harder than using the DevTools console.
Steps to reproduce
- Start the MCP server (e.g.,
npx @playwright/mcp --headless). - Open a page that logs objects and errors:
<script> console.log('hi', { foo: 1 }); console.error('oops'); </script>
- Call
browser_console_messages. - Observe that the output is flattened strings (object values lost) and there is no way to clear or paginate the console log.
Expected behaviour
- Ability to inspect console entries similar to the DevTools console: level, timestamp, source location, and serialized arguments.
- Option to limit how many entries are returned and clear the stored history after reading so agents can poll cleanly.
Proposal
- Add a new MCP tool
browser_console_panel(core capability) that:- accepts
level(error|warning|info|debug),limit(N most recent),includeArgs,includeTimestamp, andclearflags; - returns console entries formatted with level, ISO timestamp (optional), source URL/line, and serialized arguments/stack traces;
- optionally clears stored console messages when
clearis true.
- accepts
- Keep
browser_console_messagesunchanged for backward compatibility. - Introduce a gated DevTools data capability (e.g.,
--caps=devtools) that exposes CDP-backed tools without driving the DevTools UI:browser_network_entries(read-only): recent requests/responses with URL, method, status, timing, headers, and size; bounded bylimitand optional URL filter.browser_trace_capture(read-only, opt-in): start/stop a performance trace and return/save the trace JSON; optional categories and duration.browser_debugger_info(read-only): list loaded scripts and recent error stack traces; optionally capture a snapshot of active breakpoints later.browser_coverage_snapshot(read-only): return JS/CSS coverage percentages and per-script counts (if feasible via CDP).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels