Logo MCP 浏览器代理

MCP 浏览器代理

Cộng đồng
imprvhub

A Model Context Protocol (MCP) integration that provides Claude Desktop with autonomous browser automation capabilities. This agent enables Claude to interact with web content, manipulate DOM elements, execute JavaScript, and perform API requests.

Nhà phát hànhimprvhub
Kho mãmcp-browser-agent
Ngôn ngữTypeScript
Bản fork
14
Sao
41
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMPL-2.0
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    MCP 浏览器代理 cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    41 sao và 14 bản fork từ kho mã được liên kết.

MCP Browser Agent

Trust Score smithery badge

Features

  • Advanced Browser Automation

    • Navigate to any URL with customizable load strategies
    • Capture full-page or element-specific screenshots
    • Perform precise DOM interactions (click, fill, select, hover)
    • Execute arbitrary JavaScript in browser context with console logs capture
  • Powerful API Client

    • Execute HTTP requests (GET, POST, PUT, PATCH, DELETE)
    • Configure request headers and body content
    • Process response data with JSON formatting
    • Error handling with detailed feedback
  • MCP Resource Management

    • Access browser console logs as resources
    • Retrieve screenshots through MCP resource interface
    • Persistent session with headful browser instance
  • AI Agent Capabilities

    • Chain multiple browser operations for complex tasks
    • Follow multi-step instructions with intelligent error recovery
    • Technical task automation through natural language instructions

Demo

Click on any timestamp to jump to that section of the video

00:00 - Google Search for MCP
Navigation to Google homepage and search for "Model Context Protocol". Demonstration of Claude Desktop using the MCP integration to perform a basic web search and process the results.

00:33 - Screenshot Capture
Taking a screenshot of the search results with a custom filename and showcasing it in Finder. Shows how Claude can capture and save visual content from web pages during browser automation.

01:00 - Wikipedia Search
Navigation to Wikipedia.org and search for "Model Context Protocol". Illustrates Claude's ability to interact with different websites and their search functionality through the MCP integration.

01:38 - Dropdown Menu Interaction I
Navigation to a test website (the-internet.herokuapp.com/dropdown) and selection of "Option 1" from a dropdown menu. Demonstrates Claude's capability to interact with form elements and make selections.

01:56 - Dropdown Menu Interaction II
Changing the selection to "Option 2" from the same dropdown menu. Shows Claude's ability to manipulate the same form element multiple times and make different selections.

02:09 - Login Form Completion
Navigation to a login page (the-internet.herokuapp.com/login) and filling in the username field with "tomsmith" and password field with "SuperSecretPassword!". Demonstrates form filling automation.

02:28 - Login Submission
Submitting the login credentials and completing the authentication process. Shows Claude's ability to trigger form submissions and navigate through multi-step processes.

02:36 - API Request Execution
Performing a GET request to JSONPlaceholder API endpoint. Demonstrates Claude's capability to make direct API calls and process the returned data through the MCP integration.

Requirements

  • Node.js 16 or higher
  • Claude Desktop
  • Playwright dependencies

Browser Support

bash
npm init playwright@latest

This package includes Playwright and the necessary dependencies for running browser automation. When you run npm install, the required Playwright dependencies will be installed. The package supports the following browsers:

  • Chrome (default)
  • Firefox
  • Microsoft Edge
  • WebKit (Safari engine)

When you first use a browser type, Playwright will automatically install the corresponding browser drivers as needed. You can also install them manually with the following commands:

npx playwright install chrome
npx playwright install firefox
npx playwright install webkit
npx playwright install msedge

Note about Safari: Playwright doesn't provide direct support for Safari browser. Instead, it uses WebKit, which is the browser engine that powers Safari.

Note about Edge: When selecting Edge as the browser type, the agent will actually launch Microsoft Edge (not Chromium). Technically, in Playwright, Edge is launched using the Chromium browser instance with the 'msedge' channel parameter because Microsoft Edge is based on Chromium.

Installation

Installing Manually

  1. Clone or download this repository:
git clone https://github.com/imprvhub/mcp-browser-agent
cd mcp-browser-agent
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Running the MCP Server

There are two ways to run the MCP server:

Option 1: Running manually

  1. Open a terminal or command prompt
  2. Navigate to the project directory
  3. Run the server directly:
node dist/index.js

Keep this terminal window open while using Claude Desktop. The server will run until you close the terminal.

Option 2: Auto-starting with Claude Desktop (recommended for regular use)

The Claude Desktop can automatically start the MCP server when needed. To set this up:

Configuration

The Claude Desktop configuration file is located at:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Edit this file to add the Browser Agent MCP configuration. If the file doesn't exist, create it:

json
{
  "mcpServers": {
    "browserAgent": {
      "command": "node",
      "args": ["ABSOLUTE_PATH_TO_DIRECTORY/mcp-browser-agent/dist/index.js",
      "--browser",
      "chrome"
    ]
    }
  }
}

Important: Replace ABSOLUTE_PATH_TO_DIRECTORY with the complete absolute path where you installed the MCP

  • macOS/Linux example: /Users/username/mcp-browser-agent
  • Windows example: C:\\Users\\username\\mcp-browser-agent

If you already have other MCPs configured, simply add the "browserAgent" section inside the "mcpServers" object. Here's an example of a configuration with multiple MCPs:

json
{
  "mcpServers": {
    "otherMcp1": {
      "command": "...",
      "args": ["..."]
    },
    "otherMcp2": {
      "command": "...",
      "args": ["..."]
    },
    "browserAgent": {
      "command": "node",
      "args": [
        "ABSOLUTE_PATH_TO_DIRECTORY/mcp-browser-agent/dist/index.js",
      "--browser",
      "chrome"
    ]
    }
  }
}

Browser Selection

The MCP Browser Agent supports multiple browser types. By default, it uses Chrome, but you can specify a different browser in several ways:

Option 1: Configuration File

Create or edit the file .mcp_browser_agent_config.json in your home directory:

json
{
  "browserType": "chrome"
}

Supported values for browserType are:

  • chrome - Uses installed Chrome (default)
  • firefox - Uses Firefox 'Nightly' browser
  • webkit - Uses WebKit engine (Note: This is not Safari itself but the WebKit rendering engine that powers Safari)
  • edge - Uses Microsoft Edge

Note about Safari: Playwright doesn't provide direct support for Safari browser. Instead, it uses WebKit, which is the browser engine that powers Safari. The WebKit implementation in Playwright provides similar functionality but is not identical to the Safari browser experience.

Option 2: Command Line Argument

When starting the MCP server manually, you can specify the browser type:

node dist/index.js --browser firefox

Option 3: Environment Variable

Set the MCP_BROWSER_TYPE environment variable:

MCP_BROWSER_TYPE=firefox node dist/index.js

Option 4: Claude Desktop Configuration

When configuring the MCP in Claude Desktop's claude_desktop_config.json, you can specify the browser type:

json
{
  "mcpServers": {
    "browserAgent": {
      "command": "node",
      "args": [
        "ABSOLUTE_PATH_TO_DIRECTORY/mcp-browser-agent/dist/index.js",
        "--browser",
        "chrome"
      ]
    }
  }
}

Technical Implementation

MCP Browser Agent is built on the Model Context Protocol, enabling Claude to interact with a headful browser through Playwright. The implementation consists of four main components:

  1. Server (index.ts)

    • Initializes the MCP server with Model Context Protocol standard protocol
    • Configures server capabilities for tools and resources
    • Establishes communication with Claude through the stdio transport
  2. Tools Registry (tools.ts)

    • Defines browser and API tool schemas
    • Specifies parameters, validation rules, and descriptions
    • Registers tools with the MCP server for Claude's discovery
  3. Request Handlers (handlers.ts)

    • Manages MCP protocol requests for tools and resources
    • Exposes browser logs and screenshots as queryable resources
    • Routes tool execution requests to the appropriate handlers
  4. Executor (executor.ts)

    • Manages browser and API client lifecycle
    • Implements browser automation functions using Playwright
    • Handles API requests with proper error handling and response parsing
    • Maintains stateful browser session between commands

Agent Capabilities

Unlike basic integrations, MCP Browser Agent functions as a true AI agent by:

  • Maintaining persistent browser state across multiple commands
  • Capturing detailed console logs for debugging
  • Storing screenshots for reference and review
  • Managing complex interaction sequences
  • Providing detailed error information for recovery
  • Supporting chained operations for complex workflows

Available Tools

Browser Tools

Tool NameDescriptionParameters
browser_navigateNavigate to a URLurl (required), timeout, waitUntil
browser_screenshotCapture screenshotname (required), selector, fullPage, mask, savePath
browser_clickClick elementselector (required)
browser_fillFill form inputselector (required), value (required)
browser_selectSelect dropdown optionselector (required), value (required)
browser_hoverHover over elementselector (required)
browser_evaluateExecute JavaScriptscript (required)

API Tools

Tool NameDescriptionParameters
api_getGET requesturl (required), headers
api_postPOST requesturl (required), data (required), headers
api_putPUT requesturl (required), data (required), headers
api_patchPATCH requesturl (required), data (required), headers
api_deleteDELETE requesturl (required), headers

Resource Access

The MCP Browser Agent exposes the following resources:

  • browser://logs - Access browser console logs
  • screenshot://[name] - Access screenshots by name

Example Usage

Here are some realistic examples of how to use the MCP Browser Agent with Claude:

Basic Browser Navigation

Navigate to the Google homepage at https://www.google.com
Take a screenshot of the current page and name it "google-homepage"
Type "weather forecast" in the search box

Simple Interactions

Navigate to https://www.wikipedia.org and search for "Model Context Protocol"
Go to https://the-internet.herokuapp.com/dropdown and select the option "Option 1" from the dropdown

Basic Form Filling

Navigate to https://the-internet.herokuapp.com/login and fill in the username field with "tomsmith" and the password field with "SuperSecretPassword!"
Go to https://the-internet.herokuapp.com/login, fill in the username and password fields, then click the login button

