Patchright Lite MCP Server is a streamlined implementation of the Model Context Protocol that provides stealth browser automation capabilities to AI models. It wraps the Patchright Node.js SDK, which offers undetected browser automation designed to avoid anti-bot detection systems while providing a simple interface for AI integration.
Clone the repository:
git clone https://github.com/yourusername/patchright-lite-mcp-server.git
cd patchright-lite-mcp-server
Install dependencies:
npm install
Build the TypeScript code:
npm run build
Install Chromium-Driver for Pathright:
npx patchright install chromium
Start the server with:
npm start
This will launch the MCP server using stdio transport, ready to integrate with AI tools that support MCP.
Add this configuration to your claude-desktop-config.json
file:
{
"mcpServers": {
"patchright": {
"command": "node",
"args": ["path/to/patchright-lite-mcp-server/dist/index.js"]
}
}
}
Configure the MCP server in VS Code using this command:
code --add-mcp '{"name":"patchright","command":"node","args":["path/to/patchright-lite-mcp-server/dist/index.js"]}'
Run the server using the pre-built Docker image:
docker run -it --rm dylangroos/patchright-mcp
docker build -t patchright-mcp .
docker run -it --rm patchright-mcp
The server provides four essential tools for browser automation:
Launches a browser, navigates to a URL, and extracts content.
Tool: browse
Parameters: {
"url": "https://example.com",
"headless": true,
"waitFor": 1000
}
Returns:
Performs a simple interaction on a page.
Tool: interact
Parameters: {
"browserId": "browser-id-from-browse",
"pageId": "page-id-from-browse",
"action": "click", // can be "click", "fill", or "select"
"selector": "#submit-button",
"value": "Hello World" // only needed for fill and select
}
Returns:
Extracts specific content from the current page.
Tool: extract
Parameters: {
"browserId": "browser-id-from-browse",
"pageId": "page-id-from-browse",
"type": "text" // can be "text", "html", or "screenshot"
}
Returns:
Closes a browser to free resources.
Tool: close
Parameters: {
"browserId": "browser-id-from-browse"
}
Here's a complete workflow demonstrating how to use the tools in sequence:
Launch a browser and navigate to a site:
Tool: browse
Parameters: {
"url": "https://example.com/login",
"headless": false
}
Fill in a login form:
Tool: interact
Parameters: {
"browserId": "browser-id-from-step-1",
"pageId": "page-id-from-step-1",
"action": "fill",
"selector": "#username",
"value": "[email protected]"
}
Fill in password:
Tool: interact
Parameters: {
"browserId": "browser-id-from-step-1",
"pageId": "page-id-from-step-1",
"action": "fill",
"selector": "#password",
"value": "password123"
}
Click the login button:
Tool: interact
Parameters: {
"browserId": "browser-id-from-step-1",
"pageId": "page-id-from-step-1",
"action": "click",
"selector": "#login-button"
}
Extract text to verify login:
Tool: extract
Parameters: {
"browserId": "browser-id-from-step-1",
"pageId": "page-id-from-step-1",
"type": "text"
}
Close the browser:
Tool: close
Parameters: {
"browserId": "browser-id-from-step-1"
}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "patchright" '{"command":"node","args":["path/to/patchright-lite-mcp-server/dist/index.js"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"patchright": {
"command": "node",
"args": [
"path/to/patchright-lite-mcp-server/dist/index.js"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"patchright": {
"command": "node",
"args": [
"path/to/patchright-lite-mcp-server/dist/index.js"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect