PRODUCT DATASHEETstdio · local · no telemetryMIT LICENSE · NODE 20.18.1+ · TESTS IN CI
Documentation

How the PlayGuard MCP proxy works

PlayGuard is a proxy MCP: one server in your client config that runs several MCP servers under the hood — Playwright MCP, Figma (Framelink or the official desktop server), Chrome DevTools MCP, Shopify Dev MCP and Context7 — and exposes all their tools through a single connection. Every response passes through it on the way back: dead sessions are revived, accessibility snapshots lose 70–90% of their tokens, Figma trees are trimmed to layout, network lists are summarized and documentation answers are rewritten and cached. This page explains each mechanism in full: what it does, why it is safe, and which environment variable turns it off.

MIT licensed · Node 20.18.1+ · runs locally over stdio · source on GitHub

What an MCP proxy is

The Model Context Protocol (MCP) is how an agent such as Claude Code, Claude Desktop, Cursor, or Codex talks to an external tool. The client spawns a server, the server advertises a list of tools, and every call and response travels over stdio as JSON-RPC.

An MCP proxy is itself an MCP server, but most of the tools it offers belong to someone else. It spawns the real servers as child processes, forwards their tool lists upward as a single merged catalogue, and passes calls through. Because every request and every response crosses it, a proxy is the one place where you can change what the agent sees without modifying either the agent or the upstream tool.

That is the whole idea behind PlayGuard. Playwright, Figma, DevTools and the documentation MCPs are good at producing complete, correct data. Complete and correct is exactly the problem when the consumer is a language model paying by the token for every byte it reads.

The second benefit is configuration. Without a proxy, every MCP is its own entry in the client config, its own process, its own tool list, its own failure. With PlayGuard there is one entry, and environment variables inside it decide which upstreams run.

Upstream MCPs at a glance

Playwright MCP ships inside PlayGuard and always runs. Every other upstream is opt-in: set its variable in the env block of the playguard entry and it starts; leave it out and it is never spawned and its tools are never listed. Nothing needs to be installed separately — the optional upstreams are launched through the command you give, usually npx.

UpstreamEnable withWhat PlayGuard does to it
Playwright MCP
@playwright/mcp, bundled
always onCompact / delta / UNCHANGED snapshots, snapshot filters, session recovery, screenshot policy, eval cache, --codegen none, batching hints
Figma, Framelink
figma-developer-mcp
FIGMA_MCP_CMD + FIGMA_API_KEYEight optimizer modules, structural budget trim, cache, playguard_compare_design. Any Figma plan
Figma, official desktop
Figma desktop app
FIGMA_MCP_URLPassthrough of whole responses, no cache, no key. Dev or Full seat on a paid plan
Chrome DevTools MCP
chrome-devtools-mcp
DEVTOOLS_MCP_CMDNetwork summary, request trim, snapshot compaction, trace trim, error hints, privacy launch defaults
Shopify Dev MCP
@shopify/dev-mcp
SHOPIFY_DEV_MCP_CMDResponse rewrites, disk cache, UNCHANGED repeats, compacted tool list, telemetry off
Context7
@upstash/context7-mcp
CONTEXT7_MCP_CMDResponse rewrites, disk cache, UNCHANGED repeats, compacted tool list

Figma is one option at a time: Framelink or the official desktop server, and FIGMA_MCP_URL wins when both are set. Here is every upstream switched on at once — the configurator on the overview page builds the same JSON with whatever subset you pick:

.mcp.json
{
"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"
}
}
}
}
Restart the MCP client after changing the config. PlayGuard and its upstreams are started once per client session; a changed env block is read on the next start.

Architecture and routing

One process, spawned by your agent, that spawns one child process per enabled upstream. Figma's desktop server is the exception: it already runs inside the Figma app, so PlayGuard connects to it over Streamable HTTP instead of spawning anything.

Claude Code / Claude Desktop / Cursor / Codex
           │
           │  MCP (stdio) — one connection
           ▼
   ┌───────────────────┐
   │     PlayGuard     │  proxy MCP
   │                   │
   │  • router         │  browser_*          → Playwright MCP        (always)
   │  • recovery       │  Figma tools        → Framelink / Figma     (FIGMA_MCP_CMD / _URL)
   │  • optimizers     │  DevTools tools     → Chrome DevTools MCP   (DEVTOOLS_MCP_CMD)
   │  • caches         │  Shopify docs tools → Shopify Dev MCP       (SHOPIFY_DEV_MCP_CMD)
   │  • analytics      │  Context7 tools     → Context7              (CONTEXT7_MCP_CMD)
   │  • own tools      │  playguard_a11y_audit, playguard_compare_design
   └─────────┬─────────┘
             │  one child process per enabled upstream
   ┌─────────┼───────────┬──────────┬───────────┬──────────┐
   ▼         ▼           ▼          ▼           ▼          ▼
Playwright  Figma     Chrome     Shopify    Context7   (each optional
  MCP       MCP      DevTools    Dev MCP                except Playwright)
   │                    │
   ▼                    ▼
Chromium / Firefox / WebKit    Chrome (its own instance)

Routing

The tool lists of every running upstream are merged into one catalogue, each tool under its own name. A call goes to whichever upstream advertised that name. If two upstreams ever advertise the same name, the first one keeps it and a warning goes to stderr. PlayGuard adds two tools of its own: playguard_a11y_audit and playguard_compare_design.

