Fetchmux

io.github.krutftw由 GitHub 账号 krutftw 发布v0.1.0更新于 Oct 27, 2026

Self-hosted retrieval router for AI agents: budgets, provider routing, route receipts.

概览

AI 生成的概览

面向自建 FetchMux 网关的 MCP 客户端,让 AI 助手在成本与延迟预算内跨多个搜索提供商路由检索请求,并返回路由回执。

可以做什么
  • 通过自建网关执行网页搜索,由网关按你的策略选择可用提供商,返回规范化结果和路由回执。
  • 预览路由决策:给出候选提供商排名与原因码,不实际调用任何提供商。
  • 按请求设置成本上限与截止时间,失败时安全重试,仅在可重试错误时回退。
  • 对外只提供两个只读工具。
适用场景
当助手需要网页或学术检索,而你希望由自己托管的网关统一控制提供商选择、花费上限和延迟上限,并保留“哪个提供商执行、花了多少钱”的追踪记录时使用。适合已在本地或 Docker 中运行 FetchMux 网关的团队。
运行要求
需要一个可通过 FETCHMUX_BASE_URL 访问的 FetchMux 网关(默认本地端口 8787),以及 FETCHMUX_API_KEY 中的 Bearer 密钥。MCP 服务器本身通过 npx 在本地运行。提供商密钥如 BRAVE_API_KEY、TAVILY_API_KEY、EXA_API_KEY、FIRECRAWL_API_KEY 配置在网关上;免密钥的 Crossref 路由需设置 CROSSREF_ENABLED 与 CROSSREF_CONTACT_EMAIL。网关与 npx 包需要 Node.js。
安装前请注意
FETCHMUX_API_KEY 用于保护搜索路由;将 FETCHMUX_AUTH_DISABLED 设为 true 会绕过鉴权,仅应在可信本地环境使用。提供商密钥留在网关侧,但都是真实的付费密钥,且只有配置了各提供商的单次成本变量后美元预算才会生效。README 中包含一个提供商注册推荐链接,项目可从中获得佣金。路由事件会以 JSON 形式输出到 stdout。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Fetchmux,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

FetchMux

[npm] [License] [Node] [MCP]

One search endpoint for AI agents. Put a router in front of Brave, Tavily, Exa, Firecrawl, and Crossref. Every request carries a hard cost ceiling and deadline; every response comes back with a receipt that says which provider ran, why, and what it cost.

Your agents stop hard-coding a provider into prompts and app code. They send one request shape; the gateway picks an eligible provider under a policy you control, enforces the budget and deadline before the call, retries safely on failure, and returns normalized results plus a full trace. You keep your provider keys — they never leave your gateway.

The receipt

Nothing is a black box. Every /v1/search response carries the routing decision:

jsonc
"route": {  "selectedProvider": "brave",  "attemptedProviders": ["brave"],  "reasonCodes": ["TASK_MATCH", "WITHIN_BUDGET", "RELIABILITY_WEIGHT"],  "attempts": [    { "provider": "brave", "outcome": "success", "latencyMs": 640, "estimatedCostUsd": 0.005 }  ],  "estimatedCostUsd": 0.005,  "latencyMs": 640,  "fallbackUsed": false,  "traceId": "rt_b400e7c8"}

How it routes

  agent  ──▶  { query · task · maxCostUsd · maxLatencyMs }                             │                             ▼                      ┌──────────────┐        your keys                      │   FetchMux    │ ─────▶ Brave · Tavily · Exa                      │    policy     │        Firecrawl · Crossref                      └──────────────┘ ◀─────  (bring your own)                             │                             ▼  agent  ◀──  evidence[]  +  route receipt

A provider is eligible only when its credentials, task fit, circuit state, spend, and deadline all pass. Budgets and deadlines are eligibility rules, not best-effort hints. Fallback happens only on retryable failures.

Quick start

No provider account needed — the public Crossref route runs out of the box:

bash
git clone https://github.com/krutftw/fetchmuxcd fetchmuxnpm installnpm run build
export FETCHMUX_API_KEY="a-long-random-key"export CROSSREF_ENABLED=trueexport CROSSREF_CONTACT_EMAIL="[email protected]"npm run dev:gateway

From another shell:

bash
curl http://127.0.0.1:8787/v1/search \  -H "Authorization: Bearer a-long-random-key" \  -H "Content-Type: application/json" \  -d '{ "query": "retrieval augmented generation", "task": "scholarly", "maxLatencyMs": 8000 }'

