Skip to main content
Glama

k11 Playwright QA — MCP server & Claude Code plugin

Turn user stories into Playwright tests that actually pass, and fix the ones a redesign just broke.

AI coding assistants write Playwright tests quickly, but they guess selectors. The tests look right, then fail on the first run, or break the next time someone renames a CSS class. This MCP server gives the assistant the facts it can't guess:

  • Verified locators. It opens the real page and returns locators that match exactly one element, most stable first (getByTestId, getByRole, getByLabel, ...).

  • Story → spec. It turns "As a… I want… so that…", Gherkin scenarios or acceptance-criteria bullets into a Playwright Test skeleton: one test per scenario, one test.step per step.

  • Structured test runs. It runs Playwright and returns per-test results, including the exact locator a failing test was waiting for.

  • Self-healing locators. When the UI changes, it finds the element the test meant and suggests a verified replacement with a confidence score and the reasons. It never silently edits your tests.

Works with Claude Code (as a plugin with /story-to-test and /heal-tests commands), Claude Desktop, and any other MCP client. Listed in the official MCP Registry as io.github.K11-Software-Solutions/playwright-qa.


See it heal

The demo app ships in two versions. In v2 a redesign renamed every id, changed the button text from "Sign in" to "Log in", swapped the CSS classes and added a "Continue with Google" button. A test using page.locator('#login-btn') fails. heal_locator returns (trimmed):

{
  "status": "healed",
  "original": "page.locator('#login-btn')",
  "suggestion": "page.getByRole('button', { name: 'Log in' })",
  "confidence": 0.87,
  "reasons": [
    "name equivalent: \"Sign in\" → \"Log in\"",
    "id similar (50%): \"login-btn\" → \"signin-submit\"",
    "role matches", "type matches", "tag matches",
    "classes similar (64%): \"btn btn-primary\" → \"cta cta-primary\""
  ],
  "candidates": [
    { "locator": "page.getByRole('button', { name: 'Log in' })", "score": 0.87 },
    { "locator": "page.getByRole('button', { name: 'Continue with Google' })", "score": 0.42 },
    { "locator": "page.getByRole('heading', { name: 'Log in to Acme Store' })", "score": 0.15 }
  ],
  "referenceSource": "baseline"
}

It picked the right button over the look-alike, and the suggestion is a role-based locator that would have survived the redesign in the first place.

Related MCP server: RunAutomation MCP Server

Tools

Tool

What it does

explore_page

Opens a URL and lists elements with locators verified to match exactly one element.

check_locator

Counts what a locator matches on a page (1 = good) and whether it's visible.

review_user_story

Before any test is written: the questions a careful tester would ask about the story, each with why it matters.

parse_user_story

User story → structured scenarios + a Playwright Test skeleton.

write_test

Writes a spec into tests/. Refuses paths outside it; won't overwrite unless asked.

run_tests

Runs Playwright Test and returns per-test results with the failing locator.

capture_baseline

While tests pass, fingerprints the element each locator matches (.qa-mcp/baselines.json).

heal_locator

Finds the intended element after a UI change and suggests a verified replacement.

save_login_state

Logs in once with a few steps and saves the session for the other tools and your tests.

list_devices

Phone and tablet profiles for mobile web testing (iPhone, Pixel, Galaxy, iPad…).

explore_page, check_locator, capture_baseline and heal_locator accept an optional session to reach pages behind a login or several steps into a flow, and an optional device (e.g. "iPhone 15") for mobile web. run_tests accepts a Playwright project (e.g. "Mobile Safari").

Prompt: story_to_playwright, a guided workflow from story to passing test.

Ask before you build

Generating tests from an unclear story doesn't remove the ambiguity. It hides it in test code, as guesses nobody agreed to. So /story-to-test starts with review_user_story, which finds what a careful tester would ask first:

Asks about

When the story has

acceptance criteria

no criteria; only the goal itself

the outcome

a scenario with no Then, or a Then like "works correctly" with nothing to see

the user role

no "As a ..." (permissions and test accounts depend on it)

measurable terms

words a test can't check: fast, easy, many, appropriate, user-friendly...

the limit's number

"expires", "maximum", "up to" with no number

the failure path

only happy paths

the starting state