Lazy start and isolation

Optional upstreams start lazily — on the first tools/list or call — so the first start can include an npx download. tools/list waits a bounded time for a slow upstream (PLAYGUARD_LIST_WAIT_MS, 6 s), lists without it, and sends notifications/tools/list_changed once its tools are in.

Upstreams are isolated from each other. A failing optional upstream removes only its own tools; the rest keep working. Calling a tool of one that failed to start returns [PlayGuard] … MCP is not running: <error> with what to check, rather than a bare "tool not found".

Do not add Playwright MCP separately. PlayGuard spawns it from its own bundled dependency. Listing both in your config starts two browsers and two servers, and the agent sees a duplicated tool catalogue. The same applies to any upstream you route through PlayGuard.

Where the tokens go

Playwright snapshots

browser_snapshot returns the page's full accessibility tree. On a real application that is routinely 1,500–2,000 lines and 100–500 KB — roughly 25,000 to 75,000 tokens for a single look at a single page. An agent that navigates, looks, clicks, and looks again burns through a context window in a handful of steps.

Most of that payload is unusable by the agent. Static text nodes, decorative images, and presentational wrappers appear in the tree but carry no [ref=] handle, which means the agent cannot click, type into, or otherwise address them. They are read, paid for, and discarded.

The second cost is repetition. Snapshotting the same page twice returns the same hundreds of kilobytes twice, and a click that toggles one button re-sends the entire tree to communicate a two-line change.

Figma responses

A Figma file is a design document, and its API representation carries everything a design tool needs: edit history, plugin data, export settings, prototype interactions, invisible layers left over from iteration, and vector geometry stored as thousands of path coordinates. An agent implementing a component needs none of it.

Repetition is worse here than in the browser. A screen with 100 instances of one button component serializes 100 near-identical subtrees. The information the agent actually needs is one definition plus 99 sets of overrides.

A typical unoptimized node response runs 200–500 KB. After PlayGuard the same response is commonly 60–150 KB, and the log line tells you exactly what happened:

[PlayGuard figma: -68% (284.0KB→91.0KB)]

DevTools and documentation answers

Chrome DevTools lists every request a page made — 34,000 characters on a busy store, most of it images and analytics pings the agent will never open. Request details carry a dozen boilerplate headers. Documentation MCPs return indented JSON with relevance scores, the same chunk once per API version, and tool lists padded with telemetry parameters. And an agent asks the same documentation question again after every context compaction.

Snapshot compaction

The compactor keeps every line that carries a [ref=] handle, plus the structural landmarks that give those handles context — nav, main, form, dialog, and the rest. Everything the agent cannot address is dropped, and the reduction is reported inline:

[PlayGuard compact: 312/1840 lines, ~83% removed, 124.3KB→14.1KB]

The guarantee that makes this safe is narrow and checkable: an element the agent could have interacted with before compaction is still there after it. What is lost is prose the agent can retrieve on demand, not capability. Set PLAYGUARD_COMPACT=false to receive the raw tree.

Narrowing a snapshot further

When even the compact tree is large, browser_snapshot takes three optional parameters that restrict the result to one region:

  • section — only the landmark subtree whose label matches, for example "form" or navigation "Footer".
  • around — only the landmark subtree containing a given [ref=N], once the agent knows which element it cares about.
  • depth — cap the depth of the returned subtree, for a high-level overview before drilling in.

A section or ref that does not exist falls back to the full snapshot with an explicit [PlayGuard: … not found] warning rather than returning an empty result. Changing filters between calls always forces a fresh snapshot, so a narrowed request never receives a cached answer that was built for a different filter.

Waiting for a page that is still loading

PLAYGUARD_SMART_WAIT=1 makes a snapshot retry when the page looks mid-load — very few interactive refs combined with a loading, spinner, or skeleton indicator in the text. It retries a bounded number of times and then returns what it has, with a warning. It is off by default because it adds latency to every snapshot call, and most pages do not need it.

Deltas, caching, and prefetch

Compaction attacks the size of one response. These three attack the number of responses.

Delta snapshots

When a page changes only slightly, the agent receives the change instead of the page:

[PlayGuard delta: +3 added, 1 removed, ~91% saved]
ADDED:
  - button "Submit" [ref=47]
REMOVED:
  - button "Loading..." [ref=44]

Past a configurable threshold — PLAYGUARD_DELTA_THRESHOLD, the fraction of lines that must differ — the page has changed enough that a full snapshot is cheaper to read than a diff, and PlayGuard sends one.

Snapshot cache and prefetch

With PLAYGUARD_PREFETCH_SNAPSHOT=true, PlayGuard fetches a snapshot in the background right after browser_navigate, so the next browser_snapshot is served from memory. It is off by default: agents usually run an evaluate or an action first, which discards it. A page that has not changed since the last look returns a bare UNCHANGED without touching the browser at all.

Eval cache

Repeated browser_evaluate calls running the same script against the same URL are served from cache within a TTL, and oversized eval output is truncated at a character limit so a stray document.body.innerHTML cannot flood the context window.

Shorter responses, fewer calls

The bundled Playwright MCP runs with --codegen none, which drops the ### Ran Playwright code block from every response (PLAYGUARD_CODEGEN=keep restores it). Each browser_evaluate call also waits at least half a second for the page to settle, so the descriptions of browser_evaluate, browser_run_code_unsafe and browser_wait_for carry a one-line hint to batch checks into fewer calls (PLAYGUARD_HINTS=false turns it off).