To route real web search, set a provider key and use a web task instead:

bash
export FETCHMUX_API_KEY="a-long-random-key"export BRAVE_API_KEY="your-brave-key"export BRAVE_COST_PER_REQUEST_USD="0.005"   # from your provider plannpm run dev:gateway

New to Firecrawl? New accounts get 10% off the first month through this link (referral — FetchMux earns a small commission, no extra cost to you).

Use it from an agent

Point any MCP client (Claude, Cursor, and friends) at the published server:

json
{  "mcpServers": {    "fetchmux": {      "command": "npx",      "args": ["-y", "@fetchmux/mcp"],      "env": {        "FETCHMUX_BASE_URL": "http://127.0.0.1:8787/",        "FETCHMUX_API_KEY": "your-gateway-key"      }    }  }}

Two read-only tools: search_web and preview_search_route.

Or use the typed SDK, @fetchmux/sdk:

typescript
import { FetchMux } from "@fetchmux/sdk";
const client = new FetchMux({  baseUrl: "http://127.0.0.1:8787/",  apiKey: process.env.FETCHMUX_API_KEY,  fetch: globalThis.fetch.bind(globalThis),});
const res = await client.search({  query: "latest stable Node.js release",  task: "fresh_facts",  maxCostUsd: 0.02,});

Providers

Bring your own key for each. Set the matching *_API_KEY, plus an optional *_COST_PER_REQUEST_USD if you want dollar budgets enforced.

ProviderUseKey
Braveweb searchBRAVE_API_KEY
Tavilyweb search, researchTAVILY_API_KEY
Exaweb search, docsEXA_API_KEY
Firecrawlpage contentFIRECRAWL_API_KEY
Crossrefscholarly metadatanone (CROSSREF_ENABLED=true)

REST endpoints

MethodPathAuthBehavior
GET/healthpublicProcess health and version
GET/readypublicProvider readiness
GET/v1/providersbearerProvider configuration status
POST/v1/route/previewbearerRanked candidates, no provider call
POST/v1/searchbearerRouted retrieval and route receipt

Full contract: docs/openapi.yaml.

All configuration variables

The process does not auto-load .env in local Node development; set variables in the shell or a process manager. Docker Compose reads the ignored .env file.

VariableDefaultPurpose
FETCHMUX_API_KEYnoneProtected-route bearer key
FETCHMUX_API_KEYSnoneComma-separated keys for rotation
FETCHMUX_AUTH_DISABLEDfalseExact true bypasses auth (trusted local use only)
FETCHMUX_ALLOWED_ORIGINSnoneComma-separated browser origins; no CORS when empty
FETCHMUX_HOST127.0.0.1Bind address
FETCHMUX_PORT8787TCP port
BRAVE_API_KEY / TAVILY_API_KEY / EXA_API_KEY / FIRECRAWL_API_KEYnoneProvider credentials
CROSSREF_ENABLEDfalseExact true enables the credential-free scholarly route
CROSSREF_CONTACT_EMAILnoneMonitored contact for Crossref's polite pool
*_COST_PER_REQUEST_USDnonePer-provider cost estimates used by dollar budgets

See provider configuration before enabling maxCostUsd.

Run in Docker

bash
cp .env.example .env    # add your keys, never commit itdocker compose up --build -dcurl http://127.0.0.1:8787/health

Non-root Distroless image: Linux capabilities dropped, read-only root filesystem, provider credentials passed only at container start.

Benchmark

Validate every case and provider pairing with no network calls or credits:

bash
npm run benchmark -- --workload benchmarks/workloads/founding-v1.json --mode dry-run

Live mode needs provider keys and an explicit --confirm-live. Check each provider's terms before publishing results — see the benchmark methodology.

What it is (and isn't)

Open source, self-hosted, single-tenant, BYOK. Route events go to stdout as JSON and exclude your query text, keys, and result content by default. No database, no telemetry.

It is not a hosted service, a pooled-credit reseller, or a claim that these providers are interchangeable. Provider names are the adapters it ships with, not partnerships. A hosted version is on the roadmap — star the repo to follow.

Development

bash
npm test          # 232 testsnpm run typechecknpm run lintnpm run buildnpm run dev:gatewaynpm run dev:site

More docs: product design · local development · deployment · provider configuration · data handling · incident response

Security issues: [email protected].

License

Apache-2.0. Free to self-host, modify, and redistribute.

来源:README.md,提交 18f8b31

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分