Simple JavaScript Execution

Go to https://example.com and execute a JavaScript script to return the page title
Navigate to https://www.google.com and execute a JavaScript script to count the number of links on the page

Basic API Requests

Perform a GET request to https://jsonplaceholder.typicode.com/todos/1
Make a POST request to https://jsonplaceholder.typicode.com/posts with appropriate JSON data

These examples represent the actual capabilities of the MCP Browser Agent and are more realistic about what it can accomplish in its current state.

Troubleshooting

"Server disconnected" error

If you see the error "MCP Browser Agent: Server disconnected" in Claude Desktop:

  1. Verify the server is running:

    • Open a terminal and manually run node dist/index.js from the project directory
    • If the server starts successfully, use Claude while keeping this terminal open
  2. Check your configuration:

    • Ensure the absolute path in claude_desktop_config.json is correct for your system
    • Double-check that you've used double backslashes (\\) for Windows paths
    • Verify you're using the complete path from the root of your filesystem

Browser not appearing

If the browser doesn't launch or you don't see it:

  1. Check if the specified browser is installed

    • Verify that you have the browser (Chrome, Firefox, Edge, or Safari/WebKit) installed on your system
    • The browser drivers are handled automatically by Playwright
  2. Restart the server and Claude Desktop

    • Kill any existing node processes that might be running the server
    • Restart Claude Desktop to establish a fresh connection

Browser process not closing properly

There are known issues with Chromium and Chrome browsers where the process sometimes doesn't terminate properly after use. If you experience this issue:

  1. Manually close the browser process:

    • Windows: Press Ctrl+Shift+Esc to open Task Manager, find the Chrome/Chromium process and end it
    • macOS: Open Activity Monitor (Applications > Utilities > Activity Monitor), find the Chrome/Chromium process and click the X to terminate it
    • Linux: Run ps aux | grep chrome or ps aux | grep chromium to find the process, then kill <PID> to terminate it
  2. Note about browser compatibility:

    • This issue has been observed primarily with Chromium and Chrome
    • Firefox and Playwright's built-in browser don't typically experience this problem

[!CAUTION] This MCP integration is built on Playwright, which has known issues and bugs that may affect its operation. Please report any issues you encounter with the browser automation to Playwright's GitHub issues. The Playwright team is continuously working to address these issues, but this agent provides a foundation for browser automation capabilities with Claude Desktop despite these limitations.

Development

Project Structure

  • src/index.ts: Main entry point and MCP server initialization
  • src/tools.ts: Tool schemas and registration
  • src/handlers.ts: MCP request handlers for tools and resources
  • src/executor.ts: Tool implementation logic using Playwright

Building

npm run build

Watching for Changes

npm run watch

Testing

The project includes tests to verify core functionality and browser handling.

npm test               # Run tests
npm run test:watch     # Watch mode
npm run test:coverage  # Coverage report

Tests verify configuration integrity, browser automation features, error handling, and process cleanup. The test suite focuses particularly on ensuring proper handling of browser processes due to known issues with Chrome/Chromium termination.

Security Considerations

[!IMPORTANT] This MCP integration provides Claude with autonomous browser control capabilities. Please review our Security Policy for important information about prohibited uses, security implications, and best practices.

The MCP Browser Agent is designed for legitimate automation tasks but could potentially be misused. Users are responsible for ensuring their use complies with all applicable laws, terms of service, and ethical guidelines. See our detailed Security Policy for more information.

Contributing

Contributions to the MCP Browser Agent are welcome! Here are some areas where you can help:

  • Adding new browser automation capabilities
  • Improving error handling and recovery
  • Enhancing screenshot and resource management
  • Creating useful workflows and examples
  • Optimizing performance for complex operations

License

This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.

Related Links

Cài đặt

TypingMind
{
  "mcpServers": {
    "mcp-browser-agent": {
      "command": "node",
      "args": [
        "ABSOLUTE_PATH_TO_DIRECTORY/mcp-browser-agent/dist/index.js",
        "--browser",
        "chrome"
      ]
    }
  }
}

Dùng MCP MCP 浏览器代理 với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối MCP 浏览器代理, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm MCP 浏览器代理 làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của MCP 浏览器代理.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "mcp-browser-agent": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-browser-agent"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của MCP 浏览器代理, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của MCP 浏览器代理.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng MCP 浏览器代理 giúp tôi làm việc này không?
MCP 浏览器代理
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng MCP 浏览器代理.

Câu hỏi thường gặp

Máy chủ MCP MCP 浏览器代理 dùng để làm gì?

MCP 浏览器代理 là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP MCP 浏览器代理 với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng MCP 浏览器代理 với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP MCP 浏览器代理 với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối MCP 浏览器代理, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP MCP 浏览器代理 với TypingMind?

MCP 浏览器代理 hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP MCP 浏览器代理 cung cấp những công cụ nào trong TypingMind?

MCP 浏览器代理 cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP MCP 浏览器代理 không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu MCP 浏览器代理 yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