Skip to content

Feature : Expose a console panel in Playwright MCP #1284

@srijan2607

Description

@srijan2607

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

  1. Start the MCP server (e.g., npx @playwright/mcp --headless).
  2. Open a page that logs objects and errors:
    <script>
      console.log('hi', { foo: 1 });
      console.error('oops');
    </script>
  3. Call browser_console_messages.
  4. 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, and clear flags;
    • returns console entries formatted with level, ISO timestamp (optional), source URL/line, and serialized arguments/stack traces;
    • optionally clears stored console messages when clear is true.
  • Keep browser_console_messages unchanged 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 by limit and 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions