Run End-to-End Tests from Your Terminal with Kane CLI

Author and Run Tests Right from the Terminal in Natural Language, with an Evidence-Backed Pass or Fail from a Real Browser.

npm install -g @testmuai/kane-cli

PlaywrightAI TestingMCP

AI and Playwright MCP: Running Tests Through Smart Agents

Learn how Playwright MCP and AI agents work together for self-healing test automation, with a real JIRA-to-test-execution workflow and code examples.

Last Updated on:

Playwright MCP is Microsoft's official Model Context Protocol server for Playwright. It exposes browser automation as tools an AI agent calls directly, so you give the agent a goal instead of a fixed script, and it reads the page through the accessibility tree to decide each next action. It is free, open source, and runs locally through npx.

That matters because scripted suites break on the description of the page, not the product. A renamed CSS class or a reordered DOM node can fail dozens of tests overnight while the feature still works, and an agent working from a goal can adapt to the change where a hard-coded locator cannot.

This shift from scripted to goal-driven automation is what people mean by Playwright with AI: the test describes intent, and the agent works out the steps against the live page.

This approach is also aligned with the idea of vibe testing with Playwright, where engineers describe the testing intent in natural language, and AI agents help translate that intent into executable automation workflows.

TL;DR

Playwright MCP is Microsoft's official Model Context Protocol server for Playwright. It exposes browser automation as callable tools, so an AI agent works from a stated goal instead of a fixed script. It is free, open source, and runs locally.

  • Model Context Protocol (MCP): Anthropic's open standard connects language models to external tools, so any compliant client pairs with any compliant server.
  • Playwright MCP: Microsoft's official server drives browsers from the accessibility tree, not screenshots. Free, open source, and it needs no filesystem access.
  • Playwright planner agent: Explores the application through Playwright MCP and turns a high-level goal into a readable Markdown test plan.
  • Playwright generator agent: Converts that Markdown plan into executable Playwright test files, validating locators against the live page as it writes.
  • Playwright healer agent: Replays a failing test, finds an equivalent element, and repairs the locator, or reports that the feature itself is broken.
  • TestMu AI MCP Server: Connects your local AI agent to the test automation cloud to run tests across real browsers and operating systems.
  • Accessibility snapshots return inline by default, so longer agent sessions consume more context, and reading untrusted pages carries a risk of prompt injection.

Understanding Model Context Protocol (MCP)

MCP (Model Context Protocol) is Anthropic's open standard that lets an AI agent call outside tools, such as a browser, through one shared interface. Playwright MCP is Microsoft's MCP server for driving a browser. For setup in each client and its security limits, see the Playwright MCP setup guide.

For a quick visual walkthrough of this concept, watch the video below from TestMu AI.

Youtube thumbnail

Subscribe to the TestMu AI YouTube channel for more tutorials on testing and automation.

Note

Note: Run Playwright tests at scale across 3,000+ browser and OS combinations with TestMu AI. Try TestMu AI now!

Exploring Playwright Agents and MCP

Playwright Agents arrived in Playwright v1.56 as three custom agent definitions that guide LLMs through the core process of building a Playwright test.

These AI agents, Planner, Generator, and Healer, all run on top of Playwright MCP (Model Context Protocol), work together to turn testing into something smart and adaptive that plans tests, generates tests, runs tests, and self-heals tests without hand-written scripts. Agents on MCP are one way to generate tests with AI; chatbots and IDE assistants are others, and each suits a different job.

The Planner turns a goal into a Markdown test plan, the Generator writes Playwright tests from that plan and checks each locator on the live page, and the Healer repairs a test that breaks after a UI change, or reports that the feature itself is broken. The workflow below uses all three.

Three Playwright agents: Planner, Generator, and Healer

How Does Playwright MCP Work with AI Agents?

The agent reads the requirement, plans the tests, drives a live browser through Playwright MCP's tools, then checks the results and explains any failure. The workflow below runs these four steps on a real Jira ticket. For what each tool does, see the full list of Playwright MCP tools.

Automate web and mobile tests with KaneAI by TestMu AI

Real-World Workflow: Running Automation Through Intelligent AI Agents and MCP

In this workflow, one AI agent goes from a Jira ticket to a healed, passing Playwright test: Jira MCP reads the story, the Planner writes the test plan, the Generator writes the spec, and the Healer repairs it after a deliberate locator break.

With MCP and AI agents, one agent reads the ticket, plans the cases, writes the spec, and repairs it when a locator breaks, without you switching tools between those steps.

Prerequisites for the Workflow

  • Playwright is already installed using the command npm init playwright@latest
  • Playwright agent already installed using the command npx playwright init-agents --loop=vscode

Step 1: Reading Requirements Using JIRA MCP and Create Test Plan

The automation workflow begins with integrating AI agents with the project management system through JIRA MCP. Instead of manually reviewing user stories, acceptance criteria, and bug tickets, the AI agent directly connects to Jira and understands the functional requirements automatically.

The agent can analyze:

  • User stories
  • Acceptance criteria
  • Feature descriptions

