Playwright MCP Server

Playwright MCP Server

A Model Context Protocol server that enables AI assistants to interact with web pages through browser automation, supporting web scraping, form filling, navigation, and other browser-based tasks using Playwright.

Category
Visit Server

README

Playwright MCP Server

Python 3.8+ License: MIT MCP Server

A powerful Model Context Protocol (MCP) server that provides comprehensive browser automation capabilities using Playwright. This server enables AI assistants to interact with web pages, perform automated testing, web scraping, and complex browser-based workflows.

🚀 Quick Install for VSCode

Install this MCP server directly in VSCode with one click:

Install in VSCode

✨ Features

  • 🌐 Complete Browser Control: Navigate, click, type, and interact with any web element
  • 📸 Screenshot & Visual Testing: Capture full pages or specific elements
  • 🔄 Tab Management: Open, close, and switch between multiple browser tabs
  • 📝 Form Automation: Fill forms, select options, handle checkboxes and radio buttons
  • Smart Waiting: Wait for elements, network requests, or specific page states
  • 🔍 Content Extraction: Get text, attributes, and data from web pages
  • 💻 JavaScript Execution: Run custom JavaScript in the browser context
  • 🛡️ Robust Error Handling: Comprehensive error handling with meaningful messages

📦 Installation

Prerequisites

  • Python 3.8 or higher
  • Node.js (required for Playwright browser installation)

Install from PyPI

pip install playwright-mcp-server
playwright install chromium

Install from Source

git clone https://github.com/nolecram/Build_MCP_Server.git
cd Build_MCP_Server
pip install -e .
playwright install chromium

🔧 Configuration

For MCP Clients

Add to your MCP client configuration:

{
  "mcpServers": {
    "playwright": {
      "command": "playwright-mcp-server",
      "args": []
    }
  }
}

For VSCode MCP Extension

Add to your VSCode settings:

{
  "mcp.servers": {
    "playwright": {
      "command": "playwright-mcp-server"
    }
  }
}

🛠️ Available Tools

Tool Description Parameters
browser_navigate Navigate to a URL url
browser_click Click on an element selector, timeout?
browser_type Type text into an element selector, text, timeout?
browser_screenshot Take a screenshot path?, full_page?
browser_get_text Extract text from an element selector, timeout?
browser_wait_for_selector Wait for element to appear selector, timeout?, state?
browser_evaluate Execute JavaScript script
browser_new_tab Open a new tab url?
browser_close_tab Close current tab -
browser_get_title Get page title -
browser_get_url Get current URL -

💡 Usage Examples

Web Scraping

# Navigate to a website
browser_navigate {"url": "https://example.com"}

# Wait for content to load
browser_wait_for_selector {"selector": ".content"}

# Extract information
browser_get_text {"selector": ".price"}

# Take a screenshot
browser_screenshot {"full_page": true}

Form Automation

# Fill out a form
browser_type {"selector": "#email", "text": "user@example.com"}
browser_type {"selector": "#password", "text": "secretpassword"}
browser_click {"selector": "#login-button"}

Testing Workflows

# Multi-step testing
browser_navigate {"url": "https://app.example.com"}
browser_click {"selector": "#feature-button"}
browser_wait_for_selector {"selector": ".success-message"}
browser_screenshot {"path": "test-result.png"}

🧪 Testing

Run the test suite:

# Install test dependencies
pip install pytest pytest-asyncio

# Run tests
pytest tests/

# Run with coverage
pytest --cov=playwright_mcp_server tests/

📚 Documentation

Comprehensive documentation is available in the docs directory:

🔒 Security

  • Runs in headless mode by default
  • Isolated browser contexts for each session
  • Automatic resource cleanup
  • Configurable timeout limits
  • No sensitive data logging

🤝 Contributing

We welcome contributions! Please see our contributing guidelines:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for your changes
  4. Ensure all tests pass
  5. Submit a pull request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built with Playwright for reliable browser automation
  • Implements the Model Context Protocol specification
  • Inspired by the need for robust browser automation in AI workflows

📈 Roadmap

  • [ ] Support for multiple browser engines (Firefox, Safari)
  • [ ] Advanced element selection strategies
  • [ ] Built-in visual regression testing
  • [ ] Performance monitoring and metrics
  • [ ] Browser extension interaction
  • [ ] Mobile browser simulation

Star this repository if you find it useful!

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured