Skip to content

Commit f15b9a3

Browse files
authored
chore(claude): add playwright mcp (#15447)
- Add Playwright MCP server configuration for Claude Code (.mcp.json), Cursor (.cursor/mcp.json) and VSCode (.vscode/mcp.json) - Enable the MCP server in Claude settings (.claude/settings.json) - Document Playwright MCP usage in CLAUDE.md to make sure the agent knows when to use it
1 parent 6c07f3b commit f15b9a3

File tree

6 files changed

+91
-1
lines changed

6 files changed

+91
-1
lines changed

.claude/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
}
2424
]
2525
},
26+
"enableAllProjectMcpServers": true,
27+
"enabledMcpjsonServers": ["playwright"],
2628
"permissions": {
2729
"allow": [
2830
"Bash(gh issue view:*)",

.cursor/mcp.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"mcpServers": {
3+
"playwright": {
4+
"command": "pnpm",
5+
"env": {},
6+
"args": [
7+
"dlx",
8+
"@playwright/mcp@latest",
9+
"--caps=vision,verify,tracing,devtools",
10+
"--isolated",
11+
"--headless"
12+
]
13+
}
14+
}
15+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ GitHub.sublime-settings
263263
!.vscode/launch.json
264264
!.vscode/extensions.json
265265
!.vscode/*.code-snippets
266+
!.vscode/mcp.json
266267

267268
# Local History for Visual Studio Code
268269
.history/
@@ -353,3 +354,6 @@ licenses.csv
353354

354355
# SQLite DB
355356
payload.db
357+
358+
# Screenshots created by Playwright MCP
359+
.playwright-mcp

.mcp.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"mcpServers": {
3+
"playwright": {
4+
"command": "pnpm",
5+
"env": {},
6+
"args": [
7+
"dlx",
8+
"@playwright/mcp@latest",
9+
"--caps=vision,verify,tracing,devtools",
10+
"--isolated",
11+
"--headless"
12+
]
13+
}
14+
}
15+
}

.vscode/mcp.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"servers": {
3+
"playwright": {
4+
"command": "pnpm",
5+
"env": {},
6+
"args": [
7+
"dlx",
8+
"@playwright/mcp@latest",
9+
"--caps=vision,verify,tracing,devtools",
10+
"--isolated",
11+
"--headless"
12+
]
13+
}
14+
}
15+
}

CLAUDE.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CLAUDE.md
22

3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
3+
This file provides guidance to Claude Code (claude.ai/code) and Cursor when working with code in this repository.
44

55
## Project Structure
66

@@ -84,6 +84,45 @@ Payload is a monorepo structured around Next.js, containing the core CMS platfor
8484
- Default database is MongoDB (in-memory). Switch to Postgres with `PAYLOAD_DATABASE=postgres`
8585
- Docker services: `pnpm docker:start` / `pnpm docker:stop` / `pnpm docker:restart`
8686

87+
### Playwright MCP
88+
89+
You should have access to the Playwright MCP server. This MCP server enables LLMs to interact with web pages through structured accessibility snapshots, bypassing the need for screenshots or visually-tuned models.
90+
91+
**Prerequisites:**
92+
93+
- The dev server MUST be running (`pnpm run dev`) before using the MCP
94+
- First call `browser_install` to set up the browser if needed
95+
96+
**Key tools (not exhaustive):**
97+
98+
- `browser_navigate` - Navigate to a URL
99+
- `browser_snapshot` - Get accessibility snapshot of current page
100+
- `browser_click` - Click elements (requires `ref` from snapshot)
101+
- `browser_fill_form` - Fill form fields
102+
- `browser_take_screenshot` - Capture screenshot (use `fullPage: true` for full page)
103+
104+
**Screenshots for visual verification:**
105+
106+
Use `browser_take_screenshot` to visually verify UI state. Useful for:
107+
108+
- Confirming layout and styling look correct
109+
- Checking component rendering (tags, forms, tables)
110+
- Debugging UI issues that aren't visible in accessibility snapshots
111+
112+
```
113+
browser_take_screenshot() # Viewport only
114+
browser_take_screenshot({ fullPage: true }) # Full scrollable page
115+
```
116+
117+
Screenshots are saved to `.playwright-mcp/` and displayed inline.
118+
119+
**Usage flow:**
120+
121+
1. Ensure dev server is running on `localhost:3000`
122+
2. Call `browser_navigate` to open a page
123+
3. Call `browser_snapshot` to get element refs
124+
4. Use refs to interact with `browser_click`, `browser_fill_form`, etc.
125+
87126
## Testing
88127

89128
### Writing Tests - Required Practices

0 commit comments

Comments
 (0)