To securely connect AI agents with JIRA MCP, the Atlassian MCP server supports OAuth 2.1 alongside API tokens as its access-control mechanism, so the agent is granted scoped access to Jira resources.

JIRA authentication

When we connect with JIRA MCP, the screens open to accept the OAuth approval. Once we click on "Approve then Accept," you are connected with JIRA and can fetch the user story.

JIRA accept and allow

Suppose the user story has already been created in JIRA.

jira user story created

Now let's write a simple prompt:

Connect with JIRA and fetch the user story with status "To Do".

With the help of JIRA MCP, one user story is fetched automatically.

JIRA user story fetched automatically

Step 2: Generating the Test Plan Using Playwright Planner Agent

Once the requirements are analyzed, the Playwright Planner Agent starts building the test strategy automatically.

The generated test plan may include:

  • Functional test scenarios
  • Positive and negative validations
  • Edge cases

Prompt:

Connect with JIRA using the JIRA MCP server, and read the user story with the status of "To Do." Create the test plan and save it.

Once you run the above prompt, the test plan is created under the test-plans folder, with scenarios created covering Positive (Happy Path) and negative test cases.

Reading user story

Step 3: Creating Automation Scripts Using Playwright Generator Agent

After the test plan is finalized, the Playwright Generator Agent converts the planned scenarios into automation scripts. Using the application context and Playwright MCP capabilities, the AI agent generates a Playwright script.

The generator agent can:

  • Create reusable test scripts
  • Generate Page Object Models (POM)
  • Add assertions and validations

Now, let's create the automation script using Playwright/JavaScript and follow the Playwright (POM) design pattern.

Prompt:

Use the generated test plan file @test-plans/SCRUM-53-test-plan.md as the source of truth and create Playwright tests in JavaScript only for the Happy Path - Test Scenario #1. Follow the POM design pattern.

In the screenshot below, you can see the Page and Test class, utility for test data and other required pieces are created.

Utility for test data created

When you execute the test case in headed mode new account is created successfully with a successful validation message.

  • The new account creation screen appears, where the required details are entered and submitted to create the account.Entering Account Creation Details
  • A successful account creation validation message is displayed, confirming that the new account has been created successfully.successfully created account

The test cases pass successfully across all three browsers. Playwright runs tests with browser setup support for Chromium, Firefox, and WebKit, ensuring consistent test execution across multiple browser environments.

running on multiple browsers

Step 4: Intelligent Test Execution and Self-Healing with Playwright MCP

Once the automation scripts are generated, the intelligent agent begins execution using Playwright MCP. The AI agent interacts with the browser like a real user by:

  • Navigating through application workflows
  • Performing UI actions

However, the real power of intelligent automation appears during failures.

In traditional automation testing frameworks, small UI changes such as updated locators, dynamic elements, or DOM modifications often cause test failures.

With auto-heal in Playwright, the intelligent healing agent can detect failures and automatically adapt the test execution by:

  • Analyze the updated DOM structure
  • Identify alternative locators
  • Retry actions intelligently

Let's take an example by intentionally failing the generated script by updating the locator with the wrong ID, and see how Playwright Healer fixes the test case.

In the test case below, you have intentionally updated the locator with an incorrect ID.

Playwright healer agent

When you execute the test case again it definitely fails. Now let's take the help of the Playwright Healer agent to fix the test case.

Prompt:

Test cases are failing @.github/agents/playwright-test-healer.agent.md help me to fix the test case.

The Playwright Healer Agent clearly identifies that the locator does not exist on the page, which is causing the test to fail. The agent then automatically analyzes the page, finds the correct locator, and updates the test script accordingly, enabling the test case to recover and execute successfully.

Playwright Self heal success

To take a user story from acceptance criteria to a reviewed spec inside Cursor, follow the walkthrough on Playwright MCP with Cursor.

For a Claude Code walkthrough that scrapes test data, records a login video, and refactors a spec file against a demo store, see Playwright MCP with Claude Code.

Scaling Agentic Playwright Testing Beyond the Local Machine

Everything above runs on a local browser, but a stable suite from Generator still needs to run across real browsers and operating systems, not just local Chromium, Firefox, and WebKit.

The Planner, Generator, and Healer agents are doing their authoring and reasoning locally through Playwright MCP, but at this stage, the same AI agent can also be connected to another complementary server: the TestMu AI MCP Server, enabling additional testing capabilities and workflow integration.

TestMu AI (formerly LambdaTest) extends this workflow by providing an AI-native quality engineering platform that helps teams plan, create, execute, and analyze tests using intelligent agents. It supports end-to-end testing across web, mobile, and enterprise applications with real browsers, real devices, and scalable test environments. Its AI app testing agent writes tests from natural-language steps and exports them to Playwright, Selenium, Cypress, or Appium code.

