research-mcp
A stateless MCP server that provides web search, single page reading, and batch page reading tools, with automatic failover across multiple search and content extraction providers.
README
research-mcp
A stateless MCP facade that hides a pyramid of search/read providers behind a single streamable-http MCP endpoint and exposes just 3 clean tools with good Russian help texts. An LLM gets a simple "search → read" toolset; behind it, several providers are tried, merged, and failed over automatically.
The app does no authentication — it is published through Traefik + basicAuth
on the host. It holds no application state: the only thing persisted is a log
file under data/ (kept on a volume).
Tools
| Tool | What it does |
|---|---|
web_search(query, num_results=8, page=1, language=None) |
Search across all enabled providers, merge + dedup → ranked list (title, URL, snippet). Search only. |
read_page(url) |
One page or PDF → clean Markdown. Auto-detects type, walks the read pipeline (light → heavy) until one succeeds. |
read_pages(urls) |
Up to 20 urls concurrently → list of {url, ok, markdown|error}. |
Architecture: types + instances
Providers are plugins. We separate:
- type — an implementation class (e.g. the
searxngsearch provider), one per module insrc/providers/, registered with@register("type"). - instance — a configured copy of a type with its secrets/URL resolved from
named environment variables (multiple instances of one type are allowed,
e.g.
tavily-1/tavily-2with different keys).
Which instances exist and the order each pipeline tries them is configured in
code (src/pipeline_config.py); keys/URLs come from ENV by variable name.
- Search pipeline (
searxng → serper → exa): enabled instances run concurrently; results are merged and deduplicated by normalized URL (earlier pipeline position wins), then trimmed tonum_results. - Read pipeline (
trafilatura → jina → crawl4ai → tavily-1 → tavily-2 → firecrawl): a single probe GET classifies the url. PDFs (Content-Type /.pdf/%PDFmagic) are extracted with pypdf; for HTML, that same body is handed totrafilaturaso the hot path never GETs twice, then the remaining instances are tried in order and the first to return content>= FALLBACK_MIN_CHARSwins.
Cross-cutting: one transient retry (5xx / transport errors) with a short backoff;
402 (out of credits) / 429 (rate limited) are treated as a provider failure →
next instance (this is what makes tavily-1 → tavily-2 fail over).
An instance is enabled only if its required env var(s) are set; otherwise it
is skipped with a log line. trafilatura needs no config (always on); jina
works keyless (its key is optional). At startup the server requires at least one
search and one read instance, else it exits with a clear message.
Adding a provider
- Write
src/providers/<type>.pywith a class decorated@register("<type>")implementingSearchProvider.search(...)orReadProvider.read(...). - Import the module in
src/providers/__init__.py(so the decorator runs). - Add an
Instance("name", "<type>", api_key_env="YOUR_ENV_NAME")line insrc/pipeline_config.pyand reference itsnameinSEARCH_PIPELINE/READ_PIPELINE. Use the ENV var NAME, never a value. - Document the env var in
.env.example.
Quick start
make install # create .venv + install dev/test deps
cp .env.example .env # fill in the keys you have (shortcut: make env)
make test # run tests
make run # run the server (streamable-http on MCP_HOST:MCP_PORT, endpoint /mcp)
Configuration
All config comes from ENV / .env (see .env.example). Provider secrets/URLs
are read by name in the instance loader, not declared as Settings fields. The
non-secret knobs (all defaulted): MCP_HOST, MCP_PORT, LOG_LEVEL,
LOG_FILE, LOG_ROTATION, LOG_RETENTION, REQUEST_TIMEOUT,
FALLBACK_MIN_CHARS, READ_PAGES_CONCURRENCY, RETRIES. The read_pages
per-call url cap is a fixed 20 (hard constant, matching the tool description) —
not configurable.
Provider env vars: SEARXNG_URL, SERPER_API_KEY, EXA_API_KEY, JINA_API_KEY
(optional), CRAWL4AI_URL + CRAWL4AI_TOKEN, TAVILY_1_API_KEY,
TAVILY_2_API_KEY, FIRECRAWL_API_KEY.
Proxy
Any external instance can be routed through its own SOCKS5/HTTP proxy by
setting <INSTANCE>_PROXY — useful for clean egress past IP-based blocks (e.g.
Cloudflare in front of Exa). Supported per instance: EXA_PROXY, SERPER_PROXY,
JINA_PROXY, TAVILY_1_PROXY, TAVILY_2_PROXY, FIRECRAWL_PROXY. Internal
instances (searxng, crawl4ai, trafilatura) have no proxy.
The value is passed straight to httpx; socks5://host:port does proxy-side
DNS (the target hostname is resolved by the proxy, like curl --socks5-hostname), and socks5h:// / http://host:port are also accepted.
Unset → that instance goes direct. The pipeline keeps one pooled httpx client
per distinct proxy URL (and one direct client), selected per instance, so
proxied and direct providers run side by side. Needs the socks extra
(httpx[socks], already pinned).
Logging
Besides stderr (captured by Docker's rotation-capped json-file driver), the
server writes a persistent log file to data/research-mcp.log (default;
LOG_ROTATION=20 MB, LOG_RETENTION=14 days). It lives on the data/ volume,
so it survives container restarts and image updates. The file carries one
per-request line per tool call — search (query, which provider instances
actually ran, result count, latency) and read (url, the winning provider/tier
or pdf, ok, latency), plus a read_pages count=N ok=K summary — making it
useful for analyzing how requests distribute across provider tiers. No request
bodies or secrets are logged, only urls/queries, provider names, counts, timings.
Deployment
CI builds the image and pushes it to ghcr.io (test → build, tags latest +
sha). On prod we pull the prebuilt image via docker-compose.yml (behind
Traefik + basicAuth, watchtower auto-updates latest; the data/ volume keeps
the log file across updates) — we never build on prod.
Layout
| Path | Purpose |
|---|---|
src/providers/base.py |
Provider interfaces + SearchResult / ProviderError. |
src/providers/registry.py |
@register decorator → REGISTRY. |
src/providers/<type>.py |
One module per provider type. |
src/providers/pdf.py |
PDF detection + pypdf text extraction (used by the pipeline). |
src/pipeline_config.py |
In-code instances + pipeline order. |
src/pipeline.py |
Instance loader + search/read logic. |
src/settings.py |
Non-secret knobs (pydantic-settings). |
src/server.py |
build_server() with the 3 @mcp.tool definitions. |
main.py |
Thin entry point: build server, run streamable-http. |
tests/ |
pytest suite (network mocked with respx). |
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。