trackmcp
Back to directory
sac916

claude-browser-mcp

View on GitHub

Browser automation MCP server for Claude Code - provides web interaction tools via Playwright

1 stars PythonWeb & Internet Tools Updated Aug 13, 2025

Documentation

Browser MCP Server

A Model Context Protocol (MCP) server that provides comprehensive browser automation capabilities using Playwright. This server enables AI assistants to interact with web pages through standardized MCP tools for navigation, content extraction, form filling, and screenshot capture.

๐Ÿš€ Features

Core Browser Operations

  • Navigate to URLs with smart waiting strategies
  • Extract page content with customizable selectors
  • Take screenshots (full page, viewport, or specific elements)
  • Execute JavaScript with result capture
  • Click elements by CSS selectors
  • Fill forms automatically with validation

Advanced Capabilities

  • Multi-browser support (Chromium, Firefox, WebKit)
  • Request interception and monitoring
  • Viewport customization and responsive testing
  • Link extraction and URL processing
  • Error handling with detailed responses
  • Resource management and cleanup

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.8 or higher
  • Node.js (for Playwright browser installation)

Install from Source

bash
# Clone the repository
git clone 
cd claude-browser-mcp

# Install dependencies
pip install -e .

# Install Playwright browsers
playwright install

Install from PyPI (when available)

bash
pip install claude-browser-mcp
playwright install

๐Ÿ›  Usage

As MCP Server

Start the server with stdio transport:

bash
browser-mcp
# or
python -m src.server

Configuration

Configure the browser through environment variables:

bash
export BROWSER_HEADLESS=true          # Run in headless mode
export BROWSER_TYPE=chromium          # Browser type (chromium/firefox/webkit)
export BROWSER_TIMEOUT=30000          # Default timeout in milliseconds

MCP Client Integration

Add to your MCP client configuration:

json
{
  "mcpServers": {
    "browser-automation": {
      "command": "browser-mcp",
      "args": []
    }
  }
}

๐Ÿ”ง Available Tools

Navigate to a specified URL with optional waiting.

json
{
  "name": "navigate_to",
  "arguments": {
    "url": "https://example.com",
    "wait_for": "selector", 
    "timeout": 30
  }
}

`get_page_content`

Extract text content from the current page.

json
{
  "name": "get_page_content", 
  "arguments": {
    "include_links": true,
    "selector": ".main-content"
  }
}

`click_element`

Click on elements by CSS selector.

json
{
  "name": "click_element",
  "arguments": {
    "selector": "button#submit",
    "timeout": 10
  }
}

`fill_form`

Fill form fields with data.

json
{
  "name": "fill_form",
  "arguments": {
    "fields": {
      "#email": "user@example.com",
      "#password": "secretpass"
    },
    "submit": true
  }
}

`take_screenshot`

Capture page screenshots.

json
{
  "name": "take_screenshot",
  "arguments": {
    "full_page": true,
    "selector": ".dashboard"
  }
}

`execute_javascript`

Run JavaScript in the browser context.

json
{
  "name": "execute_javascript", 
  "arguments": {
    "code": "document.title",
    "return_value": true
  }
}

๐Ÿ“ Project Structure

code
claude-browser-mcp/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ __init__.py          # Package initialization
โ”‚   โ”œโ”€โ”€ server.py            # MCP server implementation
โ”‚   โ”œโ”€โ”€ browser.py           # Browser management
โ”‚   โ”œโ”€โ”€ actions.py           # High-level browser actions
โ”‚   โ””โ”€โ”€ utils.py             # Utility functions
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ setup.py                 # Package configuration
โ””โ”€โ”€ README.md               # This file

๐Ÿ— Architecture

Server (`server.py`)

  • MCP server implementation with tool registration
  • Request routing and response formatting
  • Error handling and logging
  • Async tool execution

Browser Manager (`browser.py`)

  • Playwright browser lifecycle management
  • Context creation and configuration
  • Resource cleanup and recovery
  • Multi-browser support

Actions (`actions.py`)

  • High-level browser automation methods
  • Content extraction and processing
  • Form interaction and validation
  • Screenshot and JavaScript execution

Utils (`utils.py`)

  • HTML sanitization and cleaning
  • URL validation and normalization
  • Image processing and encoding
  • Data formatting utilities

๐Ÿ”’ Security Considerations

  • HTML sanitization removes dangerous scripts and attributes
  • URL validation prevents malicious redirects
  • Input validation for all user-provided data
  • Resource limits prevent excessive memory usage
  • Timeout controls prevent hanging operations

๐Ÿณ Docker Deployment

Quick Start with Docker

bash
# Build and run with Docker Compose
docker-compose up browser-mcp

# Or build manually
./scripts/docker-build.sh
./scripts/start-container.sh

Production Deployment

bash
# Build production image
docker build -t browser-mcp:latest .

# Run with optimal settings
docker run -d \
  --name browser-mcp \
  --init --ipc=host --shm-size=1gb \
  --memory=2g --cpus=1.0 \
  -v $(pwd)/screenshots:/app/screenshots \
  -v $(pwd)/downloads:/app/downloads \
  browser-mcp:latest

