← THE LIBRARY

Engineering / Browser agent / FIELD GUIDE

Give Claude Code a browser with Playwright MCP

Add Microsoft's Playwright MCP server to Claude Code, run one web task on a public test page, and choose which browser actions need your yes.

Checked 22 Oct 2026

Pinned source guide with authored setup files. Original project by Microsoft; guide and labeled adaptations by Agent Setup Kits.

Use case
Web tasks from Claude Code
Architecture
Single agent, one MCP server
Trigger
Manual, in a session
Runs
Local browser, isolated profile
License
Apache-2.0
Human approval
Input actions ask first

First step

bash
claude mcp add playwright -- npx -y @playwright/mcp@0.0.83 --isolated

Copy this first step, then read the setup and the human approval notes before you go further.

01 / PURPOSE

The autonomous job

Open a web page, read it through accessibility snapshots, fill in and submit one form field, and report what changed. Page reads run freely; clicks and typing ask first; running arbitrary JavaScript and uploading files are denied.

02 / SYSTEM

Architecture and handoffs

Single agent with one local tool server. Claude Code starts @playwright/mcp 0.0.83 with npx over stdio. The server drives a real browser with Playwright and returns structured accessibility snapshots with element refs, so the model acts on page structure, not screenshots. --isolated keeps the browser profile in memory. A project .claude/settings.json allows read tools, asks before input actions and denies browser_evaluate, browser_run_code_unsafe and browser_file_upload.

System for Give Claude Code a browser with Playwright MCP Your machine, in-memory profile web task tool call allowed or approved Playwright actions page loads denied click/type prompt HUMAN Developer SERVICE Permission rules SERVICE Playwright MCP SERVICE Browser, isolated AGENT Claude Code SERVICE Websites SERVICE Run JS, upload files ASK ASK
Built from this kit's roles, tools and boundaryHumanAgentServiceBoundary
01 / HUMAN

Developer

Adds the server, writes the task, approves input actions and checks the result

HandoffDecides whether the page result is right

02 / AGENT

Claude Code agent

Chooses browser tools from the snapshots and reports what it did

HandoffReturns the result, or a pending action for approval

03 / SERVICE

Playwright MCP server

Runs browser actions with Playwright and returns snapshots and generated Playwright code

HandoffReturns tool results to Claude Code

Model
Whatever model your Claude Code session uses. Playwright MCP needs no model of its own.
Memory
None between sessions with --isolated: cookies, logins and storage are dropped when the browser closes. Without it, Playwright MCP keeps a persistent profile on disk by default (on Linux, 0.0.83 wrote to ~/.cache/ms-playwright-mcp/). The --help line about a temporary directory describes --user-data-dir, not the default.

03 / CONNECTIONS

Tools and triggers

Tool access described by this edition
ToolPurposeAccess
Read and navigate tools (browser_snapshot, browser_take_screenshot, browser_navigate, browser_tabs and others)Open pages and read their structure, console and network activityPre-approved in .claude/settings.json
Input tools (browser_click, browser_type, browser_fill_form, browser_press_key and others)Act on the pageAsk before every call
browser_evaluate, browser_run_code_unsafe, browser_file_uploadRun arbitrary JavaScript or send local files to a siteDenied in .claude/settings.json

What starts the work

  • Manual A developer gives Claude Code a web task in an interactive session in the project folder.
Permissions in this edition
ControlDecision
Open any URL your machine can reachYes
Read page structure, console messages and network requestsYes
Click, type, fill forms and press keys, each after a promptYes
Save snapshots and other output to .playwright-mcp/ in your project folder (add it to .gitignore)Yes
Enforced by Claude Code: input tools in the ask list prompt before every call; browser_evaluate, browser_run_code_unsafe and browser_file_upload are denied. Read the optional element description when it is there, next to target and the value; when it isn't, check target against the last snapshot.Ask
Not enforced: navigation is allowed, so Claude can open any URL without asking. Page content can contain instructions; treat what the agent reads as untrusted.Ask
The prompt that says 'do not visit any other site' is guidance, not a limit.Ask
Upstream offers --allowed-origins and --blocked-origins, but its README says they do not serve as a security boundary.Ask
The browser runs on your machine with your network access. --isolated keeps its profile in memory. Claude Code permission rules decide which browser tools run freely, ask or are denied. Upstream states that Playwright MCP is not a security boundary.Yes

04 / BOUNDARIES

Capabilities and safety

Credentials
None required. With --isolated the browser starts signed out. Do not sign in to accounts in an agent-driven browser unless you accept that the agent can act as you there.
Shutdown
browser_close or ending the Claude Code session closes the browser. claude mcp remove playwright removes the server.

Capabilities

  • Open any URL your machine can reach
  • Read page structure, console messages and network requests
  • Click, type, fill forms and press keys, each after a prompt
  • Save snapshots and other output to .playwright-mcp/ in your project folder (add it to .gitignore)

05 / SETUP

The files behind the workflow.

Original-project files retain their attribution and license; our installation notes, dependency profiles and custom wrappers are identified separately.

  1. Check Node.js

  2. Add the server

  3. Add the permission rules

  4. Run the first task

  5. Run the no-model check

add-playwright-mcp.shView file +

Adds Playwright MCP 0.0.83 to Claude Code with --isolated

Download add-playwright-mcp.sh ↓

#!/usr/bin/env bash
# Add Microsoft's Playwright MCP server to Claude Code, pinned to 0.0.83.
# Run in your terminal (not inside a Claude Code session), from your project root.
#
# --isolated keeps the browser profile in memory: no saved logins, cookies or
# history between sessions. Remove it only if you understand what a
# persistent profile keeps (see the kit page, 04 Boundaries).
set -euo pipefail

claude mcp add playwright -- npx -y @playwright/mcp@0.0.83 --isolated

claude mcp get playwright

Agent Setup Kits authored; adapted from the Claude Code section of the upstream README

mcp.jsonView file +

Save as .mcp.json in your project root. Project-scope alternative to the add script, same pin and flags

Download mcp.json ↓

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["-y", "@playwright/mcp@0.0.83", "--isolated"]
    }
  }
}

Agent Setup Kits authored; standard config shape from the upstream README

claude-settings.jsonView file +

Save as .claude/settings.json in your project. Allow read and navigate tools, ask before input tools, deny JavaScript and file upload tools

Download claude-settings.json ↓

{
  "permissions": {
    "allow": [
      "mcp__playwright__browser_snapshot",
      "mcp__playwright__browser_take_screenshot",
      "mcp__playwright__browser_find",
      "mcp__playwright__browser_wait_for",
      "mcp__playwright__browser_console_messages",
      "mcp__playwright__browser_network_requests",
      "mcp__playwright__browser_network_request",
      "mcp__playwright__browser_navigate",
      "mcp__playwright__browser_navigate_back",
      "mcp__playwright__browser_tabs",
      "mcp__playwright__browser_resize",
      "mcp__playwright__browser_close"
    ],
    "ask": [
      "mcp__playwright__browser_click",
      "mcp__playwright__browser_type",
      "mcp__playwright__browser_fill_form",
      "mcp__playwright__browser_select_option",
      "mcp__playwright__browser_press_key",
      "mcp__playwright__browser_hover",
      "mcp__playwright__browser_drag",
      "mcp__playwright__browser_drop",
      "mcp__playwright__browser_handle_dialog",
      "mcp__playwright__browser_emulate_media"
    ],
    "deny": [
      "mcp__playwright__browser_evaluate",
      "mcp__playwright__browser_run_code_unsafe",
      "mcp__playwright__browser_file_upload"
    ]
  }
}

Agent Setup Kits authored; all 25 tool names checked against tools/list from 0.0.83

first-task.mdView file +

A first web task on the public TodoMVC demo, plus a negative test

Download first-task.md ↓

# A first web task

Use the public Playwright TodoMVC demo. It is built for testing, needs no
login and holds nothing of yours.

Prompt for Claude Code:

    Use the playwright MCP server. Open https://demo.playwright.dev/todomvc/,
    add a todo called "Write the kit", then take a snapshot and tell me how
    many items are left. Do not visit any other site.

What should happen:

1. browser_navigate runs without a prompt (it is on the allow list).
2. Claude asks before browser_type. Read the target and the text, then allow.
3. browser_snapshot shows "Write the kit" in the list and an "item left"
   counter.
4. Claude reports one item left.

Playwright MCP saves snapshots and other output to .playwright-mcp/ in
your project folder. Add it to .gitignore.

Negative test: ask Claude to "run some JavaScript on the page to count the
todos". browser_evaluate and browser_run_code_unsafe are denied in
.claude/settings.json, so Claude should fall back to the snapshot or stop.

Agent Setup Kits authored

check_playwright_mcp.pyView file +

No-model check: starts the server, lists tools, adds one todo and reads it back

Download check_playwright_mcp.py ↓

"""Check Playwright MCP without any AI model.

Starts @playwright/mcp@0.0.83 over stdio, lists its tools, opens the
Playwright TodoMVC demo, adds one todo and reads it back from a snapshot.
Needs Node.js and a browser Playwright can launch. No API key.

    python3 check_playwright_mcp.py
"""
import glob
import json
import re
import subprocess

CMD = ["npx", "-y", "@playwright/mcp@0.0.83", "--headless", "--isolated",
       "--output-dir", "pw-check-output"]
proc = subprocess.Popen(CMD, stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True)
next_id = 0


def rpc(method, params=None, notify=False):
    global next_id
    msg = {"jsonrpc": "2.0", "method": method, "params": params or {}}
    if not notify:
        next_id += 1
        msg["id"] = next_id
    proc.stdin.write(json.dumps(msg) + "\n")
    proc.stdin.flush()
    while not notify:
        reply = json.loads(proc.stdout.readline())
        if reply.get("id") == next_id:
            return reply


def call(name, args):
    reply = rpc("tools/call", {"name": name, "arguments": args})
    return "\n".join(c.get("text", "") for c in reply["result"]["content"])


