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
访问服务器

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!

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选