Session recovery

Long agent runs kill browsers. A tab crashes, a target closes, the connection is refused — and the agent receives an error it was never designed to handle, halfway through a task, with no memory of how to get back.

PlayGuard matches those failures before the agent sees them:

Target.*closed · Browser.*closed · connect ECONNREFUSED · crashed

On a match it restarts Playwright MCP, restores the last URL, and retries the original call. The agent sees a normal successful response and keeps working. Two calls landing during the same crash produce one restart, and both calls continue — recovery is shared, not duplicated per caller.

The optional upstreams get the same treatment at the process level. If Chrome DevTools MCP, Shopify Dev or Context7 dies between calls or mid-call, PlayGuard respawns it once and retries the call; for DevTools it also reopens the last URL and prepends a notice that cookies and page state are gone. Figma's desktop server keeps its connection across a failed call — only a transport failure drops it, and a call is retried only when it certainly never reached the server.

Screenshot policy

A screenshot is one of the most expensive things an agent can request, and for most tasks — finding a button, checking a label, filling a form — a snapshot answers the question better. Four modes decide what happens on a screenshot call:

ModeBehaviour
warnDefault. The screenshot runs; a warning is written to stderr.
redirectReplaced with a snapshot. Pass {visual:true} when pixels are genuinely required.
blockRefused with an error that names the variable to change.
allowNo restriction.

redirect is the mode worth adopting: it removes the default cost without removing the capability, because the escape hatch is one argument away. A call that passes filename, an element/ref/target, or fullPage always gets pixels. The same policy applies to Chrome DevTools take_screenshot.

Accessibility audit

playguard_a11y_audit runs axe-core (bundled, 4.14) inside the page the browser_* tools have open and returns a short report instead of axe's raw JSON:

