Browser Automation MCP Server
A powerful Model Context Protocol (MCP) server that provides comprehensive browser automation capabilities through Selenium WebDriver. This server enables AI assistants to interact with web pages, extract data, and perform complex web automation tasks.
Browser Automation MCP Server
A powerful Model Context Protocol (MCP) server that provides comprehensive browser automation capabilities through Selenium WebDriver. This server enables AI assistants to interact with web pages, extract data, and perform complex web automation tasks.
Quick Start
-
Install the server:
cd LAM-mcp uv install -
Run the server:
# STDIO transport (recommended for most MCP clients) uv run python -m browser_mcp_server.server # Or with SSE transport uv run python -m browser_mcp_server.server --transport sse --port 8000 -
Configure with Claude Desktop: Add to your
claude_desktop_config.json:{ "mcpServers": { "browser-automation": { "command": "uv", "args": ["run", "python", "-m", "browser_mcp_server.server"], "env": { "BROWSER_HEADLESS": "true" } } } }
Available Tools
Core Navigation
navigate_to_url(url)- Navigate to any websiteget_current_url()- Get current page URL and titlerefresh_page()- Refresh the current pagego_back()- Navigate back in historygo_forward()- Navigate forward in history
Element Interaction
click_element(selector, by_type="css")- Click buttons, links, etc.type_text(selector, text, by_type="css")- Type into input fieldsclear_field(selector, by_type="css")- Clear input fieldshover_element(selector, by_type="css")- Hover over elements
Content Extraction
get_element_text(selector, by_type="css")- Extract text from elementsget_page_source()- Get full HTML sourceextract_links()- Get all links on the pageextract_table_data(selector="table")- Extract structured table data
Form Automation
fill_form(form_data)- Fill entire forms with data dictionaryselect_dropdown_option(selector, option_text=None, option_value=None)- Select dropdown options
Advanced Features
take_screenshot(element_selector=None)- Capture page or element screenshotsexecute_javascript(script)- Run custom JavaScriptwait_for_element(selector, timeout=30)- Wait for dynamic contentscroll_page(direction="down", pixels=None)- Scroll in any direction
Utility Functions
is_element_present(selector, by_type="css")- Check element existenceget_element_attribute(selector, attribute, by_type="css")- Get element attributesget_cookies()- Retrieve browser cookiesset_cookie(name, value, domain=None, path="/")- Set cookies
Environment Variables
Configure the server behavior with these environment variables:
# Browser type (chrome, firefox, edge)
BROWSER_TYPE=chrome
# Run in headless mode
BROWSER_HEADLESS=true
# Default timeout in seconds
BROWSER_TIMEOUT=30
# Browser window size
BROWSER_WINDOW_SIZE=1920x1080
# Custom user agent
BROWSER_USER_AGENT="Custom Agent String"
# Download directory
BROWSER_DOWNLOAD_DIR=/path/to/downloads
Example Usage Scenarios
Web Scraping
# Navigate and extract data
await navigate_to_url("https://news.ycombinator.com")
await wait_for_element(".storylink")
links = await extract_links()
headlines = await get_element_text(".storylink")
E-commerce Automation
# Search for products
await navigate_to_url("https://amazon.com")
await type_text("#twotabsearchtextbox", "laptop")
await click_element("#nav-search-submit-button")
await wait_for_element("[data-component-type='s-search-result']")
results = await extract_text("[data-component-type='s-search-result'] h2")
Form Filling
# Contact form automation
await navigate_to_url("https://example.com/contact")
await fill_form({
"#name": "John Doe",
"#email": "john@example.com",
"#message": "Hello from automation!"
})
await click_element("#submit")
Social Media Automation
# Login and post (be mindful of terms of service)
await navigate_to_url("https://twitter.com/login")
await type_text("[name='text']", "username")
await click_element("[role='button']:has-text('Next')")
await wait_for_element("[name='password']")
await type_text("[name='password']", "password")
await click_element("[data-testid='LoginForm_Login_Button']")
Security Best Practices
⚠️ Important Security Considerations:
- Controlled Environment: Use in secure, isolated environments
- Authentication: Implement proper authentication for production use
- Input Validation: Always validate URLs and selectors
- Rate Limiting: Implement delays between requests
- Monitoring: Log all automation activities
- Compliance: Respect robots.txt and website terms of service
Browser Support
- Chrome/Chromium: Full support with automatic driver management
- Firefox: Full support with GeckoDriver auto-installation
- Microsoft Edge: Full support with Edge WebDriver
- Headless Mode: All browsers support headless operation
Error Handling
The server provides comprehensive error handling:
{
"success": false,
"error": "Element not found: #invalid-selector",
"details": "NoSuchElementException details..."
}
Common error types:
TimeoutException: Element not found within timeoutNoSuchElementException: Invalid selector or missing elementElementNotInteractableException: Element not clickable/visibleWebDriverException: Browser communication issues
Development
Running Tests
uv run pytest tests/
Code Quality
# Format code
uv run black browser_mcp_server/
# Sort imports
uv run isort browser_mcp_server/
# Type checking
uv run mypy browser_mcp_server/
Adding New Tools
To add new browser automation tools:
- Add the function to
browser_utils.py - Create an MCP tool wrapper in
server.pyusing@mcp.tool() - Add comprehensive docstrings and type hints
- Include error handling and logging
- Add tests in
tests/
Troubleshooting
Common Issues
Browser won't start:
- Check if Chrome/Firefox is installed
- Verify driver permissions
- Try different browser type:
BROWSER_TYPE=firefox
Elements not found:
- Use
wait_for_element()for dynamic content - Check selector syntax (CSS vs XPath)
- Verify element is visible and interactable
Timeout errors:
- Increase timeout:
BROWSER_TIMEOUT=60 - Check network connectivity
- Ensure page is fully loaded
Permission issues:
- Run with appropriate user permissions
- Check download directory write access
- Verify browser installation location
Debug Mode
Enable debug logging:
export PYTHONPATH=$PYTHONPATH:$(pwd)
python -m browser_mcp_server.server --transport stdio
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License - see LICENSE file for details.
Disclaimer
This tool provides powerful browser automation capabilities. Users are responsible for:
- Complying with website terms of service
- Respecting rate limits and robots.txt
- Ensuring ethical use of automation
- Protecting user privacy and data security
Use responsibly and in accordance with applicable laws and regulations.
Related Documents
Valet V1 — Architecture & Implementation Plan
1. [Vision & Scope](#1-vision--scope)
Writing Effective Skills
What makes a skill actually work vs. being ignored or misapplied. Based on studying production skills across Claude Code (Superpowers, Trail of Bits, Anthropic's official plugins), Codex (babysit-pr, skill-creator, curated catalog), OpenClaw (55 bundled skills, 13,700+ community), and Cursor/Cline rule systems (BMAD-METHOD, RIPER-5, steipete/agent-rules).
Spotipy Types - Implementation Plan
A standalone type stub package for spotipy using Pydantic models generated from the official Spotify Web API OpenAPI schema.
Project Development Requirements (PDR)
**Generated**: 2026-03-22