TWD MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@TWD MCP generate a TWD test from this Playwright recording of the login flow"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
TWD MCP
MCP (Model Context Protocol) server for generating TWD tests from browser automation data.
Overview
This MCP server enables AI assistants (Cursor, Claude Desktop) to generate TWD tests from browser automation sessions. It works in conjunction with Playwright MCP to execute browser actions programmatically and automatically generate test code.
đ Full Documentation: For complete documentation, see the TWD MCP Integration Guide in the TWD documentation.
Related MCP server: Quality MCP
Architecture
Playwright MCP (captures) â AI (orchestrates) â TWD MCP (generates test code)TWD MCP focuses only on data transformationâbrowser capture is handled by Playwright MCP. We focus on Playwright MCP because:
Semantic alignment: Playwright uses accessibility tree snapshots that map perfectly to TWD's
screenDom(Testing Library) approachStructured data: Playwright provides clean, structured interaction data ideal for code generation
Cross-browser: Works across Chromium, Firefox, and WebKit
Test-focused: Built specifically for automation and testing scenarios
Tools
1. suggestSelectors
Maps DOM elements to Testing Library selector suggestions. Prioritizes accessible selectors (role > label > text > placeholder > testid).
Input:
tagName(required): HTML tag namerole,textContent,ariaLabel,placeholder,testId,name(optional)
Output: Array of selector suggestions with priority
2. generateMocksFromNetwork
Generates TWD mock request handlers from captured network requests/responses.
Input:
requests: Array of network requests withurl,method, andresponse(withstatusandbody)
Output: TWD mock handler code
3. generateTestFromRecording
Generates a complete TWD test file from browser recording data.
Input:
interactions: Array of user interactions (click, type, navigate)networkCalls(optional): Array of network requests to mocktestName(optional): Name for the test
Output: Complete TWD test file code
Installation
The TWD MCP server is designed to be used via npx, so no installation is required. However, if you want to develop or contribute to the project:
npm install
npm run buildTesting the MCP Server
Prerequisites
Install dependencies:
npm installBuild the project:
npm run buildMethod 1: Test with MCP Inspector (Recommended)
Install MCP Inspector globally:
npm install -g @modelcontextprotocol/inspectorRun the inspector:
mcp-inspector npx twd-mcpThis will open a web interface where you can test all three tools interactively.
Method 2: Test via Cursor/Claude Desktop (Recommended for Real Testing)
Add both Playwright MCP and TWD MCP to your Cursor settings.
For Cursor: Edit
~/.cursor/mcp.json(create if it doesn't exist)For Claude Desktop: Edit
~/Library/Application Support/Claude/claude_desktop_config.json(macOS) or%APPDATA%\Claude\claude_desktop_config.json(Windows)You can reference
mcp.json.examplein this repo for the exact format. Add both servers:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp"]
},
"twd-mcp": {
"command": "npx",
"args": ["twd-mcp@1.0.0"]
}
}
} Version Options for twd-mcp:
"twd-mcp@1.0.0"- Pin to specific version (recommended for stability)"twd-mcp@^1.0.0"- Allow patch and minor updates (1.0.1, 1.1.0, but not 2.0.0)"twd-mcp@latest"- Always use latest version (may break with major updates)"twd-mcp"- Uses latest, but npx caching may delay updates
Note: If you already have other MCP servers configured (like chrome-devtools), just add playwright and twd-mcp to the existing mcpServers object.
Restart Cursor/Claude Desktop
Test the integration by asking:
"Use Playwright to navigate to example.com and click the login button, then generate a TWD test from that"
"Use Playwright to automate navigating to my app, clicking the login button, and filling the form, then generate a TWD test"
Or test individual tools:
"Suggest selectors for a button element with text 'Submit'"
"Generate mocks from these network requests: [paste JSON]"
"Generate a test from these interactions: [paste JSON]"
Development
# Watch mode for development
npm run dev
# Build for production
npm run buildUsage Example
In Cursor (with both Playwright MCP and TWD MCP configured), you can prompt:
"Use Playwright to navigate to my app, click the login button, fill the form with test@example.com, then generate a TWD test from those actions"
Note: Playwright MCP executes actions programmatically based on your descriptionâit doesn't manually record your browser interactions. You describe what should happen, and Playwright MCP executes those actions and captures the data.
The AI will:
Use Playwright MCP to:
Navigate to the URL
Execute the described actions (clicks, typing, navigation) programmatically
Capture DOM snapshots with accessibility tree data
Capture network requests/responses
Transform Playwright data to TWD MCP format
Call TWD MCP
generateTestFromRecordingtool with the interactions and network callsOutput a complete TWD test file ready to use
Example Generated Output
import { twd, userEvent, screenDom } from "twd-js";
import { describe, it, beforeEach } from "twd-js/runner";
describe("Login flow", () => {
beforeEach(() => {
twd.clearRequestMockRules();
});
it("should complete the recorded flow", async () => {
// Define mocks before interactions
twd.mockRequest("LoginRequest", {
method: "POST",
url: "/api/login",
response: { token: "abc123" },
status: 200
});
await userEvent.click(screenDom.getByRole('button', { name: /login/i }));
await userEvent.type(screenDom.getByLabelText(/email/i), 'user@example.com');
// ... more interactions
});
});Resources
đ Full Documentation - Complete guide in TWD docs
đŚ View on npm
đ Report bugs
đŹ Join discussions
â Star on GitHub
Available Tools
3 toolsgenerateMocksFromNetworkC
Generate TWD mock request handlers from captured network requests/responses.
Inputs: requests (required).
generateTestFromRecordingC
Generate a complete TWD test file from browser recording data (interactions and optional network calls).
Inputs: interactions (required), testName, networkCalls.
suggestSelectorsA
Suggest testing-library selectors for a DOM element. Prioritizes accessible selectors (role > label > text > placeholder > testid).
Inputs: tagName (required), name, role, testId, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogâŚ
TDQS
Scored across 3 tools
Each tool targets a distinct output: selector suggestions, mock handlers, and a full test file. The only mild overlap is that generateTestFromRecording can embed network calls that generateMocksFromNetwork also handles, but the descriptions make the boundary clear.
All three names use camelCase with a clear verb+object pattern (suggestâŚ, generateâŚFromâŚ). The two generate*From* names are parallel; suggestSelectors deviates slightly by omitting a source qualifier but remains readable and consistent in style.
Three tools is lean but appropriate for a narrowly scoped recording-to-test workflow, and each covers a distinct step. It sits at the low end of the typical range without feeling padded or arbitrary.
The core pipeline (suggest selectors, generate mocks, generate test) is covered, but there are gaps: no tool to capture/list recordings, no way to run or validate a generated test, and no editing/refinement operation. Agents can work around these but will hit dead ends beyond generation.
Maintenance
Related MCP Connectors
Approved test intent, reviewed Playwright automation and run evidence, inside your editor.
Write, run and check natural-language browser tests of your web app from your AI assistant.
Direct access to Cypress tests results and accessibility reports in your AI workflow.
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to execute browser automation, perform QA tasks, and generate test code through natural language commands using Playwright.7MIT
- AlicenseNot gradedqualityNot gradedmaintenanceAutomates repository analysis, test planning, and generation of end-to-end tests with Playwright, acting as an intelligent quality assistant.MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to summarize Playwright test runs, identify flaky tests, heuristically triage failures, generate Playwright test stubs, and retrieve recent GitHub CI status through MCP tool calls.5MIT
- AlicenseAqualityBmaintenanceEnables AI coding assistants to generate, score, run, and auto-heal Playwright E2E tests while enforcing domain-driven page object architecture and anti-flakiness rules.8MIT