PlayMCP (Playwright Browser Automation) MCP server

Provides browser automation capabilities using Playwright, enabling web page navigation, element interaction, content extraction, screenshot capture, and JavaScript execution for web scraping, testing, and automated workflows.
Back to servers
Setup instructions
Provider
jomon003
Release date
Jun 10, 2025
Language
JavaScript
Stats
10 stars

PlayMCP is a powerful browser automation server implementing the Model Context Protocol (MCP). It provides 38 tools for web scraping, testing, and browser automation using Playwright, enabling you to control browsers programmatically with detailed interaction capabilities.

Installation

Prerequisites

  • Node.js 16+
  • Git (for cloning the repository)

Step-by-Step Installation

# Clone the repository
git clone https://github.com/jomon003/PlayMCP.git
cd PlayMCP

# Install dependencies
npm install

# Build the project
npm run build

# Install Playwright browsers
npx playwright install

Verify Installation

npm run start

You should see "Browser Automation MCP Server starting..." if everything is working correctly.

Configuration

Add to MCP Configuration File

Standard MCP Configuration:

{
  "servers": {
    "playmcp-browser": {
      "type": "stdio",
      "command": "node",
      "args": ["./dist/server.js"],
      "cwd": "/path/to/PlayMCP",
      "description": "Browser automation server using Playwright"
    }
  }
}

Alternative Configuration (works with VS Code GitHub Copilot):

{
  "servers": {
    "playmcp-browser": {
      "type": "stdio",
      "command": "node",
      "args": ["/absolute/path/to/PlayMCP/dist/server.js"]
    }
  }
}

For Windows users:

{
  "servers": {
    "playmcp-browser": {
      "type": "stdio",
      "command": "node",
      "args": ["C:\\path\\to\\PlayMCP\\dist\\server.js"]
    }
  }
}

Configuration Locations

  • Claude Desktop:

    • Windows: %APPDATA%\Claude\config.json
    • macOS: ~/Library/Application Support/Claude/config.json
    • Linux: ~/.config/Claude/config.json
  • VS Code MCP Extension: Add to your VS Code settings.json or MCP configuration file.

Usage Examples

Basic Web Scraping

// Open browser and navigate
await openBrowser({ headless: false, debug: true })
await navigate({ url: "https://example.com" })

// Extract content
const title = await getPageTitle()
const links = await getLinks()
const forms = await getForms()

Form Automation

// Fill out a form
await click({ selector: "#login-button" })
await type({ selector: "#username", text: "[email protected]" })
await type({ selector: "#password", text: "password123" })
await click({ selector: "#submit" })

Page Interaction

// Enhanced scrolling with feedback
await scroll({ x: 0, y: 500, smooth: false })
// Returns: { before: {x: 0, y: 0}, after: {x: 0, y: 500}, scrolled: {x: 0, y: 500} }

// Smooth scrolling
await scroll({ x: 0, y: 300, smooth: true })

// Mouse interaction
await moveMouse({ x: 100, y: 200 })
await click({ selector: ".dropdown-menu" })

DOM Structure Analysis

// Get page hierarchy (3 levels deep)
await getElementHierarchy({ maxDepth: 3 })

// Get detailed hierarchy with text and attributes
await getElementHierarchy({ 
  selector: "#main-content", 
  maxDepth: -1, 
  includeText: true, 
  includeAttributes: true 
})

// Get basic structure of a specific section
await getElementHierarchy({ selector: ".sidebar", maxDepth: 2 })

Advanced JavaScript Execution

// Run custom JavaScript
await executeJavaScript({ 
  script: "document.querySelectorAll('h1').length" 
})

// Modify page content
await executeJavaScript({ 
  script: "document.body.style.backgroundColor = 'lightblue'" 
})

// Extract complex data
await executeJavaScript({ 
  script: `
    Array.from(document.querySelectorAll('article')).map(article => ({
      title: article.querySelector('h2')?.textContent,
      summary: article.querySelector('p')?.textContent
    }))
  `
})

Screenshots

// Take screenshots
await screenshot({ path: "./full-page.png", type: "page" })
await screenshot({ path: "./element.png", type: "element", selector: "#main-content" })

Available Tools

Core Browser Controls

  • openBrowser - Launch a new browser instance with optional headless mode
  • navigate - Navigate to any URL
  • click - Click elements using CSS selectors
  • type - Type text into input fields
  • moveMouse - Move mouse to specific coordinates
  • scroll - Scroll the page with enhanced feedback
  • screenshot - Take screenshots of the page or elements
  • closeBrowser - Close the browser instance

Navigation & Interaction

  • goForward - Navigate forward in browser history
  • goBack - Navigate back in browser history
  • hover - Hover over elements
  • dragAndDrop - Drag elements between locations
  • selectOption - Choose options from dropdowns
  • pressKey - Send keyboard keys (Enter, Escape, etc.)

Data Extraction

  • getPageSource - Get HTML source code
  • getPageText - Get text content
  • getPageTitle - Get page title
  • getPageUrl - Get current URL
  • getElementContent - Get content of specific elements
  • getElementHierarchy - Get DOM structure
  • getLinks - Extract all page links
  • getImages - Get all images with attributes
  • getForms - Analyze form structures
  • getConsoleMessages - Monitor console output
  • getNetworkRequests - Track HTTP requests

JavaScript & Styles

  • executeJavaScript - Run JavaScript code
  • evaluateWithReturn - Execute JS with return values
  • getScripts - Extract JavaScript code
  • getStylesheets - Extract CSS stylesheets
  • getMetaTags - Get meta tags

Troubleshooting

Common Issues

  1. "Browser not initialized" error

    • Make sure to call openBrowser before other operations
    • Check Node.js version is 16+
  2. Playwright installation fails

    # Try manual browser installation
    npx playwright install chromium
    
  3. Path issues in MCP configuration

    • Use absolute paths in your configuration
    • For Windows, use double backslashes in paths
  4. Browser crashes or timeouts

    • Try running with headless: false for debugging
    • Increase system memory if running multiple browsers

Testing Your Installation

# Test the server directly
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | node ./dist/server.js

You should see a JSON response listing all available tools.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "playmcp-browser" '{"type":"stdio","command":"node","args":["./dist/server.js"],"cwd":"/path/to/PlayMCP","description":"Browser automation server using Playwright"}'

See the official Claude Code MCP documentation for more details.

For Cursor

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.

Adding an MCP server to Cursor globally

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": {
        "playmcp-browser": {
            "type": "stdio",
            "command": "node",
            "args": [
                "./dist/server.js"
            ],
            "cwd": "/path/to/PlayMCP",
            "description": "Browser automation server using Playwright"
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "playmcp-browser": {
            "type": "stdio",
            "command": "node",
            "args": [
                "./dist/server.js"
            ],
            "cwd": "/path/to/PlayMCP",
            "description": "Browser automation server using Playwright"
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later