[PlayGuard a11y: 6 violations (6 elements) · 7 rules passed · axe 4.14.0 · wcag2a,wcag2aa,… · https://shop.test/]

critical image-alt — Images must have alternative text (1)
  - img  <img src="…" class="hero">
    Element does not have an alt attribute (+4 more)
  https://dequeuniversity.com/rules/axe/4.14/image-alt

serious  color-contrast — Elements must meet minimum color contrast ratio thresholds (1)
  - main > p  <p style="color:#bbb">Low contrast text</p>
    Element has insufficient color contrast of 1.91 (…). Expected contrast ratio of 4.5:1

Rules are sorted by impact. Each lists at most five elements — the rest are counted — with a CSS selector, a 140-character html excerpt, and the first way to fix it. Rules axe could not decide are named under "Needs manual review".

ParamDefaultUse
selectorwhole pageAudit only this part, e.g. #cart-drawer — open a dialog first, then audit it.
tagswcag2a, wcag2aa, wcag21a, wcag21aa, wcag22aaReplaces the default. To add best-practice or wcag2aaa, pass the defaults plus it. A tag that matches no axe rule — a typo — is an error, never a clean report.

Automated checks do not cover keyboard flow or screen-reader wording; those still need a person. The page keeps axe loaded after the first audit, so later audits are fast.

The Figma optimizer

Figma responses run through eight modules before reaching the agent. The recommended upstream is Framelink's figma-developer-mcp, which returns a pre-simplified { metadata, nodes, globalVars } shape; Module 8 is built for it. A Figma MCP that passes through raw Figma REST API JSON gets Modules 1–4 and 6 instead. Which ones fire depends on the shape your upstream returns.

ModuleWhat it removes
Module 1
Metadata cleaner
Fields that say nothing about layout: createdAt, updatedAt, creator, thumbnailUrl, pluginData, sharedPluginData, exportSettings, reactions, interactions.
Module 2
Invisible layer pruner
Nodes with visible === false or opacity === 0, recursively. Hidden iteration leftovers are a large share of a working file.
Module 3
Component deduplication
Repeated instances of one component collapse to a reference. 100 buttons become one full definition plus 99 entries of { type, name, id, _ref, overrides }.
Module 4
SVG refs
Inline vector geometry (fillGeometry) is replaced with { "_svgRef": "nodeId" } — the shape identity without thousands of path coordinates.
Module 5
Top-level metadata trim
Drops metadata.thumbnailUrl (a signed single-use preview URL) and metadata.lastModified from pre-simplified shapes, which Module 1 cannot reach because it only walks document/children.
Module 6
Layout compressor
Absolute x/y on nodes inside Auto Layout containers, where position is already determined by layoutMode, gap, and padding.
Module 7
Budget trim
If the tree still exceeds FIGMA_TEXT_COMPACT, it is trimmed structurally rather than sliced as text — an over-budget branch becomes an {id, name, type, _stub:true} marker the agent can re-fetch by id.
Module 8
Framelink shape optimizer
For the { metadata, nodes[], globalVars.styles } shape, where Modules 2/4/6 find nothing. 8a: sibling subtrees identical but for ids collapse to { id, name, _sameAs }, with a _textDiff map when they differ only in text. 8b: no-op layout styles and the node refs to them are dropped. 8c: float noise is rounded (1.3999999364217122em → 1.4em); node text is never touched.
Nothing disappears silently. Module 7 allocates the character budget depth-first and proportionally to each branch's size. A branch that will not fit collapses to an {id, name, type, _stub:true} marker the agent can re-fetch by id — so every top-level section stays visible in the tree. Only a response that could not be parsed as JSON or YAML at all falls back to a raw text slice, and that case is recorded as parseSkip in the log.

Framelink 0.13+ defaults to a tree text format that is neither JSON nor YAML, so PlayGuard starts the Figma child with OUTPUT_FORMAT=json unless you set it yourself. yaml works too; tree disables the optimizer and the design diff.

Official Figma MCP (desktop server)

Instead of Framelink you can route Figma's own MCP server through PlayGuard. No API key goes in the config — the Figma desktop app's login authorizes it.

env
"env": {
"FIGMA_MCP_URL": "http://127.0.0.1:3845/mcp"
}
  1. Open the Figma desktop app (latest version), switch to Dev Mode (Shift+D) and click Enable desktop MCP server in the Inspect panel.
  2. You need a Dev or Full seat on a paid plan — Figma's requirement, not PlayGuard's.

Its tools — get_design_context, get_metadata, get_variable_defs, get_screenshot and the rest — join the merged tool list. They return generated code and XML rather than a JSON style tree, so PlayGuard passes them through whole: never sliced by FIGMA_TEXT_COMPACT, never cached (without a nodeId the server answers from the current selection in the app and reflects live edits).

If the app is closed, or started after PlayGuard, a Figma call returns how to turn the server on; once it is up, the next call connects, its tools are registered and the client is told to re-list. Credentials in the URL are kept out of messages and logs.

FeatureFramelinkOfficial desktop
VariableFIGMA_MCP_CMDFIGMA_MCP_URL
AuthFIGMA_API_KEYThe Figma app's sign-in
Figma planAny, free includedDev or Full seat, paid plan
ReturnsJSON node treeReact + Tailwind code, variables, screenshots
Optimizer, cache, design diffYesNo — passthrough
Figma's remote server can't go through PlayGuard.https://mcp.figma.com/mcp only admits clients listed in Figma's MCP catalog, so PlayGuard refuses that URL at startup and explains why. Add it to your client directly, next to PlayGuard — in Claude Code, claude mcp add --transport http figma https://mcp.figma.com/mcp. Its responses then skip PlayGuard. On the remote server Figma limits Starter-plan users and View/Collab seats to 6 tool calls a month.

Design diff: Figma against the live DOM

playguard_compare_design compares a Figma node with the DOM element that implements it and reports the differences numerically — no screenshots, no side-by-side eyeballing.

[PlayGuard design diff: 42:1337 → [data-testid="login-btn"] 2 mismatches, 6 matches]

  fontSize:        Figma 16px               → Browser 14px               ⚠  MISMATCH (+2.0px)
  color:           Figma rgb(255, 255, 255) → Browser rgb(255, 255, 255) ✓  MATCH
  backgroundColor: Figma rgb(25, 118, 210)  → Browser rgb(25, 118, 210)  ✓  MATCH
  padding:         Figma 12px 24px          → Browser 12px 16px          ⚠  MISMATCH (Δright:+8px, Δleft:+8px)
  borderRadius:    Figma 8px                → Browser 8px 8px 8px 8px    ✓  MATCH

It runs in three modes:

ModeArgumentsUse
SinglefigmaNodeId + browserSelectorOne element.
Batchpairs: [{figmaNodeId, browserSelector}, …]Several at once; one bad selector does not sink the rest.
Auto-mapfigmaNodeId + autoMap: truePoint at a component; layers beneath are matched by data-figma-id, data-testid, id, class, or exact text.

The rules that keep the comparison honest

  • Properties are chosen per node. A TEXT layer is compared on typography and colour; a container on background, padding, radius, and shadow. Pass properties[] to override.
  • Box values compare side by side. 8px 8px 0 0 never passes as 8px, because padding, margin, radius, and border width are compared per side rather than as a collapsed string.
  • Unset is not unknown. A property Figma leaves unset but CSS zero-defaults — no shadow, no border — is still checked, so a stray browser value gets caught. margin is the one exception: Figma has no margin concept, so it is reported as unknown rather than as a defect.
  • Typography follows the label. A button's font size is read from its TEXT layer at any depth, and its background is never mistaken for its text colour.
  • Viewport-dependent values are never auto-selected.width and height depend on the viewport, not the design; request them explicitly and a warning rides along.
  • Auto-map never guesses. A candidate selector that matches zero or several elements is reported as unmapped rather than silently attached to the wrong element.
  • A missing node is an error, not a substitute. A figmaNodeId the response does not contain fails that pair, instead of falling back to whatever root frame happens to be present.

Both upstream shapes are handled — raw Figma REST API node JSON and Framelink's pre-simplified globalVars.styles form. With the official desktop server the tool is not listed, and says so if called. Tolerances are configurable: sizes match within PLAYGUARD_DESIGN_DIFF_TOLERANCE_PX, colours within PLAYGUARD_DESIGN_DIFF_TOLERANCE_COLOR per RGB channel.

Chrome DevTools MCP

Google's chrome-devtools-mcp is an opt-in upstream. Its tools — take_snapshot, list_network_requests, get_network_request, list_console_messages, performance_start_trace, lighthouse_audit, get_css_styles and the rest — join the merged catalogue under their own names. Reach for them for what Playwright MCP does not cover well: headers and bodies, performance traces and insights, Lighthouse audits, computed CSS. Clicking through a flow stays with the browser_* tools — they have session recovery and the cheaper snapshot pipeline.

.mcp.json
{
"mcpServers": {
"playguard": {
"command": "npx",
"args": ["-y", "playguard@latest"],
"env": {
"PLAYGUARD_SCREENSHOTS": "redirect",
"DEVTOOLS_MCP_CMD": "npx -y chrome-devtools-mcp@latest",
"DEVTOOLS_MCP_ARGS": "--headless --isolated"
}
}
}
}

Two browsers

chrome-devtools-mcp launches its own Chrome, separate from Playwright's. Pages, cookies, logins and element ids are not shared: a DevTools uid= works only with DevTools tools, a [ref=] only with browser_*, and a DevTools tool sees only pages opened with navigate_page or new_page. PlayGuard says this in its server instructions and on the navigation tools, and points the agent at browser_network_requests / browser_console_messages for a page driven by browser_*.

By default the upstream keeps a persistent profile in ~/.cache/chrome-devtools-mcp/. A second instance on the same profile — another agent, another client — fails with "The browser is already running". Pass --isolated in DEVTOOLS_MCP_ARGS for a throwaway profile.

Advanced: one shared Chrome

To make both upstreams drive the same browser, start Chrome yourself with remote debugging and point both at it:

chrome --remote-debugging-port=9222 --user-data-dir=/tmp/pg-chrome
env
"env": {
"PLAYWRIGHT_MCP_ARGS": "--cdp-endpoint http://127.0.0.1:9222",
"DEVTOOLS_MCP_CMD": "npx -y chrome-devtools-mcp@latest",
"DEVTOOLS_MCP_ARGS": "--browserUrl http://127.0.0.1:9222"
}

Pages and cookies are then shared, but ids still are not — each upstream numbers elements its own way. Nobody owns the browser any more: if it crashes or you close it, neither Playwright session recovery nor chrome-devtools-mcp can relaunch it.

What changes on the way through

ToolChangeGet the upstream response
tools/listDrops $schema from every schema, adds the raw param, adds the two-browser note to the navigation tools and a summary note to list_network_requests.PLAYGUARD_DEVTOOLS_OPTIMIZE=false
take_snapshotSame-origin URLs become paths, image URLs are dropped, text leaves repeating their parent's name go — every interactive uid survives. An unchanged repeat is one UNCHANGED line; a small change is ADDED:/REMOVED: lines. Any non-read-only call clears the shortcut.raw: true
list_network_requestsWithout paging or filter params, a list over 30 rows becomes a summary: the main document, failed (4xx/5xx/net::ERR_*) and pending rows, per-host counts, and how to page.Pass pageSize, pageIdx, resourceTypes
get_network_requestNoisy headers (accept*, user-agent, sec-*, alt-svc…) collapse to one line; a CSP over 200 chars becomes its length; a non-JSON body over 3,000 chars is cut with a pointer to responseFilePath. Cookies, authorization, x-* are kept; JSON bodies are never cut.raw: true
performance_*_traceDrops "example question" lines and markdown link targets; insight set ids and names stay.raw: true
take_screenshotPLAYGUARD_SCREENSHOTS applies. In redirect mode it becomes take_snapshot unless it passes visual, filePath, uid or fullPage.visual: true
ErrorsFive opaque upstream errors (element not interactive, stale uid, no page selected, path outside the workspace, unknown reqid) get a one-line hint with the next step.PLAYGUARD_DEVTOOLS_OPTIMIZE=false

raw is a PlayGuard-only param, stripped before the call reaches the upstream. PLAYGUARD_DEVTOOLS_OPTIMIZE=false turns off every rewrite above; the screenshot policy and the restart notices still apply.

Measured savings

With chrome-devtools-mcp 1.12 on real sites, upstream versus sent:

ResponseSaving
list_network_requestsShopify store 34K → ~1K chars (−97%); Wikipedia 7.6K → ~0.6K (−92–95%). Lists of 30 rows or fewer are untouched.
get_network_request, HTML document−63–72%
get_network_request, JSON body~−20% (headers only)
take_snapshot−3% on a small clean page to −40% on an image-heavy store. An unchanged repeat: one ~40-char line instead of 10–46K.
Performance trace−13%
DevTools tools/list28.9K → 26.4K chars, and --no-page-id-routing removes pageId from 30 of 32 tools

Privacy and launch defaults

PlayGuard starts the upstream with --no-usage-statistics and --no-performance-crux, which would otherwise send usage data and every traced URL to Google, turns off its npm update check, and passes it only an allowlisted environment — PATH, proxy and Chrome variables, never FIGMA_API_KEY or other secrets. It also adds --no-page-id-routing, points --workspace at your project, and runs the upstream in .playguard/.qa, so a relative file path lands there. Pass any of these flags yourself to override it, or set PLAYGUARD_DEVTOOLS_DEFAULTS=false to add none.

Files, timeouts, recovery

  • Paths. The upstream runs with .playguard/.qa as its working directory, so a relative filePath lands there. Absolute paths must be inside the project or the OS temp dir.
  • Timeouts. lighthouse_audit, the two trace tools and take_heapsnapshot get 180 s instead of the SDK's 60 s.
  • Upstream process died. PlayGuard respawns it once, reopens the last URL opened with navigate_page/new_page, retries the call, and tells the agent that cookies and page state are gone.
  • Chrome restarted by the upstream. Nothing to respawn, but cached snapshot state is cleared and the response names the last URL so the agent can navigate back.

Documentation MCPs: Shopify Dev and Context7

Two read-only documentation upstreams, each enabled by its own command. Shopify Dev MCP answers questions about Shopify APIs, Liquid and themes, and validates code; Context7 serves up-to-date docs for thousands of libraries. Both run over stdio — remote HTTP endpoints are not supported yet.

env
"env": {
"SHOPIFY_DEV_MCP_CMD": "npx -y @shopify/dev-mcp@latest",
"CONTEXT7_MCP_CMD": "npx -y @upstash/context7-mcp@latest"
}

Optional SHOPIFY_DEV_MCP_ARGS / CONTEXT7_MCP_ARGS are appended the same way as DEVTOOLS_MCP_ARGS. Both start lazily, and a failing one leaves every other upstream working.

  • Context7 needs Node.js 20.18.1+, the same minimum as PlayGuard. Without a key it allows ~200 calls a day per IP; set CONTEXT7_API_KEY (free at context7.com/dashboard) to raise it.
  • Shopify Dev sends tool inputs and results to shopify.dev by default. PlayGuard starts it with OPT_OUT_INSTRUMENTATION=true unless you set that variable yourself.
  • Environment. Each gets the MCP SDK's default set plus npm, proxy, locale and temp-dir variables, and only its own keys. Other API keys and host session ids are not forwarded. Keys never reach the call log or the cache.

What changes on the way through

ToolChangeMeasured
search_docs_chunksIndented JSON → ## title / url / content blocks. Drops score/domain, exact duplicates, and byte-identical chunks whose URL differs only in API version (the URL moves to an also: line). Content is never cut.−19–20%
learn_shopify_apiEscaped code fences are unescaped. Always returned whole, even on a repeat: it is the routing guide.−254 chars on liquid
validate, validate_themeNever rewritten, never cached.—
Shopify tools/listHides feedback (telemetry only), drops model/user_prompt, makes conversationId optional — PlayGuard fills in one id per process.26.6K → 21.3K chars
resolve-library-idOne line per library: id, title, snippets, reputation, benchmark, versions, description cut to ~90 chars. Every id and the order are kept.−48–50%
query-docsGitHub Source: URLs become org/repo@ref:path; an exact duplicate snippet is dropped. Code is never touched.−1–2%
Context7 tools/listShorter descriptions and instructions; every param, type, required list and annotation kept.5.9K → 2.6K chars

Every rewrite checks the format first and passes the response through unchanged when it doesn't recognise it (logged as parseSkip). PLAYGUARD_DOCS_OPTIMIZE=false turns all of them off; raw: true on search_docs_chunks, learn_shopify_api, resolve-library-id and query-docs skips them for one call.

Cache and repeats

search_docs_chunks, resolve-library-id and query-docs results are cached on disk in .playguard/.cache/docs/ for 24 hours (PLAYGUARD_DOCS_CACHE_TTL); a version-pinned Context7 id such as /vercel/next.js/v16.2.9 keeps seven times longer. Errors are never cached and files are written atomically.

An identical call repeated within the same PlayGuard process returns a one-line UNCHANGED note instead of the whole answer. The process outlives /compact and /clear and is shared by subagents, so the note tells the agent to call again with raw: true if it no longer has the earlier answer.

Setting it up

Nothing to install. npx fetches the package on first run, Playwright MCP comes bundled, and the optional upstreams are fetched by the commands you give. Node.js 20.18.1 or newer. The fastest way to a config is the configurator on the overview page: flip the upstreams you want and copy the JSON.

Browser only

.mcp.json
{
"mcpServers": {
"playguard": {
"command": "npx",
"args": ["-y", "playguard@latest"],
"env": {
"PLAYGUARD_SCREENSHOTS": "redirect"
}
}
}
}

Browser and Figma (Framelink)

.mcp.json
{
"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",
"FIGMA_CACHE_TTL": "60000"
}
}
}
}

Claude Code reads .mcp.json in the project root, or add the server for all projects with claude mcp add --scope user. Claude Desktop uses the same JSON at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS and %APPDATA%\Claude\claude_desktop_config.json on Windows. Cursor reads the same JSON from .cursor/mcp.json (or ~/.cursor/mcp.json). Codex takes the same command, args and env as a [mcp_servers.playguard] table in ~/.codex/config.toml — the configurator on the overview page writes it for you.

On Windows, use forward slashes inside JSON strings. Spaces in paths need no escaping.

Staying up to date

Keep the @latest in playguard@latest: with it, npx checks npm on every start and fetches new releases. A bare playguard can keep running an old cached or globally installed copy. New versions load when the MCP client restarts the server.

On startup PlayGuard also checks npm for a newer version in the background. If yours is older, the first tool result says how to update, so the agent tells you. Turn it off with PLAYGUARD_UPDATE_CHECK=false.

Still on an old version? Remove stale copies with npm rm -g playguard and npx clear-npx-cache, then restart the client. Running from a local clone instead: "command": "node", "args": ["/path/to/playguard/dist/index.js"].

Configuration examples

Each block below is the env object of the playguard entry; command and args stay as in the setup above.

Headless browser + Figma with cache

env
"env": {
"PLAYWRIGHT_MCP_ARGS": "--headless",
"FIGMA_MCP_CMD": "npx",
"FIGMA_MCP_ARGS": "-y figma-developer-mcp --stdio",
"FIGMA_API_KEY": "your-figma-api-key",
"FIGMA_CACHE_TTL": "120000"
}

