Browser Tools MCP
repository·main·Indexed 27 days ago
https://github.com/agentdeskai/browser-tools-mcpAn MCP (Model Context Protocol) server that enables AI-powered applications to monitor and interact with a web browser. It allows agents to capture screenshots, monitor console logs, and run automated web audits for SEO, Performance, Accessibility, and Best Practices via a companion Node server and Chrome extension.
What's inside @agentdeskai/browser-tools-mcp
- The Puppeteer Service is a browser automation service built on Puppeteer designed for reliable cross-platform browser control. It provides features for managing browser instances, emulating various environments, and performing automated audits.
BrowserTools MCP Architecture
mainThe system consists of three layers to enable AI interaction with the browser:
- Chrome Extension: Captures screenshots, console logs, network activity, and DOM elements. It communicates via WebSockets to the Node Server.
- Node Server (
browser-tools-server): Acts as middleware. It receives logs from the extension, processes requests from the MCP server, truncates data to fit token limits, and removes sensitive headers/cookies before sending data to the LLM. - MCP Server (
browser-tools-mcp): Implements the Model Context Protocol, providing standardized tools (like the audit tools mentioned above) to MCP-compatible clients like Cursor, Claude Desktop, Cline, or Zed.
Puppeteer Service Features
mainThe service includes the following capabilities:
Cross-Platform Browser Support
- Supports Windows, macOS, and Linux.
- Detects Chrome, Edge, Brave, and Firefox.
- Includes a fallback strategy for locating browser executables.
Smart Browser Management
- Uses a singleton browser instance with automatic cleanup.
- Implements connection retry mechanisms.
- Manages temporary user data directories with automatic cleanup.
Rich Configuration Options
- Custom browser paths.
- Network condition emulation.
- Device emulation (mobile, tablet, desktop).
- Resource blocking.
- Cookies and headers customization.
- Locale and timezone emulation.
Quickstart Guide for BrowserTools MCP
mainTo use BrowserTools MCP, you must run three distinct components. Note that this project is no longer active; please use a different solution.
- Chrome Extension: Install the extension from the v1.2.0 release.
- MCP Server: Install this into your IDE (e.g., Cursor, Claude Desktop) using:
npx @agentdeskai/browser-tools-mcp@latest - Node Server: Run this in a separate terminal window to act as middleware:
npx @agentdeskai/browser-tools-server@latest
After setup, open Chrome DevTools and navigate to the BrowserToolsMCP panel.
Troubleshooting:
- If it fails, quit all Chrome processes entirely.
- Restart the
browser-tools-server. - Ensure only one instance of the Chrome DevTools panel is open.
npx @agentdeskai/browser-tools-mcp@latest npx @agentdeskai/browser-tools-server@latestInstall the MCP TypeScript SDK
mainTo use the Model Context Protocol in your TypeScript project, install the official SDK via npm.
npm install @modelcontextprotocol/sdkRequest LLM Completions via Sampling
mainSampling allows an MCP server to request LLM completions through the client. This enables agentic behaviors like decision-making or data generation.
Note: This feature is not yet supported in the Claude Desktop client.
Flow:
- Server sends
sampling/createMessagerequest to the client. - Client reviews/modifies the request.
- Client samples from an LLM.
- Client returns the result to the server.
Key Parameters:
messages: Array of conversation history (roleandcontent).modelPreferences: Hints for the client (e.g.,costPriority,speedPriority,intelligencePriority).includeContext: Specifies context to include ("none","thisServer", or"allServers").systemPrompt: Optional system prompt request.
{ "method": "sampling/createMessage", "params": { "messages": [ { "role": "user", "content": { "type": "text", "text": "What files are in the current directory?" } } ], "systemPrompt": "You are a helpful file system assistant.", "includeContext": "thisServer", "maxTokens": 100 } }- Server sends
Install and run Browser Tools Server
mainThe Browser Tools Server captures and manages browser events, logs, and screenshots. It requires the Browser Tools Chrome Extension to be installed and enabled in your browser to function. By default, the server runs on port3025.Create reusable Prompt templates
mainPrompts allow servers to define reusable templates and workflows that clients can surface to users. Prompts are user-controlled and can accept dynamic arguments and include context from resources.
Prompt Structure
A prompt definition includes:
name: Unique identifier.description: Human-readable description.arguments: An optional list of objects containingname,description, andrequired(boolean).
Run Lighthouse-powered audits
mainThe server provides AI-optimized audit capabilities for Accessibility, Performance, SEO, and Best Practices. All audits implement a "smart limit" to ensure high-impact issues are prioritized for AI consumption:
- Critical issues: No limit (all issues shown)
- Serious issues: Up to 15 items per issue
- Moderate issues: Up to 10 items per issue
- Minor issues: Up to 3 items per issue
Handle MCP Resource Updates
mainMCP supports real-time updates for resources through two mechanisms:
- List changes: Servers notify clients when the available resource list changes using the
notifications/resources/list_changednotification. - Content changes: Clients can subscribe to specific resources using
resources/subscribe. The server then sendsnotifications/resources/updatedwhen the content changes. Clients can then fetch the latest content viaresources/readand eventuallyresources/unsubscribe.
- List changes: Servers notify clients when the available resource list changes using the
Install the Browser Tools MCP Server
mainYou can run the Browser Tools MCP Server using
npxor install it globally vianpm.Prerequisites:
- Node.js 14 or higher
- A running instance of the Browser Tools Server
- Chrome or Chromium browser installed (required for audit functionality)
npx @agentdeskai/browser-tools-mcpOr install globally:
npm install -g @agentdeskai/browser-tools-mcpUse stdio Transport for Local Integrations
mainThe
stdiotransport enables communication through standard input and output streams. This is the preferred method for building command-line tools, local integrations, or simple process communication via shell scripts.const server = new Server({ name: "example-server", version: "1.0.0" }, { capabilities: {} }); const transport = new StdioServerTransport(); await server.connect(transport);