Playwright MCP
剧作家-mcp
Playwright 的 MCP(模型上下文协议)包装器。该服务器使 LLM 驱动的客户端能够控制浏览器执行自动化任务。
成分
资源
服务器公开访问浏览器截图的资源:
截图资源URI:
screenshot://{page_id}所有打开的页面都会自动提供屏幕截图资源
提示
服务器提供提示来帮助客户端解释网页:
interpret-page:分析当前网页内容和结构可选的
page_id参数用于选择要解释的页面可选
focus参数,用于关注特定方面(完整、表格、导航、文本)返回文本分析和页面截图
工具
该服务器实现了一套全面的浏览器自动化工具:
浏览器导航
navigate:转到特定的 URLnew_page:创建一个具有特定 ID 的新浏览器页面switch_page:切换到不同的浏览器页面get_pages:列出所有可用的浏览器页面
页面交互
click:使用 CSS 选择器单击元素type:在输入元素中输入文本wait_for_selector:等待元素出现在页面上
内容提取
get_text:从元素获取文本内容get_page_content:获取整个页面 HTMLtake_screenshot:捕获页面或元素的视觉状态
Related MCP server: mcp-browser-automation
配置
安装依赖项
uv add playwright
playwright install chromium快速入门
安装
克劳德桌面
在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json
在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json
"mcpServers": {
"playwright-mcp": {
"command": "uv",
"args": [
"--directory",
"/Users/shannon/Workspace/artivus/playwright-mcp",
"run",
"playwright-mcp"
]
}
}"mcpServers": {
"playwright-mcp": {
"command": "uvx",
"args": [
"playwright-mcp"
]
}
}发展
构建和发布
准备分发包:
同步依赖项并更新锁文件:
uv sync构建软件包分发版:
uv build这将在dist/目录中创建源和轮子分布。
发布到 PyPI:
uv publish注意:您需要通过环境变量或命令标志设置 PyPI 凭据:
令牌:
--token或UV_PUBLISH_TOKEN或用户名/密码:
--username/UV_PUBLISH_USERNAME和--password/UV_PUBLISH_PASSWORD
调试
由于 MCP 服务器通过 stdio 运行,调试起来可能比较困难。为了获得最佳调试体验,我们强烈建议使用MCP Inspector 。
您可以使用以下命令通过npm启动 MCP Inspector:
npx @modelcontextprotocol/inspector uv --directory /Users/shannon/Workspace/artivus/playwright-mcp run playwright-mcp启动后,检查器将显示一个 URL,您可以在浏览器中访问该 URL 以开始调试。
Available Tools
10 toolsclickC
Click on an element by selector
Inputs: selector (required), page_id.
get_page_contentC
Get the current page HTML content
Inputs: page_id.
get_pagesB
List all available browser pages
Inputs: no named parameters.
get_textC
Get text content from an element
Inputs: selector (required), page_id.
new_pageC
Create a new browser page
Inputs: page_id (required).
switch_pageC
Switch to a different browser page
Inputs: page_id (required).
take_screenshotC
Take a screenshot of the current page
Inputs: page_id, selector.
typeC
Type text into an input element
Inputs: selector (required), text (required), page_id.
wait_for_selectorC
Wait for an element to be visible on the page
Inputs: selector (required), page_id, timeout.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool has a clearly distinct purpose with no ambiguity. For example, 'click' is for interacting with elements, 'navigate' is for URL changes, and 'take_screenshot' is for capturing visual output. The descriptions make it easy to differentiate between element interaction tools like 'click', 'type', and 'get_text'.
The naming follows a consistent verb-based pattern with clear actions like 'click', 'navigate', and 'type'. There are minor deviations with 'get_page_content' and 'get_text' using 'get_' prefix while others use simple verbs, but overall the naming is highly readable and predictable.
With 10 tools, this is well-scoped for a Playwright automation server. Each tool earns its place by covering essential browser automation tasks like navigation, page management, element interaction, and content retrieval without being overwhelming or redundant.
The toolset provides complete coverage for core browser automation workflows. It includes navigation, page management, element interaction, content retrieval, and screenshot capabilities. There are no obvious gaps—agents can perform full automation sequences from start to finish.
Maintenance
Related MCP Connectors
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Official Browserless MCP server: browser automation, scraping, screenshots and PDFs for AI agents.
Unofficial Browserless MCP — wraps the Browserless headless-Chromium REST API (browserless.io)
Unofficial Hyperbrowser MCP — wraps the Hyperbrowser AI-agent browsing API (hyperbrowser.ai).…
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceExposes Playwright browser automation as MCP tools, enabling AI assistants to control a real browser tab-by-tab for form filling, navigation, and more, while preserving the user's active session.-
- AlicenseBqualityDmaintenanceAn MCP server for generic browser automation using Playwright. Enables MCP clients to navigate pages, inspect elements, execute JavaScript, capture screenshots, and monitor console logs and network traffic via a headless Chromium instance.7ISC
- AlicenseAqualityDmaintenanceEnables MCP clients to automate a real Chrome browser via Playwright, supporting session sharing and tools for navigation, clicking, typing, and more.11108 npm2MIT
- AlicenseCqualityDmaintenanceExposes a remote browser as MCP tools via Playwright, enabling AI agents to navigate and interact with web pages through DOM snapshots, clicks, typing, and form operations.4014 npm14Apache 2.0