Browser + official Figma desktop server

env
"env": {
"PLAYGUARD_SCREENSHOTS": "redirect",
"FIGMA_MCP_URL": "http://127.0.0.1:3845/mcp"
}

Shopify theme work: browser, DevTools, Shopify Dev

env
"env": {
"PLAYGUARD_SCREENSHOTS": "redirect",
"DEVTOOLS_MCP_CMD": "npx -y chrome-devtools-mcp@latest",
"DEVTOOLS_MCP_ARGS": "--headless --isolated",
"SHOPIFY_DEV_MCP_CMD": "npx -y @shopify/dev-mcp@latest"
}

Library docs with a Context7 key

env
"env": {
"CONTEXT7_MCP_CMD": "npx -y @upstash/context7-mcp@latest",
"CONTEXT7_API_KEY": "your-context7-key"
}

Firefox, screenshots blocked, hard token cap

env
"env": {
"PLAYWRIGHT_MCP_ARGS": "--browser firefox",
"PLAYGUARD_SCREENSHOTS": "block",
"PLAYGUARD_TOKEN_BUDGET": "4000"
}

Persist cookies between sessions

env
"env": {
"PLAYWRIGHT_MCP_ARGS": "--storage-state /tmp/browser-state.json"
}

Configuration reference

Every behaviour on this page has a switch. The defaults are the recommended setup; these exist so that nothing PlayGuard does is something you cannot turn off.