def latest_snapshot():
    return open(sorted(glob.glob("pw-check-output/page-*.yml"))[-1]).read()


try:
    rpc("initialize", {"protocolVersion": "2025-06-18", "capabilities": {},
                       "clientInfo": {"name": "kit-check", "version": "1"}})
    rpc("notifications/initialized", notify=True)
    tools = [t["name"] for t in rpc("tools/list")["result"]["tools"]]
    print("tools:", len(tools))
    call("browser_navigate", {"url": "https://demo.playwright.dev/todomvc/"})
    ref = re.search(r'textbox "What needs to be done\?".*?\[ref=(\w+)\]', latest_snapshot()).group(1)
    call("browser_type", {"element": "New todo input", "target": ref,
                          "text": "Write the kit", "submit": True})
    call("browser_snapshot", {})
    snap = latest_snapshot()
    print("todo added:", "Write the kit" in snap)
    print("counter:", re.search(r"text: (item[s]? left)", snap).group(1))
    call("browser_close", {})
finally:
    proc.kill()

Agent Setup Kits authored

SOURCE.mdView file +

Original-project attribution, source hashes and adaptation notes

Download SOURCE.md ↓

# Source and attribution

Playwright MCP is built and maintained by Microsoft:
https://github.com/microsoft/playwright-mcp

Pinned release: v0.0.83 (npm @playwright/mcp 0.0.83), commit
f183dad4a52965583e3cc1d59b88cdc279e2e57d
https://github.com/microsoft/playwright-mcp/commit/f183dad4a52965583e3cc1d59b88cdc279e2e57d

License: Apache-2.0 (LICENSE-playwright-mcp.txt is a verbatim copy of LICENSE
at the pinned commit).

Claude Code is Anthropic's product; permission rule syntax is from
https://code.claude.com/docs/en/permissions.

add-playwright-mcp.sh, mcp.json (save as .mcp.json), claude-settings.json
(save as .claude/settings.json), first-task.md and
check_playwright_mcp.py were written by Agent Setup Kits, adapted from the
upstream README at the pinned commit. The TodoMVC demo at
demo.playwright.dev is run by the Playwright project. Checked 22 Oct 2026.
Not affiliated with or endorsed by Microsoft or Anthropic.

Agent Setup Kits authored documentation for Pinned source guide with authored setup files; upstream code and licenses remain attributed separately

LICENSE-playwright-mcp.txtView file +

Upstream Apache-2.0 license

Download LICENSE-playwright-mcp.txt ↓

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright (c) Microsoft Corporation.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Verbatim copy of LICENSE at the pinned commit

Playwright MCP vs Playwright CLI

Microsoft ships two ways to give an agent Playwright, and the README is direct about the trade-off. For coding agents, it points to Playwright CLI with skills: CLI calls "are more token-efficient: they avoid loading large tool schemas and verbose accessibility trees into the model context." MCP, it says, "remains relevant for specialized agentic loops that benefit from persistent state, rich introspection, and iterative reasoning over page structure," such as exploratory automation, self-healing tests or long-running workflows.

Pick MCP when the agent needs to keep a browser open and reason about each page as it goes. Pick the CLI when the browser is one small part of a coding task and context space is tight. This kit covers MCP only.

06 / ORIGINAL WORK

Sources, pins, and license

This guide draws on Playwright MCP by Microsoft, at the linked source revision. Agent Setup Kits is independent of the upstream project. Edition-specific changes are labeled in the file provenance.

Playwright MCP, by Microsoft

Pinned source guide with authored setup files

Open source
Sources this edition relies on
SourceWhat it supports
Immutable source revision (tag v0.0.83) ↗Exact source snapshot for every flag and statement cited
README.md ↗Requirements, Claude Code install command, Playwright MCP vs Playwright CLI, persistent and isolated profiles and their paths, --user-data-dir, --storage-state, --port, the not-a-security-boundary statement, Docker headless chromium
package.json ↗npm package @playwright/mcp, engines node >=18 (stale: the playwright 1.64 dependency requires Node 20), playwright dependency
LICENSE ↗Apache-2.0 license
npm @playwright/mcp 0.0.83 ↗Published version used in the kit and the check
Playwright MCP getting started (official docs) ↗Official setup page; lists Node.js 20 or newer
Claude Code permissions docs (official) ↗mcp__server__tool rule names; bare-name deny removes a tool from context
Playwright TodoMVC demo ↗Public test page used for the first task
Source versions and guide targets
ComponentPinSource
@playwright/mcp (npm)0.0.83Original source ↗
Node.js20 or newer (checked on 20.19.2)Original source ↗

Apache-2.0

Playwright MCP is Apache-2.0. LICENSE-playwright-mcp.txt is a verbatim copy; all other kit files are authored by Agent Setup Kits. Sites you visit have their own terms.

Read the original license ↗

Related guides

Part of: Which setup should I use to add human approval to an agent?

Your privacy choices

Choose optional tools. Rejecting them keeps the setup library available. Advertising consent stays off.

Choices stay in this browser for 90 days. You can change them using Privacy settings. Privacy and cookie details