Browser MCP Bridge

Browser MCP Bridge

Bridges browser content, developer tools data, and web page interactions with Claude through MCP. Enables page inspection, DOM analysis, JavaScript execution, console monitoring, network activity tracking, and screenshot capture across multiple browser tabs.

Category
访问服务器

README

Browser MCP Bridge

A comprehensive browser extension and MCP server solution that bridges browser content, developer tools data, and web page interactions with Claude Code through the Model Context Protocol (MCP).

Overview

This project consists of two main components:

  1. Browser Extension - Captures browser content, DOM data, console messages, network activity, and developer tools information
  2. MCP Server - Exposes browser data to Claude Code through standardized MCP tools and resources

Features

Browser Extension

  • Page Content Extraction - Full HTML, text content, metadata, and page structure
  • DOM Inspection - Complete DOM tree snapshots with computed styles
  • Console Monitoring - Real-time console logs, errors, and warnings
  • Network Activity - HTTP requests, responses, and performance metrics
  • Developer Tools Integration - Custom DevTools panel for advanced inspection
  • JavaScript Execution - Execute arbitrary JavaScript in page context
  • Screenshot Capture - Visual snapshots of browser tabs
  • Accessibility Data - Accessibility tree and ARIA attributes
  • Performance Metrics - Load times, resource usage, and Core Web Vitals

MCP Server

  • 11 Specialized Tools - Comprehensive browser automation and inspection tools
  • Dynamic Resources - Real-time access to page content, DOM, and console data
  • WebSocket Communication - Real-time bidirectional communication with browser
  • Multi-tab Support - Manage and inspect multiple browser tabs simultaneously

Installation

Prerequisites

  • Node.js 18.0.0 or higher
  • Chrome, Edge, or Chromium-based browser
  • Claude Code CLI

1. Install the MCP Server

# Clone or navigate to the project directory
cd /path/to/browser-mcp

# Install server dependencies
cd server
npm install

# Make the server executable
chmod +x index.js

2. Install the Browser Extension

Chrome/Chromium/Edge Installation

  1. Open Extension Management

    • Navigate to chrome://extensions/ (Chrome)
    • Or edge://extensions/ (Edge)
  2. Enable Developer Mode

    • Toggle "Developer mode" in the top-right corner
  3. Load the Extension

    • Click "Load unpacked"
    • Select the /path/to/browser-mcp/extension directory
    • The extension should appear in your extensions list
  4. Verify Installation

    • Look for the "Browser MCP Bridge" extension icon in your toolbar
    • The extension should show as "Enabled"

Alternative: Create Extension Package

# Navigate to extension directory
cd extension

# Create a zip package for distribution
zip -r browser-mcp-extension.zip . -x "*.DS_Store" "node_modules/*"

3. Configure Claude Code

Add the MCP server to your Claude Code configuration:

{
  "mcpServers": {
    "browser-mcp": {
      "command": "node",
      "args": ["/path/to/browser-mcp/server/index.js"],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

macOS/Linux: Edit ~/.config/claude-desktop/claude_desktop_config.json

Windows: Edit %APPDATA%/Claude/claude_desktop_config.json

Usage

1. Start the MCP Server

The server starts automatically when Claude Code launches, or manually:

cd server
npm start

The server will:

  • Listen on port 3000 for WebSocket connections
  • Provide health check endpoint at http://localhost:3000/health
  • Connect to Claude Code via stdio

2. Connect Browser Extension

  1. Open the Extension Popup

    • Click the Browser MCP Bridge icon in your toolbar
  2. Configure Connection

    • Server URL should default to ws://localhost:3000/mcp
    • Click "Connect to Server"
    • Status should change to "Connected"
  3. Verify Connection

    • Green status indicator shows successful connection
    • Extension will automatically reconnect if disconnected

3. Use Claude Code Tools

Once connected, Claude Code has access to these tools:

Page Inspection Tools

# Get complete page content and metadata
get_page_content

# Get structured DOM snapshot
get_dom_snapshot

# Execute JavaScript in page context
execute_javascript --code "document.title"

# Capture screenshot
capture_screenshot

Developer Tools

# Get console messages
get_console_messages

# Get network requests
get_network_requests

# Get performance metrics
get_performance_metrics

# Get accessibility tree
get_accessibility_tree

Browser Management

# List all open tabs
get_browser_tabs

# Attach debugger for advanced inspection
attach_debugger --tabId 123

# Detach debugger
detach_debugger --tabId 123

4. DevTools Panel

  1. Open Chrome DevTools

    • Right-click on any page → "Inspect"
    • Or press F12
  2. Find MCP Bridge Panel

    • Look for "MCP Bridge" tab alongside Console, Network, etc.
    • Click to open the custom panel
  3. Use Panel Features

    • Quick capture buttons for different data types
    • Real-time connection status
    • Message logging and debugging
    • Visual data display

Example Workflows

Web Development Debugging

  1. Inspect Page Issues

    # In Claude Code
    "Analyze this page for accessibility issues"
    # Uses get_accessibility_tree and get_page_content
    
  2. Performance Analysis

    "Check this page's performance metrics and suggest optimizations"
    # Uses get_performance_metrics and get_network_requests
    
  3. Console Error Analysis

    "Review the console errors and help me fix them"
    # Uses get_console_messages
    

Automated Testing Support

  1. Form Testing

    execute_javascript --code "
      const form = document.querySelector('form');
      const inputs = form.querySelectorAll('input');
      return Array.from(inputs).map(i => ({name: i.name, type: i.type}));
    "
    
  2. Visual Regression

    capture_screenshot
    # Compare with baseline screenshots
    

Content Analysis

  1. SEO Analysis

    get_page_content --includeMetadata true
    # Analyze meta tags, headings, content structure
    
  2. Content Extraction

    execute_javascript --code "
      return Array.from(document.querySelectorAll('article')).map(a => a.innerText);
    "
    

Configuration

Extension Settings

The extension popup allows you to:

  • Change WebSocket server URL
  • View connection statistics
  • Manually trigger data capture
  • Access DevTools panel

Server Configuration

Environment variables:

# WebSocket port (default: 3000)
PORT=3000

# Enable debug logging
DEBUG=true

# Maximum message size (bytes)
MAX_MESSAGE_SIZE=10485760

Security Considerations

  • Local Connection Only - Server only accepts connections from localhost
  • Same-Origin Policy - Extension respects browser security policies
  • No Password Storage - No sensitive data is stored or transmitted
  • Minimal Permissions - Extension requests only necessary permissions

Troubleshooting

Extension Issues

Extension not loading:

# Check browser console for errors
# Verify all files are present in extension directory
# Ensure manifest.json is valid

Connection failures:

# Verify MCP server is running on port 3000
# Check WebSocket URL in extension popup
# Look for firewall blocking localhost:3000

Server Issues

Server won't start:

# Check Node.js version (18.0.0+)
npm list  # Verify dependencies installed
node --version

MCP connection fails:

# Verify Claude Code configuration
# Check server logs for errors
# Ensure stdio communication is working

Common Fixes

  1. Restart Everything

    # Stop Claude Code
    # Kill server process
    # Disable/re-enable extension
    # Restart browser
    # Start server and Claude Code
    
  2. Clear Extension Storage

    # In Chrome: chrome://extensions/
    # Find extension → Details → Extension options
    # Clear stored data
    
  3. Reset Server Connection

    cd server
    npm run dev  # Use with --watch for debugging
    

Development

Extension Development

cd extension

# Watch for changes (if using build tools)
npm run dev

# Test in browser
# Make changes and reload extension

Server Development

cd server

# Development mode with auto-restart
npm run dev

# Debug mode with verbose logging
DEBUG=* npm start

Adding New Tools

  1. Add tool definition to server ListToolsRequestSchema handler
  2. Implement tool logic in server CallToolRequestSchema handler
  3. Add browser-side handler in extension background.js
  4. Test with Claude Code

API Reference

MCP Tools

Tool Description Parameters
get_page_content Extract page HTML, text, metadata tabId?, includeMetadata?
get_dom_snapshot Get structured DOM tree tabId?, maxDepth?, includeStyles?
execute_javascript Run JS in page context tabId?, code
get_console_messages Retrieve console logs tabId?, types?, limit?
get_network_requests Get network activity tabId?, limit?
capture_screenshot Take visual snapshot tabId?, format?, quality?
get_performance_metrics Performance data tabId?
get_accessibility_tree A11y tree structure tabId?
get_browser_tabs List all tabs None
attach_debugger Enable advanced inspection tabId
detach_debugger Disable debugger tabId

WebSocket Messages

The extension communicates with the server using structured WebSocket messages:

// Page content data
{
  type: "browser-data",
  source: "content-script",
  tabId: 123,
  url: "https://example.com",
  data: { /* page content */ }
}

// Tool responses
{
  type: "response",
  action: "getPageContent",
  tabId: 123,
  data: { /* response data */ }
}

// Error messages
{
  type: "error",
  action: "getPageContent",
  tabId: 123,
  error: "Error message"
}

License

MIT License - See LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create feature branch
  3. Make changes with tests
  4. Submit pull request

Support

For issues and questions:

  • Check troubleshooting section above
  • Review browser console and server logs
  • Create GitHub issue with detailed information

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选