web-search-mcp

web-search-mcp

MCP server that provides web search via LLM API gateways with server-side search, returning cited answers and multi-provider fallback.

Category
Visit Server

README

web-search-mcp

对外提供 HTTP 的 web_search 服务:把搜索请求转发给支持服务端搜索的 LLM API 网关 (如 fengwind 的 -search 后缀模型),返回带来源引用的答案。多供应商自动兜底。

零依赖 Node.js(18+,自带 fetch),Docker 镜像无需 npm install,跨平台 (amd64 / arm64)。

为什么有这个东西

参照 fengwind 网关实测结论:

  • 普通模型不支持服务端搜索;-search 后缀模型(如 deepseek-v4-flash-search)可用, chat 与 responses 两种格式均返回实时结果 + [n](url) 来源引用。
  • 中文请求体必须 ASCII 转义(\uXXXX)发送,直接发中文会随机乱码或 HTTP 000 断连 (本服务已对所有供应商统一处理,见 src/ascii.js)。
  • 同一家网关可能波动,多供应商按优先级兜底更稳。

快速开始(Docker)

cp .env.example .env    # 填入你的 key / 网关
docker compose up -d --build
curl http://localhost:3000/health

配置(JSON 环境变量)

环境变量 说明
WEBSEARCH_CONFIG JSON 对象:{ "port", "timeoutMs", "providers": [...] }
WEBSEARCH_PROVIDERS JSON 数组,与 CONFIG 的 providers 合并
WEBSEARCH_TIMEOUT_MS 可选,单次请求超时(毫秒),默认 90000
PORT 可选,监听端口,默认 3000

单个 provider:

{
  "name": "fengwind",
  "baseURL": "https://api.fengwind.com",
  "apiKey": "sk-...",
  "model": ["deepseek-v4-flash-search", "deepseek-v4-pro-search"],
  "format": "chat",
  "timeoutMs": 120000,
  "priority": 0
}
字段 必填 说明
name ✅ 标识,/search 可用它定向
baseURL ✅ API 网关地址(兼容别名 gateway)
apiKey ✅ 密钥
model ✅ 模型名,字符串或数组(同网关多模型依次尝试)
format chat(默认,/v1/chat/completions)或 responses(/v1/responses + tools:[{type:"web_search"}])
priority 数字越小越优先;缺省按数组顺序

配置项非法不会导致启动失败:坏条目被跳过并打印告警,可通过 /health 的 providerCount 核对。全部为空时 /search 返回 503。

HTTP API

POST /mcp(MCP Streamable HTTP 端点)

符合 MCP 协议(JSON-RPC 2.0,2025-03-26),供 Reasonix / Claude Desktop 等 MCP 客户端直接接入:

方法 说明
initialize 握手,返回 Mcp-Session-Id
tools/list 暴露 web_search 工具(query 必填,provider 可选)
tools/call 执行搜索,返回答案文本 + 来源引用列表

Reasonix 配置(config.toml 或 .mcp.json):

[[plugins]]
name = "web-search"
type = "http"
url  = "https://box6-cu.15546991.xyz:14443/web_search/mcp"
# call_timeout_seconds = 180   # 搜索可能耗时较长,建议放宽

本实现只支持非流式 POST 响应(GET /mcp 返回 405)。

POST /search

curl -s http://localhost:3000/search \
  -H 'Content-Type: application/json' \
  -d '{"query":"今天有什么重大新闻?"}'
{
  "ok": true,
  "query": "今天有什么重大新闻?",
  "answer": "……实时内容(带 [1](url) 引用)……",
  "sources": ["https://news.cn/..."],
  "provider": "fengwind",
  "model": "deepseek-v4-flash-search",
  "format": "chat",
  "latencyMs": 8421
}

可选字段 provider:指定只用某一家({"query":"...","provider":"fengwind"}),用于单独验证。

全部供应商失败时返回 502 与 errors 列表(每家失败原因),方便排查。

⚠️ Windows 下 curl 命令行直接写中文会按本地代码页(GBK)编码,导致请求体损坏 (实测会变成乱码)。请用 UTF-8 文件发送:curl -d @request.json,或使用 Node/Python 等客户端(它们默认 UTF-8)。

GET /health

运行状态、供应商列表、超时配置。Docker HEALTHCHECK 使用此端点。

GET /providers

已配置供应商(key 脱敏为 sk-81b7...e785)。

本地运行(不用 Docker)

WEBSEARCH_CONFIG='{"providers":[...]}' node src/server.js
npm test   # 冒烟测试:假网关验证双格式 / ASCII 转义 / 兜底

目录结构

src/ascii.js     中文 → \uXXXX ASCII 转义(fengwind 实测坑)
src/providers.js JSON 环境变量解析、校验、排序、脱敏
src/search.js    双格式调用、引用提取、多供应商兜底
src/server.js    HTTP 服务与入口
test/smoke.mjs   冒烟测试(本地假网关,不发真实请求)

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured