Inspired by Armin, I decided to figure out how to use the official microsoft/playwright-mcp Playwright MCP server with Claude Code.
Short version: run this before starting claude
:
claude mcp add playwright npx '@playwright/mcp@latest'
That's it! Now when you run claude
Playwright will be available. You can say things like:
Use playwright mcp to open a browser to example.com
And a visible Chrome browser window, controlled by Claude Code, will open in front of you.
I found I needed to explicitly say "playwright mcp" the first time, otherwise it might try to use Bash to run Playwright instead.
The claude mcp add
command will persist but will only affect the directory in which you run it.
It took me a while to figure out how that works - eventually I tracked it down to a JSON file ~/.claude.json
which includes a "projects"
key with objects for each directory I had used with Claude Code in the past. That object includes MCPs and allowed commands as well.
Since Claude uses a visible browser window when interacting with Playwright, authentication is easy: have it show you a login page, then login yourself with your own credentials and tell it what to do next. Cookies will persist for the duration of the session.
With the MCP loaded you can run /mcp
and then navigate to playwright
to view all available tools. Here's the full list:
browser_close
(read-only)browser_resize
(read-only)browser_console_messages
(read-only)browser_handle_dialog
browser_file_upload
browser_install
browser_press_key
browser_navigate
browser_navigate_back
(read-only)browser_navigate_forward
(read-only)browser_network_requests
(read-only)browser_pdf_save
(read-only)browser_take_screenshot
(read-only)browser_snapshot
(read-only)browser_click
browser_drag
browser_hover
(read-only)browser_type
browser_select_option
browser_tab_list
(read-only)browser_tab_new
(read-only)browser_tab_select
(read-only)browser_tab_close
browser_generate_playwright_test
(read-only)browser_wait_for
(read-only)You don't have to reference these by name, Claude should usually be smart enough to pick the right one for the task at hand.
Created 2025-07-01T16:44:50-07:00 · Edit