Playwright HTML Render
Enables HTML page analysis, verification, and automated correction using Playwright for rendering and Mistral AI for visual inspection. Captures screenshots, analyzes renders against specifications, and generates fixes for HTML issues.
README
MCP Server - Playwright HTML Render
This project exposes HTML analysis and correction capabilities via the MCP (Model Context Protocol).
🚀 Installation
npm install
Make sure you have configured your Mistral API key in a .env file:
MISTRAL_API_KEY=your-api-key
📖 Usage
Option 1: Using with npx (No Installation Required)
You can use this MCP server directly with npx without cloning the repository:
npx github:gplanchat/server-playwright
The MCP server communicates via stdio (standard input/output), allowing MCP clients to connect to it.
Note: Make sure you have the MISTRAL_API_KEY environment variable set, or create a .env file in your current directory.
Option 2: Local Installation
If you've cloned the repository:
npm install
npm run mcp
Configuration for Cursor
To use this MCP server with Cursor, add the following configuration to your Cursor settings:
- Open Cursor settings
- Search for "MCP" or "Model Context Protocol"
- Add the following configuration:
Using npx (Recommended):
{
"mcpServers": {
"playwright-html-render": {
"command": "npx",
"args": ["-y", "github:gplanchat/server-playwright"],
"env": {
"MISTRAL_API_KEY": "your-api-key"
}
}
}
}
Using local installation:
{
"mcpServers": {
"playwright-html-render": {
"command": "node",
"args": ["/path/to/server-playwright/src/mcp-server.js"],
"env": {
"MISTRAL_API_KEY": "your-api-key"
}
}
}
}
Note:
- For npx usage, the
-yflag automatically accepts the package installation prompt - For local installation, replace
/path/to/server-playwrightwith the absolute path to your project
Configuration for Claude Desktop
To use with Claude Desktop, modify the MCP configuration file (usually ~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows):
Using npx (Recommended):
{
"mcpServers": {
"playwright-html-render": {
"command": "npx",
"args": ["-y", "github:gplanchat/server-playwright"],
"env": {
"MISTRAL_API_KEY": "your-api-key"
}
}
}
}
Using local installation:
{
"mcpServers": {
"playwright-html-render": {
"command": "node",
"args": ["/path/to/server-playwright/src/mcp-server.js"],
"env": {
"MISTRAL_API_KEY": "your-api-key"
}
}
}
}
🛠️ Available Tools
The MCP server exposes the following tools:
1. capture_html_render
Captures the render of an HTML page (screenshot, DOM, metadata).
Parameters:
htmlPath(required): Path to HTML file or URLviewport(optional): Viewport size{ width: 1920, height: 1080 }fullPage(optional): Capture the entire page (default:false)
Usage example:
{
"name": "capture_html_render",
"arguments": {
"htmlPath": "https://example.com",
"viewport": { "width": 1920, "height": 1080 }
}
}
2. analyze_html_render
Analyzes an HTML render with AI vision to detect issues.
Parameters:
screenshotPath(required): Path to screenshot PNG filedomPath(required): Path to DOM HTML filemetadataPath(required): Path to metadata JSON filecriteria(optional): Analysis criteria (default:"default")
Usage example:
{
"name": "analyze_html_render",
"arguments": {
"screenshotPath": "output/example-1234567890.png",
"domPath": "output/example-1234567890.html",
"metadataPath": "output/example-1234567890.json",
"criteria": "default"
}
}
3. fix_html_render
Fixes an HTML file based on an analysis.
Parameters:
originalHtmlPath(required): Path to original HTML fileanalysisPath(required): Path to analysis JSON fileautoApply(optional): Automatically apply corrections (default:false)
Usage example:
{
"name": "fix_html_render",
"arguments": {
"originalHtmlPath": "example.html",
"analysisPath": "output/analysis-1234567890.json",
"autoApply": false
}
}
4. test_and_fix_html
Tests and fixes a complete HTML render (capture + analysis + correction).
Parameters:
htmlPath(required): Path to HTML file or URLviewport(optional): Viewport size{ width: 1920, height: 1080 }autoFix(optional): Automatically generate corrections (default:false)criteria(optional): Analysis criteria (default:"default")
Usage example:
{
"name": "test_and_fix_html",
"arguments": {
"htmlPath": "https://example.com",
"viewport": { "width": 1920, "height": 1080 },
"autoFix": true,
"criteria": "default"
}
}
5. verify_html_render
Verifies that an HTML render matches an expected detailed description or CSS specifications.
Parameters:
htmlPath(required): Path to HTML file or URL to verifyexpectedDescription(required): Detailed description of expected render or CSS specificationsviewport(optional): Viewport size{ width: 1920, height: 1080 }fullPage(optional): Capture the entire page (default:false)verificationType(optional): Verification type -"auto"(automatic detection),"description"(textual description),"css"(CSS specifications) (default:"auto")
Example with textual description:
{
"name": "verify_html_render",
"arguments": {
"htmlPath": "https://example.com",
"expectedDescription": "The page must contain a header with a logo on the left, a centered navigation menu with 5 links (Home, About, Services, Portfolio, Contact), and a 'Contact Us' button on the right. The header must have a white background and a height of 80px.",
"verificationType": "description"
}
}
Example with CSS specifications:
{
"name": "verify_html_render",
"arguments": {
"htmlPath": "example.html",
"expectedDescription": ".header { background-color: #ffffff; height: 80px; display: flex; align-items: center; justify-content: space-between; } .logo { width: 150px; height: 50px; } .nav-menu { display: flex; gap: 20px; } .nav-menu a { color: #333; text-decoration: none; }",
"verificationType": "css"
}
}
Response:
{
"success": true,
"conform": true,
"score": 95,
"discrepanciesCount": 1,
"discrepancies": [
{
"severity": "minor",
"property": "gap",
"expected": "20px",
"actual": "15px",
"selector": ".nav-menu",
"description": "The spacing between menu items is 15px instead of 20px",
"suggested_fix": "Add gap: 20px; to .nav-menu"
}
],
"verificationPath": "output/verification-1234567890.md",
"resultPath": "output/verification-1234567890.json"
}
🧪 Testing with MCP Inspector
You can test the MCP server with the official inspector:
npx @modelcontextprotocol/inspector node src/mcp-server.js
This will open a web interface to test the available tools.
📝 Notes
- The MCP server uses stdio for communication, so it must be launched by an MCP client
- Generated files are saved in the
output/folder - Make sure Playwright is installed:
npx playwright install chromium - The Mistral API key is required for analysis and correction tools
📚 Additional Documentation
- NPX_USAGE.md - Guide for using the server with
npxwithout cloning - QUICKSTART.md - Quick start guide
- MISTRAL_SETUP.md - Mistral AI configuration guide
- INTEGRATION.md - AI agent integration guide
🔧 Troubleshooting
Server won't start
Check that:
- Node.js 18+ is installed
- Dependencies are installed (
npm install) - The Mistral API key is configured
Capture errors
Make sure Playwright is installed:
npx playwright install chromium
Analysis errors
Verify that your Mistral API key is valid and you have credits available.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。