Where Playwright MCP gives an agent control over a live browser, TestMu AI MCP Server gives the same agent direct access to your cloud execution and debugging data, without leaving the IDE. It groups its tools into four categories, each mapped to a different stage of the pipeline:

  • HyperExecute Tool: Generates the HyperExecute YAML and runner commands for your project automatically, monitors running jobs, and pulls session details, the same configuration work that used to mean hand-writing YAML and switching to a dashboard.
  • Automation Tool: When a test fails on the grid, this pulls the TestID's command logs, network logs, and console output straight into the chat, so the agent (or you) can triage the failure without opening a separate results page.
  • SmartUI Tool: Takes a SmartUI comparisonId and returns a natural-language breakdown of what actually changed, pixel differences, layout shifts, DOM structure changes, and a human-perception read of whether the change is meaningful or noise.
  • Accessibility Tool: Runs a WCAG audit against a hosted URL or a local React app and returns remediation guidance directly in the IDE.

This means the same conversational loop you used with Playwright MCP to generate and heal tests locally can continue once those tests move to the cloud.

You can ask the agent to "create a HyperExecute YAML for this project," "triage the last failed test on TestID XXXXX," or "run a SmartUI analysis on comparisonId YYYYY," and it calls the relevant tool directly instead of you opening a dashboard to look it up.

Setup follows the same MCP pattern: add the server URL (https://mcp.lambdatest.com/mcp) to your MCP client's configuration, whether that is Cursor, Claude Code, Claude Desktop, GitHub Copilot in VS Code, or another MCP-compatible client, and complete the OAuth flow on first use.

TestMu AI (formerly LambdaTest) is the underlying test automation platform behind this server, so once connected, this agentic loop extends from "Generator wrote my Playwright test" all the way to "this test failed on real Chrome on Windows 11, and here is why," without the agent or the engineer leaving the chat panel.

To connect your Playwright MCP workflow and achieve its full potential, follow the support documentation on how to get started with the TestMu AI MCP Server, configure the connection, and integrate your MCP-compatible AI clients with TestMu AI capabilities.

For the servers that replace it, see Playwright MCP alternatives.

Conclusion

Run npx playwright init-agents --loop=vscode in an existing Playwright project, point the planner at one Jira ticket you already have, and let the generator produce the first spec. One ticket is enough to judge whether the loop earns a place in your workflow.

Keep a human in the review path. QA engineers should read the generated test plans and scripts before they merge, checking that the scenarios match business intent and that the healer repaired a locator rather than masking a real regression.

When those specs outgrow your laptop, connect the same agent to the TestMu AI MCP Server using the documentation linked earlier, and run the suite across real browsers and operating systems. If you would rather describe tests in natural language than wire up the agent loop yourself, KaneAI covers the same plan-generate-execute cycle as a managed testing agent.

The same agentic MCP approach is expanding beyond the browser, as mobile teams adopt Appium MCP for AI-powered mobile test automation. For structuring the generated code, use Playwright fixtures, and for diagnosing failures the healer could not resolve, see Playwright Reporting and Playwright Docker. To drive the browser straight from an AI editor, see Cursor browser automation.

Advanced Web Testing with Playwright and AI, presented at Testμ 2026, works through the same problem.

Testing from the terminal? Kane CLI by TestMu AI lets SDETs and developers plan, write, run and debug tests from the command line.

To run your first test, start free, or
for a full walkthrough of the product.

Author

...

Kailash Pathak

Blogs: 11

  • Twitter
  • Linkedin

Kailash Pathak is a Senior QA Lead Manager at 3Pillar Global with over 18 years of experience in software testing and automation. He has built scalable automation frameworks using Selenium, Cypress, and Playwright, integrating them with CI/CD pipelines and aligning them with business goals. He is the author of Web Automation Testing Using Playwright, which ranked #1 in Amazon’s “API & Operating Environments” category for six consecutive months. He is a Microsoft MVP (Most Valuable Professional) in Quality Assurance, a LinkedIn “Top QA Voice” with 19,500+ followers, and a core member of TestMu AI Spartans, DZone, and Applitools Ambassador programs. Kailash holds certifications including AWS (CFL), PMI-ACP®, ITIL®, PRINCE2 Practitioner®, and ISTQB. He has delivered 25+ QA talks across conferences and webinars and actively mentors engineers while driving quality strategies, shift-left testing, and continuous improvement.

Reviewer

...

Srinivasan Sekar

Reviewer

  • Linkedin

Srinivasan Sekar is Director of Engineering at TestMu AI, where he leads engineering and open-source initiatives behind the Selenium and Appium automation grid and owns TestMu AI's MCP Server. A committer to Appium and a contributor to Selenium, WebdriverIO, Taiko, and AppiumTestDistribution, he brings over 15 years of experience in quality engineering and open-source technologies. He is the author of the Apress book 'The MCP Standard: A Developer's Guide to Building Universal AI Tools with the Model Context Protocol,' a Certified Kubernetes and Cloud Native Associate, and an international conference speaker. Before TestMu AI he spent over eight years at Thoughtworks as a Principal Consultant and Quality Architect. Srinivasan holds a B.Tech in Information Technology from Anna University.

Add to Google preferred sources

Summarise with AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

AI and Playwright MCP FAQs

Did you find this page helpful?

More Related Blogs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests