Provides comprehensive browser automation capabilities including navigation, content extraction, form filling, screenshot capture, and JavaScript execution through Playwright's Firefox engine.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Browser MCP Servergo to github.com and take a screenshot of the trending page"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Related MCP server: Playwright Server MCP
π¦ Installation
Prerequisites
Python 3.8 or higher
Node.js (for Playwright browser installation)
Install from Source
# Clone the repository
git clone <repository-url>
cd claude-browser-mcp
# Install dependencies
pip install -e .
# Install Playwright browsers
playwright installInstall from PyPI (when available)
pip install claude-browser-mcp
playwright installπ Usage
As MCP Server
Start the server with stdio transport:
browser-mcp
# or
python -m src.serverConfiguration
Configure the browser through environment variables:
export BROWSER_HEADLESS=true # Run in headless mode
export BROWSER_TYPE=chromium # Browser type (chromium/firefox/webkit)
export BROWSER_TIMEOUT=30000 # Default timeout in millisecondsMCP Client Integration
Add to your MCP client configuration:
{
"mcpServers": {
"browser-automation": {
"command": "browser-mcp",
"args": []
}
}
}π§ Available Tools
navigate_to
Navigate to a specified URL with optional waiting.
{
"name": "navigate_to",
"arguments": {
"url": "https://example.com",
"wait_for": "selector",
"timeout": 30
}
}get_page_content
Extract text content from the current page.
{
"name": "get_page_content",
"arguments": {
"include_links": true,
"selector": ".main-content"
}
}click_element
Click on elements by CSS selector.
{
"name": "click_element",
"arguments": {
"selector": "button#submit",
"timeout": 10
}
}fill_form
Fill form fields with data.
{
"name": "fill_form",
"arguments": {
"fields": {
"#email": "user@example.com",
"#password": "secretpass"
},
"submit": true
}
}take_screenshot
Capture page screenshots.
{
"name": "take_screenshot",
"arguments": {
"full_page": true,
"selector": ".dashboard"
}
}execute_javascript
Run JavaScript in the browser context.
{
"name": "execute_javascript",
"arguments": {
"code": "document.title",
"return_value": true
}
}π Project Structure
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
# Build and run with Docker Compose
docker-compose up browser-mcp
# Or build manually
./scripts/docker-build.sh
./scripts/start-container.shProduction Deployment
# 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:latestDevelopment with Docker
# Development container with debugging
docker-compose --profile dev up browser-mcp-dev
# Access container
docker exec -it claude-browser-mcp-dev /bin/bashContainer Management
# 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:
{
"success": true,
"url": "https://example.com",
"title": "Page Title",
"data": "...",
"metadata": {
"timestamp": "...",
"execution_time": "..."
}
}Error responses include:
{
"success": false,
"error": "Detailed error message",
"tool": "tool_name",
"arguments": {...},
"timestamp": "..."
}π‘ Environment Variables
Variable | Default | Description |
|
| Run browser in headless mode |
|
| Browser engine to use |
|
| Default timeout (ms) |
π€ Development
Setting up Development Environment
# Install in development mode
pip install -e .[dev]
# Run tests
pytest tests/
# Format code
black src/
# Type checking
mypy src/Adding New Tools
Define tool schema in
server.pyImplement action method in
actions.pyAdd utility functions in
utils.pyUpdate documentation and tests
π License
MIT License - see LICENSE file for details.
π Acknowledgments
Playwright for browser automation
MCP for the protocol specification
Anthropic for Claude and MCP development
π 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.