Playwright MCP Server
Click on "Install 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., "@Playwright MCP ServerNavigate to https://news.ycombinator.com and get the page title"
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.
Playwright MCP Server
A Model Context Protocol (MCP) server that provides Playwright browser automation capabilities. This server enables AI assistants like GitHub Copilot to perform web scraping, testing, and browser automation tasks.
Features
This MCP server exposes 25 comprehensive Playwright tools organized by category:
š Auto-Recording Feature
All actions are automatically recorded! You can generate a complete Playwright test file from any workflow with a single command:
"Generate a Playwright test from my workflow"This automatically creates a test file in generated-tests/ with all your actions. No manual recording needed!
Navigation & Page Control (6 tools)
playwright_navigate: Navigate to URLs with custom wait conditions
playwright_go_back: Navigate back in browser history
playwright_go_forward: Navigate forward in browser history
playwright_reload: Reload the current page
playwright_set_viewport: Set custom viewport dimensions
playwright_get_page_info: Get current page URL and title
Element Interaction (8 tools)
playwright_click: Click elements (supports multiple buttons and click counts)
playwright_fill: Fill input fields quickly
playwright_type: Type text with keyboard simulation and delays
playwright_hover: Hover over elements
playwright_select: Select dropdown options
playwright_checkbox: Check or uncheck checkboxes
playwright_drag_and_drop: Drag and drop elements
playwright_press_key: Press keyboard keys (Enter, Escape, etc.)
Data Extraction (3 tools)
playwright_extract_text: Extract text from single or multiple elements
playwright_get_attribute: Get attribute values from elements
playwright_evaluate: Execute custom JavaScript and get results
Waiting & Synchronization (1 tool)
playwright_wait_for_selector: Wait for elements with custom timeout and state
Capture (1 tool)
playwright_screenshot: Capture full or partial page screenshots
Test Recording & Generation (4 tools)
playwright_record_start: Start recording user actions for test generation
playwright_record_stop: Stop recording actions
playwright_generate_test: Generate test scripts (Playwright/Puppeteer/Selenium in TypeScript/JavaScript/Python)
playwright_generate_workflow_test: š Auto-generate Playwright test from current workflow actions
Browser Management (2 tools)
playwright_close: Close browser and cleanup
All tools support stateful browser sessions (cookies, auth, history preserved)
Related MCP server: Playwright Plus Python MCP
š Prerequisites
Before you begin, ensure you have:
Node.js 18 or higher - Download here
npm (comes with Node.js)
VS Code (for GitHub Copilot integration) - Download here
GitHub Copilot subscription (for AI-powered usage)
š§ Installation & Setup
Step 1: Clone the Repository
git clone <your-repo-url>
cd playwright-mcp-serverStep 2: Install Dependencies
npm installThis will install:
@modelcontextprotocol/sdk- MCP protocol implementationplaywright- Browser automation libraryzod- Schema validationTypeScript and related dependencies
Step 3: Install Playwright Browsers
npx playwright install chromiumThis downloads the Chromium browser binary (~170MB). You can also install other browsers:
# Optional: Install all browsers
npx playwright installStep 4: Build the Server
npm run buildThis compiles TypeScript to JavaScript in the build/ directory.
Step 5: Configure VS Code (GitHub Copilot Integration)
Create or update .vscode/mcp.json in your workspace (not in this project):
{
"mcpServers": {
"playwright": {
"command": "node",
"args": ["/absolute/path/to/playwright-mcp-server/build/index.js"]
}
}
}ā ļø Important: Replace /absolute/path/to/playwright-mcp-server/ with the actual path where you cloned this repo.
Examples:
Windows:
"C:\\Users\\YourName\\Projects\\playwright-mcp-server\\build\\index.js"Mac/Linux:
"/home/username/projects/playwright-mcp-server/build/index.js"
Step 6: Reload VS Code
Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac)Type "Reload Window" and press Enter
Or simply restart VS Code
Step 7: Verify Installation
Open GitHub Copilot Chat in VS Code and try:
Navigate to https://example.com and take a screenshotIf it works, you're all set! š
š” Usage Examples
Basic Browser Automation
Use natural language with GitHub Copilot Chat:
Navigate to https://news.ycombinator.com and get the page titleGo to https://example.com, click the link with text "More information", and take a screenshotNavigate to https://github.com, fill the search box with "playwright", and press EnterAdvanced Interactions
Go to https://amazon.com, hover over the menu, wait for the dropdown, and extract all category namesNavigate to a form page, check the terms checkbox, select "United States" from the country dropdown, and click submitOpen the developer console and execute: document.querySelectorAll('a').lengthTest Recording & Generation
Start recording a test named "login_flow"
Navigate to https://example.com/login
Fill the username field with "testuser"
Fill the password field with "password123"
Click the login button
Wait for the dashboard to load
Stop recording
Generate a Playwright test in TypeScript, save as "login.spec.ts"This will create a complete test file in generated-tests/login.spec.ts!
Multi-Step Workflows
1. Navigate to https://opensource-demo.orangehrmlive.com/web/index.php/auth/login
2. Extract the demo credentials from the page
3. Login with those credentials
4. Verify the dashboard title
5. Take a screenshotData Extraction
Go to https://news.ycombinator.com and extract all article titlesNavigate to a product page and get the price attribute from the element with class "product-price"š¬ Test Generation Feature
Auto-Generate Tests (NEW!)
Simply perform your workflow and generate a test:
Navigate to https://example.com
Click login button
Fill username with "test"
Fill password with "pass"
Click submit
Generate a Playwright test from my workflowResult: Complete test file in generated-tests/workflow_TIMESTAMP.spec.ts
Manual Recording (Original Method)
Record ā Generate ā Run
Step 1: Start Recording
Start recording "checkout_flow"Step 2: Perform Actions (all are automatically recorded)
Navigate to https://demo-store.com
Click .add-to-cart
Fill #email with "test@example.com"
Click .checkout-buttonStep 3: Stop Recording
Stop recordingStep 4: Generate Test
Generate a Playwright test in TypeScript, save as "checkout.spec.ts"Or generate for different frameworks:
Generate a Puppeteer test in JavaScript, save as "checkout.test.js"
Generate a Selenium test in Python, save as "test_checkout.py"Generated test files are saved in generated-tests/ directory and are ready to run!
š Tool Reference
Navigation & Page Control
Tool | Description | Key Parameters |
| Navigate to URL |
|
| Browser back button | - |
| Browser forward button | - |
| Reload current page | - |
| Set viewport size |
|
| Get URL and title | - |
Element Interaction
Tool | Description | Key Parameters |
| Click element |
|
| Fill input quickly |
|
| Type with delays |
|
| Hover over element |
|
| Select dropdown option |
|
| Check/uncheck checkbox |
|
| Drag and drop |
|
| Press keyboard key |
|
Data Extraction
Tool | Description | Key Parameters |
| Extract text content |
|
| Get element attribute |
|
| Execute JavaScript |
|
Waiting & Capture
Tool | Description | Key Parameters |
| Wait for element |
|
| Capture screenshot |
|
Test Generation
Tool | Description | Key Parameters |
| Start recording |
|
| Stop recording | - |
| Generate test script |
|
Browser Management
Tool | Description | Key Parameters |
| Close browser | - |
šļø Architecture
This MCP server follows a 100% local architecture:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā YOUR LOCAL MACHINE ā
ā ā
ā āāāāāāāāāāāāāāāā ā
ā ā VS Code ā ā
ā ā + Copilot ā ā
ā āāāāāāāā¬āāāāāāāā ā
ā ā stdio (no network) ā
ā ā¼ ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā Playwright MCP Server ā ā
ā ā (build/index.js) ā ā
ā āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā ā¼ ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā Chromium Browser (Local) ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāKey Points:
ā No external MCP services - Everything runs locally
ā stdio communication - No HTTP or WebSocket connections
ā No API keys needed - No authentication required
ā Privacy-first - Your automation scripts never leave your machine
ā Offline capable - Works without internet (except for accessing websites)
š ļø Development
Build Commands
# Build once
npm run build
# Watch mode (auto-rebuild on changes)
npm run watch
# Clean build
rm -rf build && npm run buildProject Structure
playwright-mcp-server/
āāā .github/
ā āāā copilot-instructions.md # GitHub Copilot context
āāā .vscode/
ā āāā mcp.json # MCP server configuration
āāā src/
ā āāā index.ts # Main server implementation
āāā build/
ā āāā index.js # Compiled output (generated)
āāā generated-tests/ # Generated test files (created at runtime)
āāā package.json # Dependencies
āāā tsconfig.json # TypeScript configuration
āāā README.md # This fileExtending the Server
To add a new tool:
Define the schema in
src/index.ts:
const MyToolSchema = z.object({
param1: z.string().describe("Description"),
param2: z.number().optional(),
});Add the tool definition:
{
name: "playwright_my_tool",
description: "What this tool does",
inputSchema: { /* JSON schema */ }
}Implement the handler:
case "playwright_my_tool": {
const { param1, param2 } = MyToolSchema.parse(args);
const page = await browserManager.ensurePage();
// Your implementation
return { content: [{ type: "text", text: "Result" }] };
}Rebuild:
npm run build
š Security & Privacy
Local-only operation - No data sent to external servers
Headless mode - Browser runs without visible window (configurable)
Input validation - All parameters validated with Zod schemas
Sandboxed browser - Chromium runs with security flags
No telemetry - No usage tracking or analytics
Best Practices:
Be cautious when navigating to untrusted URLs
Validate user input before passing to
playwright_evaluateReview generated test scripts before running
Use in trusted environments only
š Troubleshooting
Issue: MCP Server Not Connecting
Solution:
# 1. Verify build exists
ls build/index.js
# 2. Test server manually
node build/index.js
# 3. Check VS Code MCP configuration
cat .vscode/mcp.json
# 4. Reload VS Code
# Ctrl+Shift+P ā "Reload Window"Issue: Browser Launch Fails
Solution:
# Install/reinstall browsers
npx playwright install chromium
# Check system dependencies (Linux)
npx playwright install-deps chromium
# Test browser manually
npx playwright open https://example.comIssue: Tool Not Found
Cause: MCP server cache or outdated build
Solution:
# Rebuild
npm run build
# Clear VS Code cache and reload
# Ctrl+Shift+P ā "Developer: Reload Window"Issue: Screenshots Not Saving
Cause: Permission issues or invalid path
Solution:
# Create screenshots directory
mkdir -p screenshots
# Check write permissions
ls -laIssue: Generated Tests Not Appearing
Cause: Directory not created
Solution:
Tests are automatically saved to generated-tests/ directory. If missing:
mkdir generated-testsDebug Mode
Enable detailed logging by modifying src/index.ts:
console.error("DEBUG:", JSON.stringify(request, null, 2));Then rebuild and check terminal output.
šÆ Use Cases
1. Web Scraping
Navigate to a news site and extract all article titles and links2. Automated Testing
Record my login flow, then generate a test suite3. Form Automation
Fill out and submit contact forms with test data4. Visual Regression Testing
Take screenshots of my app in different viewport sizes5. Data Collection
Navigate through paginated results and collect all product information6. Browser-Based Scripts
Execute custom JavaScript to analyze page performanceš Configuration Options
Change Browser Type
Edit src/index.ts:
// Use Firefox instead of Chromium
import { firefox } from "playwright";
this.browser = await firefox.launch({ ... });Headful Mode (Visible Browser)
Edit src/index.ts:
this.browser = await chromium.launch({
headless: false, // Show browser window
args: ["--no-sandbox", "--disable-setuid-sandbox"],
});Custom Viewport
Default is 1280x720. Change in src/index.ts:
this.context = await browser.newContext({
viewport: { width: 1920, height: 1080 },
userAgent: "...",
});Screenshot Directory
Generated tests save to generated-tests/. Modify in src/index.ts:
const testsDir = path.join(process.cwd(), "my-custom-tests");š¤ Contributing
Contributions are welcome! Here's how:
Fork the repository
Create a feature branch:
git checkout -b feature/amazing-featureMake your changes
Build and test:
npm run buildCommit:
git commit -m 'Add amazing feature'Push:
git push origin feature/amazing-featureOpen a Pull Request
Development Setup
git clone <your-fork>
cd playwright-mcp-server
npm install
npm run build
# Make changes in src/
npm run watch # Auto-rebuild on changesš License
MIT
š Related Resources
Model Context Protocol - Official MCP documentation
Playwright - Browser automation framework
MCP TypeScript SDK - Official SDK
GitHub Copilot - AI pair programmer
VS Code - Recommended editor
ā Support & Community
If you find this project useful:
ā Star this repository
š Report issues on GitHub
š” Suggest new features
š¤ Contribute improvements
š® Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Documentation: This README and inline code comments
š Acknowledgments
Built with the Model Context Protocol
Powered by Playwright
Inspired by the MCP community
Made with ā¤ļø for browser automation
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceProvides browser automation capabilities using Playwright, enabling users to navigate websites, extract content, take screenshots, and interact with web pages through natural language prompts.13MIT
- AlicenseBquality-maintenanceEnables browser automation and web scraping through Playwright, supporting navigation, screenshots, element interaction, form filling, JavaScript execution, and content extraction.8
- Alicense-qualityCmaintenanceEnables browser automation using Playwright, allowing LLMs to interact with web pages, take screenshots, generate test code, scrape web pages, and execute JavaScript in a real browser environment.19,860MIT
- Alicense-qualityCmaintenanceEnables AI agents to control a web browser using Playwright, supporting navigation, interaction, and data extraction through natural language.MIT
Related MCP Connectors
Provides cloud browser automation capabilities using Stagehand and Browserbase, enabling LLMs to iā¦
AI-powered browser automation ā navigate, click, fill forms, and extract data from any website.
Automate cloud browsers to navigate websites, interact with elements, and extract structured data.ā¦
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sohitmahato/custom-playwright-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server