SmartBrowserMCP
A Model Context Protocol server for web automation that enables browser control, element interaction, content extraction, and monitoring using Playwright.
README
SmartBrowserMCP
A Model Context Protocol (MCP) server that provides web automation capabilities through browser control tools.
Overview
SmartBrowserMCP is a TypeScript/Node.js server that implements the Model Context Protocol to expose browser automation functionality. It uses Playwright for browser management and provides tools for web testing, monitoring, and automation tasks.
Features
- Browser Automation: Control web browsers programmatically
- Element Interaction: Click elements by CSS selector, text content, or link text
- Content Extraction: Extract text and HTML content from pages or specific elements
- Page Navigation: Scroll pages and navigate web content
- Console Monitoring: Check browser console logs and errors
- Network Monitoring: Monitor network requests and responses
- Screenshot Capture: Take screenshots of web pages
- Task Execution: Execute custom automation tasks
- Report Generation: Generate detailed reports of browser sessions
- Session Management: Clear and manage browser sessions
Installation
npm install
Development
Prerequisites
- Node.js (v18 or higher)
- npm or yarn
Setup
- Clone the repository
- Install dependencies:
npm install - Create a
.envfile (optional):MCP_SERVER_PORT=3000 MCP_SERVER_HOST=0.0.0.0 MCP_TRANSPORT=stdio BROWSER_HEADLESS=true BROWSER_SLOW_MO=0 BROWSER_TIMEOUT=30000 LOG_LEVEL=info
Building
npm run build
Running
Development mode:
npm run dev
Production mode:
npm run build
npm start
Transport Modes
The server supports two transport modes controlled by the MCP_TRANSPORT environment variable:
STDIO Mode (Default)
For MCP clients like Claude Desktop, Cursor, and other MCP-compatible applications.
Run in STDIO mode:
# Default mode (no env var needed)
npm run build
npm start
# Explicit STDIO mode
MCP_TRANSPORT=stdio
HTTP Mode
For direct API usage and web-based integration.
Run in HTTP mode:
MCP_TRANSPORT=http
Using npm link (global command):
npm link
smartbrowser-mcp
MCP Client Configuration:
For Claude Desktop, add to your MCP config:
{
"mcpServers": {
"smartbrowser": {
"command": "npx",
"args": [
"smartbrowsermcp@latest"
],
"env": {
"MCP_TRANSPORT": "stdio",
"BROWSER_HEADLESS": "true"
}
}
}
}
Visible Browser Mode:
To see the browser automation in real-time, set BROWSER_HEADLESS to false:
{
"mcpServers": {
"smartbrowser": {
"command": "npx",
"args": [
"smartbrowsermcp@latest"
],
"env": {
"MCP_TRANSPORT": "stdio",
"BROWSER_HEADLESS": "false"
}
}
}
}
Or using local path:
{
"mcpServers": {
"smartbrowser": {
"command": "node",
"args": ["/var/www/html/LMStudio/WebPilotMCP/dist/index.js"],
"env": {
"MCP_TRANSPORT": "stdio",
"BROWSER_HEADLESS": "false"
}
}
}
}
Mode Differences:
- HTTP Mode: For direct API usage and testing. Server runs on configured port (default: 3000)
- STDIO Mode: For MCP clients. Communicates via stdin/stdout using JSON-RPC protocol
- Headless Mode (default): Browser runs in background, not visible to user
- Visible Mode (
BROWSER_HEADLESS=false): Browser window opens, users can watch automation
Available Tools
The server provides the following MCP tools:
executeTask: Execute custom automation taskscheckConsole: Monitor browser console for logs and errorscheckNetwork: Monitor network activitytakeScreenshot: Capture screenshots of web pagesgenerateReport: Generate detailed session reportsclearSession: Clear browser session dataclick_element: Click elements by CSS selector, text content, or link textget_page_content: Extract text and HTML content from pages or specific elementsscrollPage: Scroll pages up/down or to specific positions
API Endpoints
GET /api/mcp: MCP server endpoint (SSE transport)POST /api/mcp: MCP message handling endpointGET /: Server information endpointGET /health: Health check endpoint
Configuration
The server can be configured via environment variables:
Server Configuration
MCP_SERVER_PORT: Server port (default: 3000)MCP_SERVER_HOST: Server host (default: 0.0.0.0)MCP_TRANSPORT: Transport mode -stdioorhttp(default: stdio)
Browser Configuration
BROWSER_HEADLESS: Run browser in headless mode (default: true)BROWSER_SLOW_MO: Slow down operations by specified milliseconds (default: 0)BROWSER_TIMEOUT: Browser operation timeout in milliseconds (default: 30000)
Logging Configuration
LOG_LEVEL: Logging level (default: info)
Advanced Configuration
PLAYWRIGHT_BROWSERS_PATH: Custom path to Playwright browsers
Project Structure
src/
├── config/
│ └── server.ts # Server configuration
├── services/
│ ├── browserManager.ts # Browser instance management
│ └── inputSanitizer.ts # Input sanitization utilities
├── tools/
│ ├── checkConsole.ts # Console monitoring tool
│ ├── checkNetwork.ts # Network monitoring tool
│ ├── clearSession.ts # Session management tool
│ ├── clickElement.ts # Element interaction tool
│ ├── executeTask.ts # Custom task execution
│ ├── generateReport.ts # Report generation tool
│ ├── getPageContent.ts # Content extraction tool
│ ├── scrollPage.ts # Page scrolling tool
│ └── takeScreenshot.ts # Screenshot capture tool
├── types/
│ ├── index.ts # Type definitions
│ └── schemas.ts # Zod schemas for validation
└── index.ts # Main server entry point
Dependencies
- @modelcontextprotocol/sdk: MCP SDK for server implementation
- @modelcontextprotocol/server: MCP server utilities
- playwright: Browser automation
- express: Web server framework
- zod: Schema validation
- dotenv: Environment variable management
- sanitize-html: HTML sanitization for security
License
ISC
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions, please use the project's issue tracker.
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.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.