Browser

VariableDefaultDescription
PLAYGUARD_SCREENSHOTSwarnallow / warn / block / redirect. Applies to DevTools take_screenshot too.
PLAYGUARD_COMPACTtrueSet false to receive the raw accessibility tree (Playwright and DevTools).
PLAYGUARD_DELTAtrueSet false to disable delta snapshots.
PLAYGUARD_DELTA_THRESHOLD0.4Fraction of lines that must change (0–1) before a full snapshot is sent instead of a delta.
PLAYGUARD_TOKEN_BUDGET0Max tokens per snapshot. Truncates on a line boundary so a [ref=] is never split. 0 = off.
PLAYGUARD_HINT_THRESHOLD4After N consecutive snapshots with no action taken, inject a hint listing the available interactive refs.
PLAYGUARD_PREFETCH_SNAPSHOTfalseSet true to fetch a snapshot in the background after browser_navigate.
PLAYGUARD_CODEGEN—Set keep to stop PlayGuard adding --codegen none to the bundled Playwright MCP.
PLAYGUARD_HINTStrueSet false to stop appending batching hints to tool descriptions.
PLAYGUARD_SMART_WAITfalseSet 1 to retry a snapshot that looks mid-load instead of returning it as-is.
PLAYGUARD_SMART_WAIT_MS1000Delay between smart-wait retries, in ms.
PLAYGUARD_SMART_WAIT_MAX_RETRIES3Retries before giving up and returning the snapshot with a warning.
PLAYGUARD_SMART_WAIT_MIN_REFS5A snapshot with at least this many refs is never treated as still loading.
PLAYGUARD_EVAL_CACHE_TTL500browser_evaluate cache TTL in ms. 0 = off.
PLAYGUARD_EVAL_COMPACT10000Max characters of eval output. 0 = off.
PLAYWRIGHT_MCP_CMDbundledOverride the Playwright MCP command.
PLAYWRIGHT_MCP_ARGS—Extra arguments for Playwright MCP, space-separated; quote an argument containing a space. --output-dir here takes precedence over PLAYGUARD_OUTPUT_DIR.
PLAYGUARD_OUTPUT_DIR.playguard/Where on-disk artifacts go, split by origin: .playguard/.qa/ for the site under test, .playguard/.figma/ for Figma image exports.
PLAYGUARD_PROJECT_ROOTnearest repo rootThe root that .playguard/ is created in. process.cwd() is whatever the client spawned the server with, so it is not trusted — set this to pin the location.
PLAYGUARD_LOG_DIRlogs/NDJSON analytics log directory. Under npx the default sits inside the npm cache, so set this to keep logs where you can find them.
PLAYGUARD_UPDATE_CHECKtrueSet false to skip the startup check for a newer version on npm (offline, CI).

Figma

VariableDefaultDescription
FIGMA_MCP_CMD—Framelink launch command. Unset, with no FIGMA_MCP_URL, means Figma is off.
FIGMA_MCP_URL—Official desktop server, http://127.0.0.1:3845/mcp. No key; wins over FIGMA_MCP_CMD. mcp.figma.com is refused.
FIGMA_MCP_ARGS—Extra arguments for the Figma MCP, space-separated; quote an argument containing a space.
FIGMA_API_KEY—Forwarded to the Framelink child process, and used nowhere else.
FIGMA_CACHE_TTL0Figma response cache TTL in ms. 0 = off. Framelink only.
FIGMA_SVG_REFStrueSet false to keep SVG geometry inline.
FIGMA_TEXT_COMPACT10000Max characters for the Figma response. Over budget, the tree is trimmed structurally by Module 7. 0 = off.
OUTPUT_FORMATjsonFormat requested from Framelink. Must be json or yaml for the optimizer and design diff; tree disables both.

Chrome DevTools

