网页执行层工具

exfetch是一个为LLM代理设计的浏览器感知网页执行层工具,结合了直接HTTP获取与Chrome扩展桥接技术,为AI助手提供经过认证且支持JavaScript渲染的网页访问功能。

  • by BMC-INC
  • Rust
  • 本地部署
  • 更新于
在 GitHub 查看 BMC-INC/exfetch

使用说明

去角质

LLM代理的浏览器感知web执行层。将直接HTTP获取与Chrome扩展桥相结合,为AI助手提供经过身份验证、JavaScript渲染的web访问。

建筑

                          +------------------+
                          |   Claude / LLM   |
                          +--------+---------+
                                   |
                    JSON-RPC (stdio or SSE)
                                   |
                          +--------v---------+
                          |   exfetch CLI    |
                          |  (Rust binary)   |
                          +--+-----+------+--+
                             |     |      |
               +-------------+     |      +--------------+
               |                   |                     |
       +-------v-------+  +-------v-------+  +----------v---------+
       |  HTTP Fetcher  |  | Search Engine |  | WebSocket Bridge   |
       | (reqwest+TLS)  |  | (DDG/SearXNG) |  | (tokio-tungstenite)|
       +-------+--------+  +---------------+  +----------+---------+
               |                                         |
       +-------v--------+                      +---------v---------+
       | Content Extract |                      | Chrome Extension  |
       | readability/md  |                      | (Manifest V3)     |
       +----------------+                      +-------------------+

安装

cargo install --path .

命令行用法

获取页面

exfetch fetch https://example.com
exfetch fetch https://example.com --markdown
exfetch fetch https://example.com --json
exfetch fetch https://example.com --raw
exfetch fetch https://example.com --max-length 5000

搜索网页

exfetch search "rust programming language"
exfetch search "rust programming" --results 10
exfetch search "rust programming" --fetch          # also fetch top results
exfetch search "rust programming" --json
exfetch search "query" --engine searxng --searxng-url https://searx.be

启动服务器

exfetch serve                          # WebSocket server for browser extension
exfetch serve --mcp-stdio              # MCP server over stdin/stdout
exfetch serve --mcp-sse 8080           # MCP server over SSE
exfetch serve --daemon                 # Fork to background

检查状态

exfetch status

Claude代码的MCP设置

添加到您的Claude Code MCP配置中:

{
  "mcpServers": {
    "exfetch": {
      "command": "exfetch",
      "args": ["serve", "--mcp-stdio"]
    }
  }
}

claude.ai的MCP设置

对于claude.ai,您需要一个隧道(cloudflared或ngrok)来暴露SSE端点:

# Terminal 1: start exfetch with SSE
exfetch serve --mcp-sse 8080

# Terminal 2: expose via tunnel
cloudflared tunnel --url http://localhost:8080
# or
ngrok http 8080

然后在claude.ai设置中将隧道URL配置为远程MCP服务器。

Chrome 扩展

  1. 打开 chrome://extensions/ 在Chrome浏览器中
  2. 启用“开发人员模式”
  3. 点击“加载解包”
  4. 选择 extension/chrome/ 目录
  5. 使用启动服务器 exfetch serve
  6. 扩展将通过WebSocket自动连接

配置文件

exfetch从以下位置读取配置 ~/.config/exfetch/config.toml:

[defaults]
timeout = 15
user_agent = "exfetch/0.1"
search_engine = "duckduckgo"   # or "searxng"
# searxng_url = "https://searx.be"

[policy]
blocked_domains = []
allow_cookie_read = false
max_requests_per_minute = 60

[tabs]
reuse_strategy = "exact"
open_in_background = true

CLAUDE.md集成

添加到您的项目 CLAUDE.md:

Use `exfetch <url>` to fetch web content. Use `exfetch search <query>` to search.

许可证

麻省理工学院