How to save Playwright MCP session artifacts

Playwright MCP browser sessions often need evidence after an agent has finished interacting with a page. Saving session artifacts gives reviewers a filesystem record of snapshots, tool calls, traces, videos, and other files instead of relying only on transient MCP responses.

The standalone MCP server writes file-backed output when it is started with an output directory. Session logs are kept when --save-session is enabled, --output-mode file stores snapshot, console, and network results as files, and --caps=devtools exposes the trace and video tools to clients that need richer evidence.

Keep the artifact directory outside source control and treat it as sensitive evidence. Session logs can include page text, URLs, prompt-visible tool arguments, and trace or video material from authenticated pages.

Steps to save Playwright MCP session artifacts:

  1. Create a dedicated artifact directory.
    $ mkdir -p playwright-mcp-artifacts
  2. Start the standalone Playwright MCP server with file-backed output enabled.
    $ npx @playwright/mcp@latest --headless --port 8931 \
      --output-dir playwright-mcp-artifacts \
      --output-mode file \
      --save-session \
      --caps=devtools
    Listening on http://localhost:8931
    Put this in your client config:
    {
      "mcpServers": {
        "playwright": {
          "url": "http://localhost:8931/mcp"
        }
      }
    }
    For legacy SSE transport support, you can use the /sse endpoint instead.

    --output-dir chooses where files are written. --save-session records tool calls into a session folder. --caps=devtools is required for MCP trace and video tools.

  3. Point the MCP client at the printed /mcp URL.
    mcp-client-config.json
    {
      "mcpServers": {
        "playwright": {
          "url": "http://localhost:8931/mcp"
        }
      }
    }

    Keep localhost unless a separately protected remote listener is required. Leave the server terminal open while the client records artifacts.

  4. Ask the MCP client to open https://example.com.

    With --output-mode file active, snapshot-style tool results are saved into the output directory. Start and stop browser_start_tracing, browser_stop_tracing, browser_start_video, and browser_stop_video around the browser action when trace or video evidence is needed.

  5. List the saved artifact files after the browser action finishes.
    $ find playwright-mcp-artifacts -maxdepth 2 -type f
    playwright-mcp-artifacts/page-2026-07-07T01-48-17-390Z.yml
    playwright-mcp-artifacts/session-1783388897209/session.md
  6. Open the saved session log to confirm the recorded tool call.
    $ cat playwright-mcp-artifacts/session-1783388897209/session.md
    ### Tool call: browser_navigate
    - Args
    ##### snipped #####
    - Result
    ##### snipped #####
      "page": "- Page URL: https://example.com/\n- Page Title: Example Domain"

    Do not publish raw session logs from authenticated sites. Review and redact URLs, page text, form values, cookies, tokens, and screenshots before sharing the artifact directory.