Web Browser Server
An advanced web browsing server enabling headless browser interactions via a secure API, providing features like navigation, content extraction, element interaction, and screenshot capture.
random-robbie
Tools
browse_to
Navigate to a specific URL and return the page's HTML content. Args: url: The full URL to navigate to context: Optional context object for logging (ignored) Returns: The full HTML content of the page
extract_text_content
Extract text content from the current page, optionally using a CSS selector. Args: selector: Optional CSS selector to target specific elements context: Optional context object for logging (ignored) Returns: Extracted text content
click_element
Click an element on the current page. Args: selector: CSS selector for the element to click context: Optional context object for logging (ignored) Returns: Confirmation message or error details
get_page_screenshots
Capture screenshot of the current page. Args: full_page: Whether to capture the entire page or just the viewport selector: Optional CSS selector to screenshot a specific element context: Optional context object for logging (ignored) Returns: Base64 encoded screenshot image
get_page_links
Extract all links from the current page. Args: context: Optional context object for logging (ignored) Returns: List of links found on the page
input_text
Input text into a specific element on the page. Args: selector: CSS selector for the input element text: Text to input context: Optional context object for logging (ignored) Returns: Confirmation message
README
MCP Web Browser Server
An advanced web browsing server for the Model Context Protocol (MCP) powered by Playwright, enabling headless browser interactions through a flexible, secure API.
<a href="https://glama.ai/mcp/servers/lwqlaw6k6d"><img width="380" height="200" src="https://glama.ai/mcp/servers/lwqlaw6k6d/badge" alt="Web Browser Server MCP server" /></a>
🌐 Features
- Headless Web Browsing: Navigate to any website with SSL certificate validation bypass
- Full Page Content Extraction: Retrieve complete HTML content, including dynamically loaded JavaScript
- Multi-Tab Support: Create, manage, and switch between multiple browser tabs
- Advanced Web Interaction Tools:
- Extract text content
- Click page elements
- Input text into form fields
- Capture screenshots
- Extract page links with filtering capabilities
- Scroll pages in any direction
- Execute JavaScript on pages
- Refresh pages
- Wait for navigation to complete
- Resource Management: Automatic cleanup of unused resources after inactivity
- Enhanced Page Information: Get detailed metadata about the current page
🚀 Quick Start
Prerequisites
- Python 3.10+
- MCP SDK
- Playwright
Installation
# Install MCP and Playwright
pip install mcp playwright
# Install browser dependencies
playwright install
Configuration for Claude Desktop
Add to your claude_desktop_config.json
:
{
"mcpServers": {
"web-browser": {
"command": "python",
"args": [
"/path/to/your/server.py"
]
}
}
}
💡 Usage Examples
Basic Web Navigation
# Browse to a website
page_content = browse_to("https://example.com")
# Extract page text
text_content = extract_text_content()
# Extract text from a specific element
title_text = extract_text_content("h1.title")
Web Interaction
# Navigate to a page
browse_to("https://example.com/login")
# Input text into a form
input_text("#username", "your_username")
input_text("#password", "your_password")
# Click a login button
click_element("#login-button")
Screenshot Capture
# Capture full page screenshot
full_page_screenshot = get_page_screenshots(full_page=True)
# Capture specific element screenshot
element_screenshot = get_page_screenshots(selector="#main-content")
Link Extraction
# Get all links on the page
page_links = get_page_links()
# Get links matching a pattern
filtered_links = get_page_links(filter_pattern="contact")
Multi-Tab Browsing
# Create a new tab
tab_id = create_new_tab("https://example.com")
# Create another tab
another_tab_id = create_new_tab("https://example.org")
# List all open tabs
tabs = list_tabs()
# Switch between tabs
switch_tab(tab_id)
# Close a tab
close_tab(another_tab_id)
Advanced Interactions
# Scroll the page
scroll_page(direction="down", amount="page")
# Execute JavaScript on the page
result = execute_javascript("return document.title")
# Get detailed page information
page_info = get_page_info()
# Refresh the current page
refresh_page()
# Wait for navigation to complete
wait_for_navigation(timeout_ms=5000)
🛡️ Security Features
- SSL certificate validation bypass
- Secure browser context management
- Custom user-agent configuration
- Error handling and comprehensive logging
- Configurable timeout settings
- CSP bypass control
- Protection against cookie stealing
🔧 Troubleshooting
Common Issues
- SSL Certificate Errors: Automatically bypassed
- Slow Page Load: Adjust timeout in
browse_to()
method - Element Not Found: Verify selectors carefully
- Browser Resource Usage: Auto-cleanup after inactivity period
Logging
All significant events are logged with detailed information for easy debugging.
📋 Tool Parameters
browse_to(url: str, context: Optional[Any] = None)
url
: Website to navigate tocontext
: Optional context object (currently unused)
extract_text_content(selector: Optional[str] = None, context: Optional[Any] = None)
selector
: Optional CSS selector to extract specific contentcontext
: Optional context object (currently unused)
click_element(selector: str, context: Optional[Any] = None)
selector
: CSS selector of the element to clickcontext
: Optional context object (currently unused)
get_page_screenshots(full_page: bool = False, selector: Optional[str] = None, context: Optional[Any] = None)
full_page
: Capture entire page screenshotselector
: Optional element to screenshotcontext
: Optional context object (currently unused)
get_page_links(filter_pattern: Optional[str] = None, context: Optional[Any] = None)
filter_pattern
: Optional text pattern to filter linkscontext
: Optional context object (currently unused)
input_text(selector: str, text: str, context: Optional[Any] = None)
selector
: CSS selector of input elementtext
: Text to inputcontext
: Optional context object (currently unused)
create_new_tab(url: Optional[str] = None, context: Optional[Any] = None)
url
: Optional URL to navigate to in the new tabcontext
: Optional context object (currently unused)
switch_tab(tab_id: str, context: Optional[Any] = None)
tab_id
: ID of the tab to switch tocontext
: Optional context object (currently unused)
list_tabs(context: Optional[Any] = None)
context
: Optional context object (currently unused)
close_tab(tab_id: Optional[str] = None, context: Optional[Any] = None)
tab_id
: Optional ID of the tab to close (defaults to current tab)context
: Optional context object (currently unused)
refresh_page(context: Optional[Any] = None)
context
: Optional context object (currently unused)
get_page_info(context: Optional[Any] = None)
context
: Optional context object (currently unused)
scroll_page(direction: str = "down", amount: str = "page", context: Optional[Any] = None)
direction
: Direction to scroll ('up', 'down', 'left', 'right')amount
: Amount to scroll ('page', 'half', or a number)context
: Optional context object (currently unused)
wait_for_navigation(timeout_ms: int = 10000, context: Optional[Any] = None)
timeout_ms
: Maximum time to wait in millisecondscontext
: Optional context object (currently unused)
execute_javascript(script: str, context: Optional[Any] = None)
script
: JavaScript code to executecontext
: Optional context object (currently unused)
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
# Clone the repository
git clone https://github.com/random-robbie/mcp-web-browser.git
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
# Install dependencies
pip install -e .[dev]
📄 License
MIT License
🔗 Related Projects
💬 Support
For issues and questions, please open an issue on GitHub.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Mult Fetch MCP Server
A versatile MCP-compliant web content fetching tool that supports multiple modes (browser/node), formats (HTML/JSON/Markdown/Text), and intelligent proxy detection, with bilingual interface (English/Chinese).
Hyperbrowser MCP Server
Welcome to Hyperbrowser, the Internet for AI. Hyperbrowser is the next-generation platform empowering AI agents and enabling effortless, scalable browser automation. Built specifically for AI developers, it eliminates the headaches of local infrastructure and performance bottlenecks, allowing you to
React MCP
react-mcp integrates with Claude Desktop, enabling the creation and modification of React apps based on user prompts
Exa MCP
A Model Context Protocol server that enables AI assistants like Claude to perform real-time web searches using the Exa AI Search API in a safe and controlled manner.
Perplexity Chat MCP Server
MCP Server for the Perplexity API.
Web Research Server
A Model Context Protocol server that enables Claude to perform web research by integrating Google search, extracting webpage content, and capturing screenshots.
Browser Use (used by Deploya.dev)
AI-driven browser automation server that implements the Model Context Protocol to enable natural language control of web browsers for tasks like navigation, form filling, and visual interaction.
Aindreyway Codex Keeper
Serves as a guardian of development knowledge, providing AI assistants with curated access to latest documentation and best practices.
Perplexity Deep Research
A server that allows AI assistants to perform web searches using Perplexity's sonar-deep-research model with citation support.