fetchmux
Self-hosted retrieval router for AI agents: one MCP/REST endpoint that routes web search across Brave, Tavily, Exa, Firecrawl, and Crossref (BYOK) with per-request cost ceilings, deadlines, and an auditable route receipt on every response.
README
FetchMux
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:
"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:
git clone https://github.com/krutftw/fetchmux
cd fetchmux
npm install
npm run build
export FETCHMUX_API_KEY="a-long-random-key"
export CROSSREF_ENABLED=true
export CROSSREF_CONTACT_EMAIL="you@example.com"
npm run dev:gateway
From another shell:
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:
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 plan
npm 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:
{
"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:
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.
| Provider | Use | Key |
|---|---|---|
| Brave | web search | BRAVE_API_KEY |
| Tavily | web search, research | TAVILY_API_KEY |
| Exa | web search, docs | EXA_API_KEY |
| Firecrawl | page content | FIRECRAWL_API_KEY |
| Crossref | scholarly metadata | none (CROSSREF_ENABLED=true) |
REST endpoints
| Method | Path | Auth | Behavior |
|---|---|---|---|
GET |
/health |
public | Process health and version |
GET |
/ready |
public | Provider readiness |
GET |
/v1/providers |
bearer | Provider configuration status |
POST |
/v1/route/preview |
bearer | Ranked candidates, no provider call |
POST |
/v1/search |
bearer | Routed retrieval and route receipt |
Full contract: docs/openapi.yaml.
<details> <summary><b>All configuration variables</b></summary>
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.
| Variable | Default | Purpose |
|---|---|---|
FETCHMUX_API_KEY |
none | Protected-route bearer key |
FETCHMUX_API_KEYS |
none | Comma-separated keys for rotation |
FETCHMUX_AUTH_DISABLED |
false |
Exact true bypasses auth (trusted local use only) |
FETCHMUX_ALLOWED_ORIGINS |
none | Comma-separated browser origins; no CORS when empty |
FETCHMUX_HOST |
127.0.0.1 |
Bind address |
FETCHMUX_PORT |
8787 |
TCP port |
BRAVE_API_KEY / TAVILY_API_KEY / EXA_API_KEY / FIRECRAWL_API_KEY |
none | Provider credentials |
CROSSREF_ENABLED |
false |
Exact true enables the credential-free scholarly route |
CROSSREF_CONTACT_EMAIL |
none | Monitored contact for Crossref's polite pool |
*_COST_PER_REQUEST_USD |
none | Per-provider cost estimates used by dollar budgets |
See provider configuration before enabling maxCostUsd.
</details>
Run in Docker
cp .env.example .env # add your keys, never commit it
docker compose up --build -d
curl 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:
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
npm test # 232 tests
npm run typecheck
npm run lint
npm run build
npm run dev:gateway
npm run dev:site
More docs: product design · local development · deployment · provider configuration · data handling · incident response
Security issues: security@fetchmux.com.
License
Apache-2.0. Free to self-host, modify, and redistribute.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。