github microsoft/playwright-mcp v0.0.63

8 hours ago

🗄️ Browser storage & authentication state control

Full introspection and manipulation of browser storage, enabling reproducible auth flows, debugging, and stateful automation.

> playwright-cli state-save auth.json
> playwright-cli state-load auth.json

Inspect and manage cookies:

> playwright-cli cookie-list
> playwright-cli cookie-get session_id
> playwright-cli cookie-set session_id abc123 --domain=example.com
> playwright-cli cookie-delete session_id
> playwright-cli cookie-clear

Work directly with Web Storage APIs:

# LocalStorage
> playwright-cli localstorage-list
> playwright-cli localstorage-get theme
> playwright-cli localstorage-set theme dark
> playwright-cli localstorage-clear

# SessionStorage
> playwright-cli sessionstorage-list
> playwright-cli sessionstorage-set wizardStep 3
> playwright-cli sessionstorage-clear

Perfect for:

  • Persisting login sessions
  • Debugging auth and feature flags
  • Sharing reproducible browser state across runs

🌐 Powerful network & API request mocking

Intercept, mock, modify, or block network requests directly from the CLI — no test harness required.

Simple CLI-based request mocking

Mock responses by URL pattern with custom status codes, bodies, headers, or request mutations.

# Mock with custom status
> playwright-cli route "**/*.jpg" --status=404

# Mock with JSON body
> playwright-cli route "**/api/users" \
    --body='[{"id":1,"name":"Alice"}]' \
    --content-type=application/json

# Mock with custom headers
> playwright-cli route "**/api/data" \
    --body='{"ok":true}' \
    --header="X-Custom: value"

# Strip sensitive headers from outgoing requests
> playwright-cli route "**/*" --remove-header=cookie,authorization

Manage active routes:

> playwright-cli route-list
> playwright-cli unroute "**/*.jpg"
> playwright-cli unroute

Use cases:

  • Frontend development without a backend
  • Offline and error-state testing
  • Snapshot stability and deterministic rendering

Flexible URL pattern matching

Routes support glob-style patterns for precise targeting:

**/api/users           Exact path match
**/api/*/details       Wildcards within paths
**/*.{png,jpg,jpeg}    File extension matching
**/search?q=*          Query parameter matching

🧠 Advanced request handling with run-code

For conditional logic, request inspection, response mutation, or timing control, drop down to raw Playwright routing via run-code.

Conditional responses based on request data

> playwright-cli run-code "async page => {
  await page.route('**/api/login', route => {
    const body = route.request().postDataJSON();
    if (body.username === 'admin') {
      route.fulfill({ body: JSON.stringify({ token: 'mock-token' }) });
    } else {
      route.fulfill({ status: 401, body: JSON.stringify({ error: 'Invalid' }) });
    }
  });
}"

Modify real backend responses

> playwright-cli run-code "async page => {
  await page.route('**/api/user', async route => {
    const response = await route.fetch();
    const json = await response.json();
    json.isPremium = true;
    await route.fulfill({ response, json });
  });
}"

Simulate network failures

> playwright-cli run-code "async page => {
  await page.route('**/api/offline', route =>
    route.abort('internetdisconnected')
  );
}"

🧠 SKILLS

Local SKILLS installation

> playwright-cli install-skills

Other

Browser installation (renamed)

> playwright-cli install-browser

Ephemeral browser contexts (renamed)

> playwright-cli config --in-memory

Renamed from --isolated to better reflect behavior:

  • Browser profile lives only in memory
  • Nothing persisted to disk
  • Clean state on every run

Don't miss a new playwright-mcp release

NewReleases is sending notifications on new releases.