mcp-playwright
Allows controlling Firefox browser for automation tasks such as navigation, clicking, filling inputs, taking screenshots, executing JavaScript, and extracting page content.
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., "@mcp-playwrightnavigate to example.com and take a screenshot"
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.
MCP Playwright
A Model Context Protocol (MCP) server that provides Playwright browser automation capabilities. This package allows AI assistants and other MCP clients to control web browsers, interact with web pages, and perform automated testing tasks.
Features
🌐 Support for multiple browsers (Chromium, Firefox, WebKit)
🔄 Multiple browser session management
📸 Screenshot capture
🖱️ Element interaction (click, fill, etc.)
⏱️ Wait for elements and conditions
📜 JavaScript execution
📄 Page content extraction
🎯 CSS selector and text-based element targeting
Related MCP server: Playwright MCP Server
Installation
npm install -g mcp-playwrightOr for local development:
npm install mcp-playwrightUsage
As a Standalone Server
mcp-playwright serveWith MCP Client Configuration
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"playwright": {
"command": "mcp-playwright",
"args": ["serve"]
}
}
}Programmatic Usage
import PlaywrightMCPServer from 'mcp-playwright';
const server = new PlaywrightMCPServer();
await server.run();Available Tools
launch_browser
Launch a new browser instance.
Parameters:
browserType(optional): "chromium", "firefox", or "webkit" (default: "chromium")headless(optional): Run in headless mode (default: true)sessionId(optional): Unique session identifier (default: "default")
navigate_to
Navigate to a specific URL.
Parameters:
url(required): URL to navigate tosessionId(optional): Browser session ID (default: "default")
click_element
Click on an element using CSS selector or text.
Parameters:
selector(required): CSS selector or text content to clicksessionId(optional): Browser session ID (default: "default")
fill_input
Fill an input field with text.
Parameters:
selector(required): CSS selector for the input fieldtext(required): Text to fill in the inputsessionId(optional): Browser session ID (default: "default")
get_text
Get text content from an element.
Parameters:
selector(required): CSS selector for the elementsessionId(optional): Browser session ID (default: "default")
take_screenshot
Take a screenshot of the current page.
Parameters:
path(optional): Path to save the screenshot (default: "screenshot.png")fullPage(optional): Capture full page (default: false)sessionId(optional): Browser session ID (default: "default")
wait_for_element
Wait for an element to appear on the page.
Parameters:
selector(required): CSS selector to wait fortimeout(optional): Timeout in milliseconds (default: 30000)sessionId(optional): Browser session ID (default: "default")
execute_script
Execute JavaScript code in the browser context.
Parameters:
script(required): JavaScript code to executesessionId(optional): Browser session ID (default: "default")
get_page_source
Get the HTML source of the current page.
Parameters:
sessionId(optional): Browser session ID (default: "default")
close_browser
Close a browser session.
Parameters:
sessionId(optional): Browser session ID to close (default: "default")
Examples
Basic Web Automation
Launch a browser:
{
"tool": "launch_browser",
"arguments": {
"browserType": "chromium",
"headless": false,
"sessionId": "my-session"
}
}Navigate to a website:
{
"tool": "navigate_to",
"arguments": {
"url": "https://example.com",
"sessionId": "my-session"
}
}Interact with elements:
{
"tool": "click_element",
"arguments": {
"selector": "button[type='submit']",
"sessionId": "my-session"
}
}Web Scraping
Extract text content:
{
"tool": "get_text",
"arguments": {
"selector": "h1.title",
"sessionId": "my-session"
}
}Take screenshots:
{
"tool": "take_screenshot",
"arguments": {
"path": "./screenshots/page.png",
"fullPage": true,
"sessionId": "my-session"
}
}Advanced Automation
Execute custom JavaScript:
{
"tool": "execute_script",
"arguments": {
"script": "return document.querySelectorAll('a').length;",
"sessionId": "my-session"
}
}Wait for dynamic content:
{
"tool": "wait_for_element",
"arguments": {
"selector": ".dynamic-content",
"timeout": 10000,
"sessionId": "my-session"
}
}Multiple Browser Sessions
You can manage multiple browser sessions simultaneously by using different sessionId values:
// Launch first browser
{
"tool": "launch_browser",
"arguments": {
"sessionId": "browser-1",
"browserType": "chromium"
}
}
// Launch second browser
{
"tool": "launch_browser",
"arguments": {
"sessionId": "browser-2",
"browserType": "firefox"
}
}Requirements
Node.js 18+
The package automatically installs Playwright browsers on first use
Development
Clone the repository:
git clone https://github.com/devcodingskill/mcp-playwright.git
cd mcp-playwrightInstall dependencies:
npm installBuild the project:
npm run buildRun in development mode:
npm run devContributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Troubleshooting
Browser Installation Issues
If you encounter browser installation issues, try:
npx playwright installPermission Issues
On Linux/macOS, you might need to install additional dependencies:
npx playwright install-depsMemory Issues
For large-scale automation, consider:
Using headless mode
Closing browser sessions when done
Managing multiple sessions carefully
Security Considerations
This tool provides powerful browser automation capabilities
Be cautious when executing untrusted JavaScript code
Consider running in isolated environments for production use
Review and sanitize any user-provided selectors or scripts
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.
Latest Blog Posts
- 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/devcodingskill/playwright-mcp-tools'
If you have feedback or need assistance with the MCP directory API, please join our Discord server