浏览器控制服务器

camofox-browser-mcp是一个用于控制本地camofox-browser实例的MCP服务器,提供标签生命周期管理、导航、交互、截图等功能,适用于LLM代理的浏览器自动化工作流。

  • by Microck
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Microck/camofox-browser-mcp

使用说明

camofox-browser-mcp

MCP server for controlling a local camofox-browser instance.


快速安装

将此内容粘贴到llm代理会话中:

Install and configure camofox-browser-mcp by following the instructions here:
https://raw.githubusercontent.com/Microck/camofox-browser-mcp/refs/heads/main/INSTALL.md

npm(推荐)

npm install -g camofox-browser-mcp

用于控制本地的MCP服务器 Jo-inc/camofox-浏览器 例子

此服务器向LLM代理公开了完整实用的camofox浏览器工作流程: 标签生命周期、导航、交互、快照、屏幕截图、链接、统计数据, cookie导入、会话清理、YouTube转录提取和高级 复合助手程序(navigate_and_snapshot, scroll_and_snapshot, fill_form, type_and_submit, batch_click, web_search).

先决条件

  1. Node.js 22+(npm包需要)
  2. 可选:Bun(建议用于当地开发): https://bun.sh/docs/installation
  3. 跑步 camofox-browser 服务器(默认 http://127.0.0.1:9377)
  4. 可选,取决于使用的工具:
    • CAMOFOX_API_KEY 用于cookie导入
    • CAMOFOX_ADMIN_KEY 用于浏览器停止端点

安装

当地开发检查

git clone https://github.com/Microck/camofox-browser-mcp.git
cd camofox-browser-mcp
bun install
bun run typecheck
bun run build

npm 包

npm install -g camofox-browser-mcp

# optional smoke-run (most users just configure their MCP client)
camofox-browser-mcp

配置

在MCP客户端配置中设置这些环境变量。

变量 必填 默认 用途
CAMOFOX_BASE_URL 是的 http://127.0.0.1:9377 运行camofox浏览器服务器的基本URL
CAMOFOX_URL alias 未设置 的兼容性别名 CAMOFOX_BASE_URL
CAMOFOX_TIMEOUT_MS 没有 30000 camofox调用的HTTP超时
CAMOFOX_TIMEOUT alias 未设置 的兼容性别名 CAMOFOX_TIMEOUT_MS
CAMOFOX_DEFAULT_USER_ID 没有 default-user 默认值 userId 当省略时
CAMOFOX_DEFAULT_SESSION_KEY 没有 default-session 默认值 sessionKey 当省略时
CAMOFOX_API_KEY for camofox_import_cookies 未设置 承载密钥 /sessions/:userId/cookies
CAMOFOX_ADMIN_KEY for camofox_stop_browser unset 管理员密钥发送为 x-admin-key 为了 /stop
CAMOFOX_AUTOSTART_SERVER 没有 true 当baseUrl为localhost且无法访问服务器时,尝试生成 camofox-browser 自动
CAMOFOX_AUTOSTART_COMMAND 没有 camofox-browser 用于生成camofox浏览器HTTP服务器的命令
CAMOFOX_AUTOSTART_TIMEOUT_MS 没有 15000 等待生成的服务器应答的最长时间 /health

MCP配置示例(本地构建)

{
  "mcpServers": {
    "camofox-browser-mcp": {
      "command": "bun",
      "args": ["/absolute/path/to/camofox-browser-mcp/dist/index.js"],
      "env": {
        "MCP_TRANSPORT_TYPE": "stdio",
        "MCP_LOG_LEVEL": "info",
        "CAMOFOX_BASE_URL": "http://127.0.0.1:9377",
        "CAMOFOX_DEFAULT_USER_ID": "default-user",
        "CAMOFOX_DEFAULT_SESSION_KEY": "default-session",
        "CAMOFOX_API_KEY": "",
        "CAMOFOX_ADMIN_KEY": ""
      }
    }
  }
}

工具覆盖范围

MCP工具集映射到 camofox-browser 端点,包括兼容性 常用别名 camofox-mcp 提示。

服务器和会话工具

MCP工具 端点 注释
camofox_health GET /health 运行时和浏览器状态
server_status 别名 camofox_health 兼容性别名
camofox_start_browser POST /start 启动浏览器引擎
camofox_stop_browser POST /stop 需要管理员密钥
camofox_close_session DELETE /sessions/:userId 关闭用户的所有选项卡/上下文
camofox_import_cookies POST /sessions/:userId/cookies 需要API密钥

选项卡生命周期工具

MCP工具 端点 注释
camofox_list_tabs GET /tabs 按用户列出打开的选项卡
list_tabs 别名 camofox_list_tabs 兼容性别名
camofox_create_tab POST /tabs 使用可选URL创建选项卡
create_tab 别名 camofox_create_tab 兼容性别名
camofox_close_tab DELETE /tabs/:tabId 关闭一个选项卡
close_tab 别名 camofox_close_tab 兼容性别名
camofox_close_tab_group DELETE /tabs/group/:listItemId 关闭组中的所有选项卡
camofox_get_stats GET /tabs/:tabId/stats 使用统计数据和访问的URL

导航和交互工具

MCP工具 端点 注释
camofox_navigate_tab POST /tabs/:tabId/navigate URL或宏导航
navigate 别名 camofox_navigate_tab 兼容性别名
navigate_and_snapshot composite 导航、等待,然后快照
camofox_wait POST /tabs/:tabId/wait 等待页面准备就绪
camofox_wait_for_text POST /act (kind=wait) 等待文本出现
camofox_get_snapshot GET /tabs/:tabId/snapshot 基于引用的可访问性快照
snapshot 别名 camofox_get_snapshot 兼容性别名
scroll_and_snapshot composite 滚动,然后快照
camofox_click POST /tabs/:tabId/click 按参照或选择器单击
batch_click composite 按顺序执行多次单击
camofox_type POST /tabs/:tabId/type 按引用/选择器键入文本
type_text 别名 camofox_type 兼容性别名
type_and_submit composite 键入,然后按submit键
fill_form 复合 填写多个字段+可选提交点击
camofox_hover POST /act (kind=hover) 通过ref或选择器悬停
camofox_press POST /tabs/:tabId/press 键盘按键
camofox_scroll POST /tabs/:tabId/scroll 垂直滚动
camofox_scroll_element POST /act (kind=scrollIntoView) 将引用的元素滚动到视图中
camofox_back POST /tabs/:tabId/back 历史回顾
go_back 别名 camofox_back 兼容性别名
camofox_forward POST /tabs/:tabId/forward 历史前进
go_forward 别名 camofox_forward 兼容性别名
camofox_refresh POST /tabs/:tabId/refresh 页面重新加载
refresh 别名 camofox_refresh 兼容性别名
camofox_get_links GET /tabs/:tabId/links 提取页面链接
camofox_screenshot GET /tabs/:tabId/screenshot 返回base64 PNG
web_search 宏包装器 navigate 多引擎搜索助手

内容提取工具

MCP工具 端点 注释
camofox_youtube_transcript POST /youtube/transcript 提取YouTube字幕

支持的web_search引擎

web_search 地图 engine 后端宏的值:

  • google, youtube, amazon, reddit, wikipedia, twitter, yelp
  • spotify, netflix, linkedin, instagram, tiktok, twitch

兼容性说明

  • list_profiles, save_profile, load_profile,以及 delete_profile 不是 尚未暴露,因为电流 jo-inc/camofox-browser API不提供 cookie导出/配置文件端点。

典型工作流程

  1. camofox_start_browser
  2. camofox_create_tab (或 camofox_list_tabs +再利用)
  3. camofox_navigate_tab
  4. camofox_get_snapshot
  5. 与裁判互动: camofox_click, camofox_type, camofox_press, camofox_scroll
  6. 重新运行 camofox_get_snapshot 主要页面更改后
  7. 清理 camofox_close_tab 或 camofox_close_session

宏观支持

camofox_navigate_tab 通过 macro 和 query 通过camofox浏览器。 上游宏包括:

  • @google_search
  • @youtube_search
  • @amazon_search
  • @reddit_search
  • @reddit_subreddit
  • @wikipedia_search
  • @twitter_search
  • @yelp_search
  • @spotify_search
  • @netflix_search
  • @linkedin_search
  • @instagram_search
  • @tiktok_search
  • @twitch_search

故障排除

  • camofox_health 失败:检查 CAMOFOX_BASE_URL 并确认后端正在运行。
  • camofox_import_cookies 403:设置 CAMOFOX_API_KEY 在后端和MCP环境中。
  • camofox_stop_browser 403:设置 CAMOFOX_ADMIN_KEY 在后端和MCP环境中。
  • 导航后缺少参考文献:调用 camofox_get_snapshot 再一次。

许可证

麻省理工学院