Development with Docker

bash
# Development container with debugging
docker-compose --profile dev up browser-mcp-dev

# Access container
docker exec -it claude-browser-mcp-dev /bin/bash

Container Management

bash
# Health check
./scripts/health-check.sh

# View logs
docker logs -f claude-browser-mcp

# Monitor resources
docker stats claude-browser-mcp

๐Ÿšจ Error Handling

The server provides detailed error responses with:

  • Error categorization (timeout, validation, execution)
  • Context information (URL, selector, arguments)
  • Recovery suggestions where applicable
  • Logging for debugging and monitoring

๐Ÿ“Š Response Format

All tools return standardized JSON responses:

json
{
  "success": true,
  "url": "https://example.com",
  "title": "Page Title",
  "data": "...",
  "metadata": {
    "timestamp": "...",
    "execution_time": "..."
  }
}

Error responses include:

json
{
  "success": false,
  "error": "Detailed error message",
  "tool": "tool_name",
  "arguments": {...},
  "timestamp": "..."
}

๐Ÿ›ก Environment Variables

VariableDefaultDescription
`BROWSER_HEADLESS``true`Run browser in headless mode
`BROWSER_TYPE``chromium`Browser engine to use
`BROWSER_TIMEOUT``30000`Default timeout (ms)

๐Ÿค Development

Setting up Development Environment

bash
# Install in development mode
pip install -e .[dev]

# Run tests
pytest tests/

# Format code
black src/

# Type checking
mypy src/

Adding New Tools

1. Define tool schema in `server.py`

2. Implement action method in `actions.py`

3. Add utility functions in `utils.py`

4. Update documentation and tests

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

  • Issues: Report bugs and request features on GitHub
  • Documentation: See inline code documentation
  • Community: Join MCP community discussions

Note: This is a foundational implementation. Additional features like request interception, advanced form handling, and performance optimizations can be added based on specific use cases.

Frequently asked questions

What is claude-browser-mcp?

claude-browser-mcp is Browser automation MCP server for Claude Code - provides web interaction tools via Playwright

How do I install claude-browser-mcp?

Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.

Is claude-browser-mcp open source?

Yes โ€” it is hosted on GitHub at https://github.com/sac916/claude-browser-mcp and has 1 stars.

Related MCP tools

co-browserbrowser-use-mcp-server

Browse the web, directly from Cursor etc. Built for the Model Context Protocol to enhance AI capabilities. Python-based implementation.

760 Python
browserbrowser-usecursor+3
All-Hands-AIopenhands

๐Ÿ™Œ OpenHands: Code Less, Make More for the Model Context Protocol. Enhance AI assistants with powerful integrations. Python-based implementation.

64,677 Python
agentartificial-intelligencechatgpt+6
mem0aimem0

Universal memory layer for AI Agents; Announcing OpenMemory MCP - local and secure memory management. Python-based implementation.

42,646 Python
agentsaiai-agents+12
zhayujiechatgpt-on-wechat

ๅŸบไบŽๅคงๆจกๅž‹ๆญๅปบ็š„่Šๅคฉๆœบๅ™จไบบ๏ผŒๅŒๆ—ถๆ”ฏๆŒ ๅพฎไฟกๅ…ฌไผ—ๅทใ€ไผไธšๅพฎไฟกๅบ”็”จใ€้ฃžไนฆใ€้’‰้’‰ ็ญ‰ๆŽฅๅ…ฅ๏ผŒๅฏ้€‰ๆ‹ฉChatGPT/Claude/DeepSeek/ๆ–‡ๅฟƒไธ€่จ€/่ฎฏ้ฃžๆ˜Ÿ็ซ/้€šไน‰ๅƒ้—ฎ/ Gemini/GLM-4/Kimi/LinkAI๏ผŒ่ƒฝๅค„็†ๆ–‡ๆœฌใ€่ฏญ้Ÿณๅ’Œๅ›พ็‰‡๏ผŒ่ฎฟ้—ฎๆ“ไฝœ็ณป็ปŸๅ’Œไบ’่”็ฝ‘๏ผŒๆ”ฏๆŒๅŸบไบŽ่‡ชๆœ‰็Ÿฅ่ฏ†ๅบ“่ฟ›่กŒๅฎšๅˆถไผไธšๆ™บ่ƒฝๅฎขๆœใ€‚

39,573 Python
aiai-agentchatgpt+17
topoteretescognee

Cognee is the open-source AI memory platform for agents. Give your AI agents persistent long-term memory across sessions with a self-hosted knowledge graph engine.

30,433 Python
agent-memoryagent-skillsai+16
assafelovicgpt-researcher

An LLM agent that conducts deep research (local and web) on any given topic and generates a long report with citations. Built for the Model Context Protocol to

24,026 Python
agentaiautomation+8

Run your own MCP server? See who uses it and what to fix.

Measure it with TrackMCP