actions with no Given (who's signed in, what data exists)

undefined terms

with context (a glossary or product notes): a term the story relies on that the context never explains

Each question comes with why it matters and the words that raised it. If there are questions, the agent asks you and waits; it doesn't guess. If you tell it to go ahead anyway, each open question goes into the spec as an // OPEN QUESTION: comment and into its final report.

The rules are deterministic, so the same story always gets the same questions, and they're tested both ways: each kind of gap must be caught, and a clear story must get none.

How self-healing works

All K11 QA tools keep their settings, baselines and reports in .qa-mcp/. What each file is for, and what to commit.

  1. Baseline. While tests pass, capture_baseline records each element's fingerprint: role, accessible name, test id, id, name, type, label, placeholder, classes, text and href.

  2. Detect. When run_tests reports a failure, it includes the locator Playwright was waiting for.

  3. Match. heal_locator scores every visible element on the current page against the fingerprint. It uses exact matching for stable attributes and fuzzy, synonym-aware matching for text and ids ("Sign in" ≈ "Log in", btn ≈ button).

  4. Verify. The best match gets the most stable locator that matches exactly one element on the live page.

  5. Decide. It reports healed only when the confidence is at least 0.55 and clearly ahead of the runner-up. Otherwise it reports needs_review with the top candidates, or not_found if nothing resembles the original. Without a baseline it falls back to what the locator itself implies and says so.

Commit .qa-mcp/baselines.json to your repository so healing works in CI. Do not commit .qa-mcp/auth/, which holds login sessions; save_login_state adds it to .gitignore for you.

Pages behind a login and multi-step flows

Every page tool accepts a session:

{
  "url": "https://shop.example.com/login",
  "session": {
    "storage_state": ".qa-mcp/auth/default.json",
    "steps": [
      { "action": "click", "locator": "page.getByRole('link', { name: 'My orders' })" },
      { "action": "wait_for", "locator": "page.getByRole('heading', { name: 'Order history' })" }
    ]
  }
}
  • storage_state is a saved login. Create one with save_login_state (log in once with steps) or reuse the file from your Playwright global setup. It must be inside the project.

  • steps run after the start page loads: goto, click, fill, press, select, check, uncheck and wait_for, up to 25. Locators are parsed the same safe way as everywhere else.

  • Secrets stay out of prompts and logs. Write "value": "${ENV:APP_PASSWORD}" and the value is read from the environment. Results show the placeholder, and literal fill values are masked as •••.

  • Baselines are stored under the page the steps end on, so capturing and healing with the same session line up.

Mobile web

Most sites show phones a different layout: a hamburger menu instead of a nav bar, hidden columns, separate buttons. Locators that work on desktop often don't on mobile, and the other way round. Every page tool takes a device (any of Playwright's built-in profiles: screen size, pixel density, touch and mobile user agent):

explore_page   { url, device: "iPhone 15" }           → the elements a phone user actually sees
check_locator  { url, locator, devices: ["desktop", "iPhone 15", "Pixel 7"] }
               → "unique and visible on every device", or which device it fails on
capture_baseline / heal_locator { ..., device: "Pixel 7" }   → baselines are kept per device
heal_locator   { ..., check_devices: ["desktop"] }   → warns if a mobile fix isn't valid on desktop

heal-ci across Playwright projects. If your playwright.config has desktop and mobile projects, each failure is healed on the device its project emulates. Projects named after a device ("Pixel 7") or Playwright's template names ("Mobile Chrome", "Mobile Safari") are recognised; map any others in heal.config.json ("projects": { "Phones": "iPhone 15" }). When one broken locator fails on several devices:

  • the devices must agree on the replacement. If each finds a different "best" element (say separate desktop and mobile buttons with their own test ids), heal-ci looks for a locator that is unique on all of them, such as the shared role and name, and otherwise asks a person;

  • a change is kept only if the test then passes in every project, so a fix for mobile can never silently break desktop.

Pages are emulated in Chromium, which is right for responsive layouts and locators. For Safari-specific rendering, keep a WebKit project in your Playwright config. Native mobile apps need Appium, not Playwright.

Healing in CI, with an audit trail

heal-ci repairs locators broken by a UI change and opens a pull request that explains every change:

npx -y k11-playwright-qa-mcp heal-ci --apply
  1. Runs your Playwright suite.

  2. For each locator failure, works out the page the test was on (from .qa-mcp/heal.config.json, or the test's own page.goto(...)) and heals against the committed baseline on the device the test's Playwright project emulates, logging in first if the config says so.

  3. Applies a change only when confidence is at least 0.7 (--min-confidence) and clearly ahead of the runner-up.

  4. Re-runs the healed tests and reverts any change whose test still fails in any Playwright project. Each change is kept or reverted on its own merits.

  5. Leaves failures that aren't about locators alone: they may be real bugs.

  6. Writes heal-report.md (the pull-request description) and heal-report.json (full evidence).

Without --apply, it's a dry run that only reports suggestions. A real report from the demo app's redesign:

1 healed and verified, 0 suggested, 1 reverted, 1 needs review, 0 not found, 1 failure not caused by locators.

Test

Old locator

New locator

Confidence

Runner-up

Re-run

Account › shows my orders

page.locator('#view-orders')

page.getByRole('button', { name: 'View orders' })

82%

View returns button (59%)

passed

Needs a person: "Edit profile" link → best candidate "Account settings" (45%), not confident enough to change. "Open cart" healed at 85%, but the test still failed because the cart message changed too, so the change was reverted.

Not caused by locators: "has the account title" (the page title changed). Untouched.

Copy docs/heal-locators.yml into your app's .github/workflows/ to run it on a schedule and open the pull request automatically, and docs/heal.config.example.json to .qa-mcp/heal.config.json to tell it how to log in.

How it compares to Microsoft's Playwright MCP

Playwright MCP lets an AI drive a browser through any task, and Playwright's test agents (planner, generator, healer) build on it. Use them to explore and automate broadly. Use k11 Playwright QA when you need test maintenance you can audit:

Playwright MCP and test agents

k11 Playwright QA

Healing evidence

The agent's reasoning

Confidence score, specific reasons and the runner-up, in a report

Reference point

The current page

A fingerprint saved when the test last passed

Same input, same result

Varies by run and model

Yes

Edits to your tests

The agent edits them

Only verified, confident changes; the rest goes to a person

CI output

Agent session

A pull request with an audit report

They work well together: drive flows with Playwright MCP, and keep your suite healthy with k11 Playwright QA.

Install

Requires Node 20+.

First, once per machine, install the Chromium build the server uses:

npx -y k11-playwright-qa-mcp install-browsers

Adds the MCP tools plus the /story-to-test and /heal-tests commands:

/plugin marketplace add K11-Software-Solutions/k11techlab-playwright-qa-mcp
/plugin install playwright-qa@k11-qa-tools

Claude Code: MCP server only

From your app's project folder:

claude mcp add playwright-qa -- npx -y k11-playwright-qa-mcp

Claude Desktop and other MCP clients

{
  "mcpServers": {
    "playwright-qa": {
      "command": "npx",
      "args": ["-y", "k11-playwright-qa-mcp"],
      "env": { "QA_MCP_ROOT": "/path/to/your/app" }
    }
  }
}

From source

git clone https://github.com/K11-Software-Solutions/k11techlab-playwright-qa-mcp
cd k11techlab-playwright-qa-mcp
npm install && npx playwright install chromium
claude mcp add playwright-qa -- node /path/to/k11techlab-playwright-qa-mcp/dist/cli.js

The server works on the project in QA_MCP_ROOT, or the current directory if that isn't set. That project needs @playwright/test installed for run_tests.

Try it

In Claude Code, inside your app's repository:

/story-to-test http://localhost:3000/login As a customer, I want to sign in so that I can see my orders.
- Valid credentials show "Welcome back"
- A wrong password shows an error and keeps me on the login page

After a UI change:

/heal-tests tests/login.spec.ts

Safety

  • Locator strings are parsed, never eval'd. Only single getByRole / getByTestId / getByLabel / getByPlaceholder / getByText / locator(css) expressions are accepted.

  • Writes are confined to tests/, limited to .spec/.test files, and never overwrite unless you ask.

  • Tests run through the project's own Playwright CLI with Node directly, with no shell, so arguments can't inject commands.

  • Healing only suggests. You, or the agent with your review, decide what to change.

Development

npm install
npx playwright install chromium
npm test        # unit, browser, login-flow, heal-ci and MCP-protocol tests (31)
npm run build

Roadmap

  • Learn each test's page automatically from a Playwright trace, so heal.config.json is rarely needed

  • Visual (screenshot) fingerprints as an extra healing signal

  • Healing for chained and filtered locators (.filter(), .nth(), nested locators)

  • Visual comparison of desktop and mobile layouts


Built by K11 Software Solutions. Part of the K11 Tech Lab agentic QA series. MIT licensed.

Available Tools

10 tools
capture_baselineCapture locator baselinesA

While tests pass, record a fingerprint (role, name, test id, id, classes, text...) of the element each locator matches, saved in .qa-mcp/baselines.json under the page reached. heal_locator uses these after the UI changes. Accepts the same session as explore_page for pages behind a login.

Inputs: url (required), locators (required), device, session.

check_locatorCheck locatorA

Check how many elements a Playwright locator matches on a page (1 = good) and whether the match is visible. Accepts the same session as explore_page.

Inputs: url (required), locator (required), device, devices, +1 more.

explore_pageExplore pageA

Open a URL in a headless browser (optionally with a saved login and/or steps to reach a deeper page) and list its meaningful elements with locators verified to match exactly one element, most stable first. Use these locators when writing tests instead of guessing selectors.

Inputs: url (required), device, session, max_elements, +1 more.

heal_locatorHeal locatorA

For a locator that no longer matches (or matches several elements), find the most likely intended element on the current page and suggest a verified replacement with a confidence score and reasons. Accepts the same session as explore_page. Never edits files: review the suggestion, update the test, then re-run.

Inputs: url (required), locator (required), device, session, +1 more.

list_devicesList devicesA

Device profiles for mobile web testing (Playwright's built-in list): phones and tablets with their screen size, pixel density and touch. Pass a name as device to explore_page, check_locator, capture_baseline and heal_locator.

Inputs: no named parameters.

parse_user_storyParse user storyA

Turn a user story (As a.../I want.../so that..., Gherkin scenarios, or acceptance-criteria bullets) into structured scenarios and a Playwright Test skeleton with one test per scenario and one test.step per step. Call review_user_story first; the result includes a short review so open questions are never silently skipped.

Inputs: story (required), url.

review_user_storyReview user story before testingA

Call this BEFORE parse_user_story. Finds what a careful tester would ask before writing tests: missing acceptance criteria, outcomes that can't be asserted, no user role, untestable words (fast, easy, many), limits without numbers, no failure path, missing preconditions, and (with context) terms the context never explains. Returns questions for a person to answer, each with why it matters and the words that raised it. If ready is false, ask the user these questions and wait; do not guess the answers.

Inputs: story (required), context.

run_testsRun Playwright testsA

Run Playwright Test in the project and return per-test results. Failures include the error, its location and, when the cause was a locator, the locator Playwright was waiting for (pass it to heal_locator).

Inputs: grep, spec, project.

save_login_stateSave login stateA

Log in once by running steps on a login page, then save the browser's cookies and storage to .qa-mcp/auth/.json. Pass that file as session.storage_state to other tools, or to Playwright's storageState in tests. Put passwords in environment variables and reference them as ${ENV:NAME}; never pass them literally. The saved file contains session tokens: keep .qa-mcp/auth out of version control.

Inputs: url (required), steps (required), name, device, +1 more.

write_testWrite test fileA

Write a Playwright spec into the project's tests/ folder. Refuses paths outside tests/ and will not overwrite unless overwrite=true.

Inputs: code (required), path (required), overwrite.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool has a clearly distinct role in a linear QA workflow: story review, story parsing, exploration, locator checking, baseline capture, locator healing, test writing, test running, device listing, and login capture. The only near-overlaps (explore_page vs check_locator, capture_baseline vs heal_locator) are explicitly delineated by descriptions as 'discover', 'verify', 'record', and 'suggest replacement'. parse_user_story's built-in mini-review is flagged as a safety net rather than a duplicate of review_user_story.

    Naming Consistency5/5

    Every tool follows a snake_case verb_noun pattern (review_user_story, parse_user_story, explore_page, check_locator, capture_baseline, heal_locator, write_test, run_tests, list_devices, save_login_state). Verb choices are meaningful and non-redundant, and resource nouns are consistent across the set.

    Tool Count5/5

    Ten tools sit squarely in the well-scoped range, and every one earns its place as a step in the story-to-green-test loop. None feel like filler or a thin wrapper, and there is no density that would overwhelm an agent.

    Completeness4/5

    The surface covers the full authoring lifecycle: review, parse, explore, verify locators, write, run, and self-heal, plus auth and device support. Minor gaps exist: run_tests appears to run the project suite with no documented filter/target parameter, and there is no tool to read, update, or delete existing spec files (write_test only refuses overwrites), which agents must work around via the filesystem.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers