Playwright MCP
bundled- Compact, delta and UNCHANGED snapshots
- Session recovery, same URL restored
- Screenshot policy, eval cache
- --codegen none, batching hints
One config entry runs five MCP servers behind a single connection, for Claude Code, Claude Desktop, Cursor and Codex. It revives crashed sessions and strips 70–90% of snapshot tokens before any of it reaches your agent.
claude mcp add playguard -- npx -y playguard@latestBuilt for agent-driven front-end work: browser QA, Figma-to-code, Shopify themes. Each upstream is switched on by its own env vars in the same config entry; leave them out and that server never starts. A failing upstream removes only its own tools.
bundledFIGMA_MCP_CMD · FIGMA_MCP_URLDEVTOOLS_MCP_CMDSHOPIFY_DEV_MCP_CMDCONTEXT7_MCP_CMDplayguard_*Optional upstreams start lazily. tools/list waits up to 6 s for a slow one, then announces its tools later with tools/list_changed.
One merged tool list. Each call goes to whichever upstream advertised the tool.
browser_* → playwright
get_figma_data → figma
list_network_* → devtools
search_docs_chunks → shopify
query-docs → context7Dead browsers and crashed upstream processes are restarted, the last URL restored, the call retried.
Target closed
ECONNREFUSED
→ retried ✓Snapshots compacted and diffed, Figma trees trimmed, network lists summarized, doc answers rewritten.
124.3 KB → 14.1 KB
34K chars → ~1KRepeats cost one line. UNCHANGED pages, a short eval cache, doc lookups kept on disk for 24 h.
← UNCHANGED
.cache/docs/ hit
log → *.ndjsonEvery interactive element survives. What goes is the static text and wrappers your agent was paying to read.
npm run analyze — see Measuring it yourself.100 copies of the same card? The agent gets one full subtree and 99 _sameAs stubs. No-op styles dropped, float noise rounded, every top-level frame kept. On raw Figma API JSON: metadata cleaned, components deduped, SVGs referenced.
No screenshots, no eyeballing, no “looks about right”. Works with the Framelink upstream.
playguard_a11y_audit runs axe-core inside the page your agent already has open and hands back a short report instead of axe's raw JSON: rules sorted by impact, a selector, an html excerpt and the first fix for each element.
#cart-drawer after opening itbest-practice or wcag2aaa[PlayGuard a11y: 6 violations · 7 rules passed · axe 4.14.0 · wcag2a,wcag2aa,…] critical image-alt — Images must have alternative text - img <img src="…" class="hero"> Element does not have an alt attribute (+4 more) serious color-contrast — Minimum contrast ratio - main > p <p style="color:#bbb">Low contrast text</p> Contrast 1.91 (#bbbbbb on #ffffff). Expected 4.5:1
| PARAMETER | WITHOUT | WITH PG-01 |
|---|---|---|
| Browser crash | Agent gets “Target closed” | Restarted, URL restored, retried |
| Crash during two calls | Two failures, or two browsers | One restart; both calls continue |
| Snapshot size | Full tree, 100–500 KB every call | Compacted + diffs, 70–90% less |
| Repeat reads | Fetched again | UNCHANGED, TTL cache |
| Figma JSON (Framelink) | Raw, duplicated, 200–500 KB | Optimized, deduped, 60–150 KB |
| DevTools network list | 7–34K chars on a busy page | ~0.6–1K chars summary, failures kept |
| DevTools repeat snapshot | 10–46K chars again | One ~40-char UNCHANGED line |
| Docs lookup (Shopify Dev, Context7) | Network call every time | Disk cache, or a one-line UNCHANGED |
| Docs tool lists | Shopify 26.6K, Context7 5.9K chars | 21.3K and 2.6K chars |
| Config | Five MCP entries, five tool lists | One entry, one connection |
| One upstream fails | Its own error, per server | Only its tools go; the rest keep working |
| Telemetry from upstreams | DevTools → Google, Shopify → shopify.dev | Off by default, keys not forwarded |
| Proxy cost | — | 1–3 ms per Playwright call |
Numbers come from npm run bench, recorded upstream responses and PlayGuard's own NDJSON call log — no LLM in the loop, just bytes and milliseconds.
Pick your client, flip the switches, copy the config. It replaces your separate Playwright, Figma, Chrome DevTools, Shopify Dev and Context7 entries. Node 20.18.1+ is the only requirement; playguard@latest pulls new releases on every start.
Restart your MCP client after changing the config: upstreams start once per session. Every switch and default: configuration reference.
{"mcpServers": {"playguard": {"command": "npx","args": ["-y", "playguard@latest"],"env": {"PLAYGUARD_SCREENSHOTS": "redirect","FIGMA_MCP_CMD": "npx","FIGMA_MCP_ARGS": "-y figma-developer-mcp --stdio","FIGMA_API_KEY": "your-figma-api-key","DEVTOOLS_MCP_CMD": "npx -y chrome-devtools-mcp@latest","DEVTOOLS_MCP_ARGS": "--headless --isolated","SHOPIFY_DEV_MCP_CMD": "npx -y @shopify/dev-mcp@latest","CONTEXT7_MCP_CMD": "npx -y @upstash/context7-mcp@latest"}}}}
Want the long version? How PlayGuard works walks through every mechanism and every environment variable.
Any MCP client that launches stdio servers: Claude Code, Claude Desktop, Cursor, Codex and others. Node.js 20.18.1+ is the only requirement; npx fetches PlayGuard on first start. Codex takes the same command, args and env as a [mcp_servers.playguard] table in ~/.codex/config.toml.
Playwright MCP (bundled, always on), Figma — either Framelink figma-developer-mcp or Figma's official desktop server — Chrome DevTools MCP, Shopify Dev MCP and Context7. Each optional one is switched on by its own env var in the same playguard entry; leave the variable out and it never starts.
Yes — Figma-to-code with browser checks is the work PlayGuard is built for. One playguard entry runs Playwright MCP and Figma (Framelink or the official desktop server) side by side, so the agent reads the design with the Figma tools and drives the page with browser_* over one connection. With Framelink, playguard_compare_design compares a Figma node against the live DOM element that implements it and reports mismatches numerically — font size, colour, padding, radius. Chrome DevTools, Shopify Dev and Context7 can run in the same entry too.
It wraps it. PlayGuard bundles @playwright/mcp and runs it as an always-on upstream, so the agent keeps the same browser_* tools — with snapshots compacted by 70–90%, dead sessions revived and the last URL restored. That is why you drop your separate Playwright MCP entry once PlayGuard is in the config.
Yes, for the servers PlayGuard runs. Playwright MCP is bundled and spawned by PlayGuard itself — listing it separately starts two browsers and duplicates the tool list. The same goes for a Figma, DevTools, Shopify Dev or Context7 entry you route through PlayGuard: one entry replaces all of them.
Framelink works on any Figma plan with an API key and gets the full treatment: the 8-module optimizer, the cache and playguard_compare_design. The official desktop server (FIGMA_MCP_URL=http://127.0.0.1:3845/mcp) needs no key but a Dev or Full seat on a paid plan; it returns generated code, variables and screenshots, which PlayGuard passes through whole. One at a time; the URL wins if both are set.
No. Figma only admits clients listed in its MCP catalog, so PlayGuard refuses that URL at startup and says why. Add it to your MCP client directly, next to PlayGuard; its responses then skip PlayGuard.
Only its own tools go away. Optional upstreams start lazily and are isolated from each other; calling a tool of one that failed returns [PlayGuard] … MCP is not running with what to check. A crashed upstream process is respawned once and the call retried; DevTools also reopens its last URL.
No — it launches its own Chrome. Pages, cookies and element ids are not shared: a DevTools uid works only with DevTools tools, a [ref=] only with browser_*. Use it for network, performance traces, Lighthouse and computed CSS; keep clicking through flows with browser_*. Advanced users can point both at one Chrome over CDP.
Compaction keeps every line carrying a [ref=] (or DevTools uid) plus structural landmarks, so nothing the agent can act on disappears. Static text without a ref is dropped — when the agent needs to read copy, it uses the section/around filters, browser_evaluate, or raw: true. Doc rewrites never cut content or code, and every rewrite passes an unrecognised response through unchanged. raw: true on a call, or PLAYGUARD_COMPACT=false, PLAYGUARD_DEVTOOLS_OPTIMIZE=false, PLAYGUARD_DOCS_OPTIMIZE=false, returns the untouched response.
Only to the upstream that needs them. Chrome DevTools, Shopify Dev and Context7 each get a filtered environment, so FIGMA_API_KEY never reaches them and CONTEXT7_API_KEY reaches Context7 only. Keys never land in the call log or the cache. PlayGuard also turns off DevTools usage statistics and CrUX lookups and Shopify Dev instrumentation by default. Its only own network request is a startup version check on npm (PLAYGUARD_UPDATE_CHECK=false turns it off).
About 1–3 ms per Playwright call, measured by npm run bench. Against a snapshot that shrinks from 300 KB to 30 KB, that is not the number worth worrying about.
Every call is logged as NDJSON with raw and kept byte counts and the upstream it went to — set PLAYGUARD_LOG_DIR to pick the folder. npm run analyze, run from a clone of the repo, turns your own logs into a report with savings per upstream, cache hits and latency percentiles per tool.
Your call: allow, warn (default), block, or redirect — the last swaps a screenshot for a snapshot, with {visual:true} as the escape hatch when you genuinely need pixels. The policy applies to DevTools take_screenshot too.