playwright-lite-mcp
Detected as one of the full page cache layers by magento_cache_check, which inspects whether a Magento page was served from Cloudflare's edge cache and explains why a page was not cached.
Detected as one of the full page cache layers by magento_cache_check, which reports the cache verdict for a URL (Fastly among Varnish, Cloudflare and built-in) along with the reason when a page is not cached.
magento_graphql_check runs GraphQL presets or a custom query against a store's GraphQL endpoint — store config, catalog, products (including zero-price detection), guest cart and GET caching — and returns a compact report without page snapshots.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
playwright-lite-mcp
A token-efficient MCP server for Magento 2 / Adobe Commerce / Mage-OS QA by AI coding agents: health, full page cache, GraphQL and guest checkout checks in one call each, plus a Playwright code mode with a magento helper API for everything else. TypeScript, MCP SDK v2, Playwright.
A guest checkout check costs ~3,000 tokens instead of ~20,000 with the official @playwright/mcp (benchmark).
Quick start (Docker, one command)
Requires Docker. Claude Code starts the container itself; the image is pulled on first use:
claude mcp add -s user playwright-lite -- docker run -i --rm --init \
-e PW_ALLOWED_ORIGINS="https://your-store.example.com" \
-e PW_ALLOW_SCRIPTS=true \
ghcr.io/mikekots/playwright-lite-mcp-magento:latestRestart Claude Code, run /mcp and check playwright-lite: connected. Then ask, for example: "Run magento_guest_checkout for https://your-store.example.com/some-simple-product.html and tell me the order total".
For a local dev store (Warden, DDEV, Valet) the container needs to reach the host and accept the local CA:
claude mcp add -s user playwright-lite -- docker run -i --rm --init \
--add-host app.hyva-demo.test:host-gateway \
-e PW_ALLOWED_ORIGINS="https://app.hyva-demo.test" \
-e PW_ALLOW_SCRIPTS=true \
-e PW_IGNORE_HTTPS_ERRORS=true \
ghcr.io/mikekots/playwright-lite-mcp-magento:latestWithout Docker, see Step 1 and Step 6. A ready-made demo store to try it on: sample-store/.
Related MCP server: QA Testing MCP Server
Tools
Tool | One call does |
| product → cart → checkout → shipping → payment (→ Place Order); totals, offered methods, console errors per step, failed requests |
| full page cache verdict per URL (Varnish, Fastly, Cloudflare, built-in), with the reason when a page is not cached |
| GraphQL presets (store, catalog, products incl. zero prices, guest cart, GET caching) or your own query |
| HTTP status, load time and JS errors for a list of pages |
| code mode: one Playwright script with |
| the basics, for anything else |
Token benchmark
Same task on both servers: guest checkout of a simple product up to the payment step, then read the totals and the console errors (node sample-store/benchmark.mjs, against the demo store):
Server | Tool calls | Tool results | Tool definitions | Total (one task) |
| 16 | ~15,000 tok | ~5,300 tok | ~20,300 tok |
playwright-lite: | 1 | ~136 tok | ~2,900 tok | ~3,000 tok (85% less) |
playwright-lite: | 1 | ~67 tok | ~2,900 tok | ~2,900 tok (85% less) |
Tokens are estimated as characters / 4. The official server gets its cheapest realistic sequence (a snapshot only when element refs are needed, one fill_form for all address fields); each of its three page snapshots alone is ~4,300 tokens. A real agent also re-sends the growing conversation with each of those 16 model requests, so the real difference is bigger.
Why another one, when there is the official @playwright/mcp
The official server is general-purpose, and therefore heavy: large page snapshots and many tools eat the agent's context. This server gives three things:
Fewer tokens. Page snapshots are truncated to a limit, and domain tools such as
page_health_check,magento_cache_check,magento_graphql_checkandmagento_guest_checkoutreplace dozens of navigate → snapshot round-trips with one call and a compact report.Security. The browser only opens allowlisted origins. Deny by default: without
PW_ALLOWED_ORIGINSthe server refuses to start.Domain tools. Add your own, like the built-in guest checkout for Magento.
Step 1. Install
Requires Node.js 20+.
npm install
npm run browsers # downloads Chromium for Playwright
npm run typecheck
npm test
npm run buildStep 2. Layout
src/
index.ts entry point: server, stdio transport, graceful shutdown
config.ts env config validated with zod (fail fast)
security.ts origin allowlist
script.ts code mode: runs the agent's Playwright script (browser_run)
browser.ts browser lifecycle: lazy start, auto-restart, redirect blocking
tools.ts MCP tools
magento.ts Magento guest checkout flow (magento_guest_checkout)
cache.ts full page cache check (magento_cache_check)
graphql.ts GraphQL API check (magento_graphql_check)
health.ts page health check (page_health_check, magento.health)
helpers.ts the `magento` helper API for browser_run scripts
mutex.ts serialized tool execution
logger.ts JSON logs to stderr
errors.ts turns Playwright errors into short, agent-readable messages
*.test.ts tests: allowlist, cookies, code mode, tool integration, checkout, cache, GraphQL
sample-store/ demo store (Mage-OS + Hyvä on Warden): setup.sh, check.sh, mcp-smoke.mjs, benchmark.mjs
.github/workflows/ CI (tests + Docker build) and Release (GHCR image, GitHub release, npm)There is a ready-made store to test against: see sample-store/README.md.
Step 3. Production-ready principles (what is done here)
stdout belongs to the protocol. With the stdio transport, JSON-RPC goes over stdout, so any console.log breaks the connection. All logs go to stderr (logger.ts). This is the most common reason a server "does not connect".
Errors are returned as results, not thrown. A tool returns isError: true with a short message and a hint ("call browser_snapshot to re-inspect"). The agent reads it and recovers instead of crashing.
Serialized execution. Agents may call several tools in parallel. Two clicks on one page at the same time give flaky results, so a Mutex runs calls one by one.
Timeouts everywhere. Navigation and actions have configurable limits, so a hung page never blocks the agent forever.
Two layers of URL protection. First: the tool argument is checked. Second: context.route blocks top-level navigation to other origins after a click or a server redirect. Playwright only intercepts the first request of a redirect chain, so each hop is fetched with maxRedirects: 0 and its Location is checked separately (test blocks a server redirect…). Iframes and sub-resources (CDNs, payment widgets) are not blocked, so checkout keeps working.
No secrets in logs. Tool arguments are never logged, and browser_fill does not echo the typed value, because it may be a password.
Resilience. The browser starts lazily on the first tool call, so the client handshake is fast. If Chromium crashes, it is relaunched on the next call.
Graceful shutdown. SIGINT/SIGTERM, a closed stdin (the client ended the session) or an unexpected error close the browser. A hard 5-second timeout makes sure no zombie Chromium is left behind.
Step 4. Configuration
Variable | Default | Description |
| required | Comma-separated: |
|
|
|
|
|
|
|
| Navigation timeout (also the limit for slow checkout steps) |
|
| Click, fill, etc. timeout |
|
| Page snapshot size limit |
| none | JSON file with cookies/localStorage, to start logged in |
| none | Cookie-consent button names separated by |
|
| How long to wait for the cookie banner after navigation |
|
|
|
|
| Time limit of one |
|
|
|
|
|
|
Create a PW_STORAGE_STATE file with npx playwright codegen --save-storage=auth-state.json https://your-site: log in in the window that opens, then close it. The file is in .gitignore, since it holds live session cookies.
Step 5. Try it with MCP Inspector
PW_ALLOWED_ORIGINS="https://*.example.com,https://example.com" npm run inspectA web UI opens where you can call each tool by hand and see raw responses. Do this before connecting an agent: it makes it easy to tell a server bug from odd model behavior.
Step 6. Connect to Claude Code
claude mcp add --scope user playwright-lite \
-e PW_ALLOWED_ORIGINS="http://localhost:3000" \
-e PW_HEADLESS=false \
-e PW_ALLOW_SCRIPTS=true \
-- node /absolute/path/to/playwright-lite-mcp/dist/index.js--scope user makes the server (and code mode) available in every project; use --scope project to limit it to one. Then run /mcp in a session and check the server is connected. If the official Playwright MCP is also connected, disable it for the project so the agent does not mix up the tools.
Step 7. Docker
The image contains Node and Chromium's headless shell only (~1.2 GB). Build it locally:
docker build -t playwright-lite-mcp .
claude mcp add -s user playwright-lite -- docker run -i --rm --init \
-e PW_ALLOWED_ORIGINS="https://staging.example.com" -e PW_ALLOW_SCRIPTS=true playwright-lite-mcpReleased versions are published to ghcr.io/mikekots/playwright-lite-mcp-magento:<version> and :latest for amd64 and arm64 (see Releases).
Details:
-iis required, stdio does not work without it.--initforwards signals correctly.localhostinside the container is not your host: usehttp://host.docker.internal:3000and allowlist it.A local
.testdomain resolves to127.0.0.1only on your host: add--add-host <domain>:host-gateway, and-e PW_IGNORE_HTTPS_ERRORS=truebecause the local CA is not trusted inside the container.The image runs headless Chromium only, so
PW_BROWSER=firefox|webkitdoes not work in Docker.Check an image end to end:
node sample-store/mcp-smoke.mjs https://app.hyva-demo.test --docker playwright-lite-mcp.
Step 8. Code mode (browser_run)
Instead of a navigate → snapshot → click → snapshot chain, the agent writes one Playwright script, the server runs it, and only the result goes back into the agent's context. Fewer tokens, and loops and conditions become possible.
Enable with PW_ALLOW_SCRIPTS=true. Without it the tool is not registered.
{ "code": "await page.goto('https://shop.test/'); await page.getByRole('link', { name: 'Shoes' }).click(); return await page.locator('.product-item-name').allInnerTexts();" }codeis the body of an async function withpagein scope.returnsends back a JSON result.On timeout (
timeoutMsorPW_SCRIPT_TIMEOUT_MS) the page is closed, cookies survive, and the next call gets a fresh page.Navigation to other origins is blocked by the same
context.route.
Not a sandbox. The script runs in the Node process with the user's permissions: it can reach
process, files and the network. The allowlist only restricts browser navigation. Enable it only locally or in Docker, and never expose it over an HTTP transport.
The magento helpers
Inside a script, magento is in scope next to page. The helpers are the domain tools, but they return plain data instead of text, so the script can loop, filter and aggregate, and only its final summary reaches the agent:
Helper | Returns |
| absolute URL on the current page's store |
|
|
|
|
|
|
|
|
|
|
|
|
Example: categories from GraphQL → cache check of each → guest checkout of two products, in one call:
await page.goto('https://app.hyva-demo.test/');
const cats = await magento.graphql('{ categoryList(filters: { url_path: { in: ["gear", "gear/bags"] } }) { url_path } }');
const cache = await magento.cache(cats.data.categoryList.map((c) => magento.url('/' + c.url_path + '.html')));
const checkouts = [];
for (const path of ['/joust-duffle-bag.html', '/voyage-yoga-bag.html']) {
const r = await magento.checkout({ productUrl: magento.url(path) });
checkouts.push({ path, ok: r.ok, total: r.totals.find(([k]) => k === 'Order Total')?.[1] });
}
return { cache: cache.map((c) => `${c.verdict} ${c.url}`), checkouts };A guest checkout takes 5–10 s: pass a larger timeoutMs for loops. Every URL still goes through the allowlist.
Example prompt for Claude Code: "Using browser_run and the magento helpers, check the cache of every Gear category on https://app.hyva-demo.test and run a guest checkout for two bags; return only problems".
Step 9. Magento guest checkout (magento_guest_checkout)
One call goes through the real storefront like a customer: product page → Add to Cart → checkout → shipping address → shipping method → payment method → (optionally) Place Order. It returns a compact QA report:
Guest checkout: OK (stopped before Place Order; pass placeOrder: true to place it)
Product: Joust Duffle Bag | cart: 1 item(s), subtotal $34.00
Shipping: flatrate_flatrate | offered: flatrate_flatrate (Flat Rate - Fixed, $5.00); tablerate_bestway (Best Way - Table Rate, $15.00)
Payment: checkmo | offered: checkmo
Totals: Cart Subtotal $34.00 | Shipping Flat Rate - Fixed $5.00 | Order Total $39.00
Steps: add_to_cart 0.5s, checkout_load 1.1s, shipping_address 0.0s, shipping_method 2.3s, payment 2.3s
Console errors: none
Failed requests: noneInput (only productUrl is required):
Field | Default | |
| — | Product page of a simple product (no required options) |
| page default | |
|
| |
| US test address (Austin, Texas) | Any of |
| first offered |
|
|
| |
|
|
|
|
| By default every call starts as a fresh guest (cookies and cart cleared, also those from |
Behavior worth knowing:
Console errors are tagged with the step they happened in (
[payment] console: ...), and the store's own 4xx/5xx responses are listed: these are usually the actual checkout bug.The 404 on
guest-carts/.../totalsright after Place Order is normal Magento behavior (the quote is closed once the order exists) and is not reported.On failure the result is
isError: truewith the failed step and the reason, and the page is left at that step, so the agent can callbrowser_snapshotto look.Products with options (configurable, bundle) fail immediately with an explanation: use
browser_runto pick the options.Supported: the standard
Magento_Checkout(Luma, and Hyvä withhyva-themes/magento2-luma-checkout). Hyvä Checkout (Magewire) and other one-step checkouts are detected and reported as unsupported.
Step 10. Full page cache check (magento_cache_check)
Requests each URL several times over plain HTTP and tells whether the full page cache serves it, and if not, why:
Cache check: 2 requests per URL, as a guest without cookies. Layer: Varnish
CACHED https://app.hyva-demo.test/gear.html | HIT 2ms age=1685 → HIT 2ms age=1685 | via X-Cache | tags: 10
CACHED https://app.hyva-demo.test/gear/bags.html?product_list_order=price | MISS 342ms → HIT 22ms | via X-Cache | tags: 21
NOT_CACHEABLE https://app.hyva-demo.test/checkout/cart/ | MISS 125ms → MISS 117ms | via X-Cache | cache-control: max-age=0, must-revalidate, no-cache, no-store
- Magento marked the page uncacheable (X-Magento-Cache-Control: max-age=0, must-revalidate, no-cache, no-store)
- expected: Magento never caches cart/checkout/customer pages
Summary: 2/3 cached, 1 not cacheableInput: urls (up to 20), requests (2–5, default 2: the first may warm the cache, the last must be a HIT), withSession (default false: a cookie-less guest, which is what the shared cache entry is for; true sends the browser's cookies, e.g. a logged-in customer or X-Magento-Vary).
How it decides:
Cache status from whichever header the stack provides:
X-Magento-Cache-Debug(built-in FPC, or stock Varnish VCL in developer mode),X-Cache(Warden VCL, Fastly / Adobe Commerce Cloud, many CDNs;MISS, HITfrom Fastly counts as a hit),CF-Cache-Status(Cloudflare),X-Varnish(two transaction ids = hit),Age.Cacheability from what Magento itself sent:
X-Magento-Cache-ControlandX-Magento-Tags. Behind Varnish the client-facingCache-Controlis alwaysno-store(the VCL rewrites it), so it is ignored there.Verdicts:
CACHED;NOT_CACHEABLE(marked expected for cart/checkout/customer pages, otherwise a hint to look for acacheable="false"layout block);MISS(looks cacheable but is not served from cache: listsSet-Cookieon the response, query strings, and the config to check);UNKNOWN(no status headers, e.g. production mode hidesX-Magento-Cache-Debug);ERROR(4xx/5xx or not allowlisted).Redirects are reported, not followed.
Step 11. GraphQL check (magento_graphql_check)
Checks the GraphQL API that headless/PWA storefronts and many Hyvä/Luma widgets depend on. Without a query it runs preset checks, one line each:
GraphQL: https://app.hyva-demo.test/graphql
OK store 85ms | default "Default Store View", USD, en_US
OK catalog 90ms | 6 top-level categories: What's New (0), Women (0), Men (0), Gear (34), Training (0), Sale (0)
OK products 290ms | 181 products; first 20: 20 Configurable
OK cart 732ms | guest cart + 24-WG02 ×1 → qty 1, subtotal 92.00 USD, grand total 92.00 USD (an abandoned guest cart is left behind)
OK cache 4ms | GET storeConfig: HIT 6ms → HIT 4ms via X-Cache, X-Magento-Cache-Id present
Summary: 5/5 OKPreset | What it checks |
|
|
| children of the root category with product counts |
| product listing: total, types, out-of-stock items, zero final prices (a classic indexing/price-scope bug) |
|
|
| the same GET query twice: Magento caches GraphQL GET requests, so the second one should be a HIT |
With query (and optional variables, method: "GET" to see the cache status) it runs your query instead and returns HTTP status, GraphQL errors with category and path, timing and the data truncated to maxChars (default 2000). Other input: storeUrl (any store URL, or the full endpoint), checks (a subset of presets), storeCode (sent as the Store header). Requests are sent as a cookie-less guest; non-JSON answers (an HTML error page, a redirect) are described instead of failing the call.
Step 12. Adding your own tool
const CartTotalInput = z.object({ productUrl: z.string() });
server.registerTool(
'cart_add_and_total',
{
title: 'Add to cart and read total',
description: 'Open a product page, add it to cart and return the cart total.',
inputSchema: CartTotalInput,
},
run<z.infer<typeof CartTotalInput>>('cart_add_and_total', async ({ productUrl }, page) => {
await page.goto(assertUrlAllowed(productUrl, cfg.PW_ALLOWED_ORIGINS).toString());
await page.getByRole('button', { name: /add to cart/i }).click();
await page.goto(new URL('/checkout/cart', productUrl).toString());
const total = await page.getByTestId('cart-total').innerText();
return text(`Cart total: ${total}`);
}),
);Rules: describe the input with a zod schema with .describe() on every field (the model reads these descriptions), keep the response short and to the point, and always run through run().
Releases
Versions follow semantic versioning, starting at 0.1.0 (0.x = the tool set may still change). CHANGELOG.md lists the changes. To release:
npm version patch # or minor; updates package.json and creates the git tag
git push --follow-tagsThe Release workflow then tests, builds and pushes the Docker image to GitHub Container Registry, creates a GitHub release and, when the NPM_TOKEN secret is set, publishes the npm package (so it can also run with npx playwright-lite-mcp). CI runs typecheck, tests, build and a Docker build on every push and pull request.
What's next
HTTP transport (
@modelcontextprotocol/nodeor@modelcontextprotocol/express) with authentication, so one server can serve a team or CI. That needs a separate browser context per session, andbrowser_runmust never be exposed over it.More checks: configurable product option picking in the checkout, Hyvä Checkout (Magewire) support, price and stock checks.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Browser-based QA for AI-built software. Test pages with real browsers via agents.
Website checker for AI coding agents. Measures your site in a real browser, with evidence.
AI QA tester — real browsers scan sites for bugs, SEO, perf, and accessibility issues via chat.
Browser-backed QA with evidence and fix-ready reports for coding agents.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants to manage Adobe Commerce and Magento 2 instances through business-level tools for catalog, promotions, CMS, and SEO. It features secure OAuth 1.0 authentication, safety guardrails for bulk operations, and built-in diagnostic reports for store health.382MIT
- AlicenseAqualityDmaintenanceEnables AI agents to perform comprehensive web application testing including visual, functional, performance, accessibility, and SEO analysis using browser automation without requiring API keys.7MIT
- AlicenseAqualityCmaintenanceEnables AI agents to interact with Adobe Commerce Cloud projects via REST API and SSH for database queries, log reading, environment management, and more, with no PHP CLI required.1581 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to autonomously interact with and test web applications in a real browser, providing DOM/Accessibility tree extraction, runtime telemetry, screenshot capture, and Markdown test reports.16 npm1MIT