VariableDefaultDescription
DEVTOOLS_MCP_CMD—Chrome DevTools MCP launch command, e.g. npx -y chrome-devtools-mcp@latest. Unset means DevTools is off.
DEVTOOLS_MCP_ARGS—Extra arguments for chrome-devtools-mcp, e.g. --headless --isolated.
PLAYGUARD_DEVTOOLS_OPTIMIZEtrueSet false for a pure passthrough: no response rewriting, no tool-list compaction, no error hints.
PLAYGUARD_DEVTOOLS_DEFAULTStrueSet false to stop appending --no-usage-statistics, --no-performance-crux, --no-page-id-routing and --workspace.
PLAYGUARD_DEVTOOLS_NETWORK_MAX30A network list with more rows than this, requested without paging or filters, is summarized. 0 = off.
PLAYGUARD_DEVTOOLS_BODY_MAX3000Max characters of a non-JSON body in get_network_request. 0 = off.
PLAYGUARD_LIST_WAIT_MS6000How long the tool list waits for an optional upstream (Figma, DevTools, Shopify Dev, Context7) before listing without it. Its tools follow with tools/list_changed.

Shopify Dev and Context7

VariableDefaultDescription
SHOPIFY_DEV_MCP_CMD—Shopify Dev MCP launch command, e.g. npx -y @shopify/dev-mcp@latest. Unset = off.
SHOPIFY_DEV_MCP_ARGS—Extra arguments for it.
CONTEXT7_MCP_CMD—Context7 launch command, e.g. npx -y @upstash/context7-mcp@latest. Unset = off.
CONTEXT7_MCP_ARGS—Extra arguments for it.
CONTEXT7_API_KEY—Forwarded to Context7 only; raises the anonymous ~200 calls/day limit. Free at context7.com/dashboard.
PLAYGUARD_DOCS_OPTIMIZEtrueSet false for a pure passthrough of both: no rewriting, no repeat notes, no tool-list compaction.
PLAYGUARD_DOCS_CACHE_TTL86400Seconds a doc lookup stays in .playguard/.cache/docs/ (7× for a version-pinned Context7 id). 0 = off.

Design diff

VariableDefaultDescription
PLAYGUARD_DESIGN_DIFF_TOLERANCE_PX2Size difference, in px, still counted as a match.
PLAYGUARD_DESIGN_DIFF_TOLERANCE_COLOR5Per-channel RGB difference still counted as a match.

Measuring it on your own workload

The 70–90% figure is a range because it depends on your pages. Rather than trusting it, measure it: every tool call is written to YYYY-MM-DD.ndjson with raw and kept byte counts. Set PLAYGUARD_LOG_DIR to choose the folder — by default the logs sit next to the installed package, which under npx is deep in the npm cache. Then run npm run analyze from a clone of the repository, with the same PLAYGUARD_LOG_DIR, to turn your logs into a report.

── Snapshot token savings ────────────────────────────────
  Cache hits:      12/47 snapshots (0 from prefetch)
  Bytes saved by cache:    84.3 KB  (~21 075 tokens)
  Bytes saved by compact:  312.1 KB (~78 025 tokens)
  Total saved:             396.4 KB (~99 100 tokens)
  Reduction vs raw:        83%  (82.1 KB sent vs 478.5 KB without PlayGuard)

── Chrome DevTools MCP ───────────────────────────────────
  Calls:       38 total  (2 errors, 1 raw:true)
  Tokens in:   ~61 000  →  out: ~35 400  (saved ~25 600, -42%)
  Snapshots:   9  (3 UNCHANGED, 2 delta)

Every upstream gets its own section of the report — Playwright, Figma, Chrome DevTools, Shopify Dev and Context7 — because each NDJSON line records which server answered. The line carries the full detail for your own analysis: the PlayGuard version (ver), the first 200 characters of any error (errText); for browser calls rawBytes, keptBytes, delta, cacheHit; for Figma calls inBytes, outBytes and a count for each module that fired; for DevTools summarized, trimmed, revived; for documentation calls cached and repeat. The DevTools numbers above are illustrative — your ratio depends on which tools the agent calls.

npm run bench measures the other side of the trade: proxy overhead, snapshot versus screenshot size, cache hit rate, and crash recovery time, with no model in the loop. Overhead lands at 1–3 ms per Playwright call.

What it does not do

  • It does not phone home. PlayGuard runs locally over stdio and talks to no server of its own. Its one network request is the startup version check, a plain GET of registry.npmjs.org/playguard/latest that sends nothing about you or your project (PLAYGUARD_UPDATE_CHECK=false turns it off). The logs are files on your disk.
  • It does not hand your keys around. Chrome DevTools, Shopify Dev and Context7 each get a filtered environment: FIGMA_API_KEY never reaches them, and CONTEXT7_API_KEY reaches Context7 only. Keys never land in the call log or the cache.
  • It does not let upstreams phone home by default. Chrome DevTools MCP starts with usage statistics and CrUX lookups off and its own update check disabled; Shopify Dev MCP starts with instrumentation opted out. Pass the upstream flag yourself to turn any of it back on.
  • It does not drop what the agent can act on. Compaction preserves every [ref=] and DevTools uid; budget trimming leaves re-fetchable stubs; documentation content and code are never cut.
  • It is not a black box. MIT licensed, source on GitHub, and CI runs the full suite on every push and pull request — the compactor, all eight Figma optimizer modules, crash detection, caching, the DevTools and documentation rewrites, the accessibility report, and design-diff extraction each have tests.

← Back to the overviewRead the source →