WebSearch-MCP
WebSearch-MCP
一个模型上下文协议 (MCP) 服务器实现,通过标准输入输出 (stdio) 传输提供网页搜索功能。该服务器集成了 WebSearch Crawler API 来检索搜索结果。
目录
Related MCP server: MCP Server for Google Search
关于
WebSearch-MCP 是一个模型上下文协议 (MCP) 服务器,为支持 MCP 的 AI 助手提供网页搜索功能。它允许像 Claude 这样的 AI 模型实时搜索网页,检索任何主题的最新信息。
该服务器集成了处理实际网络搜索的爬虫 API 服务,并使用标准化模型上下文协议与 AI 助手进行通信。
安装
通过 Smithery 安装
要通过Smithery自动安装 Claude Desktop 的 WebSearch:
npx -y @smithery/cli install @mnhlt/WebSearch-MCP --client claude手动安装
npm install -g websearch-mcp或者无需安装即可使用:
npx websearch-mcp配置
可以使用环境变量来配置 WebSearch MCP 服务器:
API_URL:WebSearch Crawler API 的 URL(默认值:http://localhost:3001)MAX_SEARCH_RESULT:请求中未指定时返回的最大搜索结果数(默认值:5)
例子:
# Configure API URL
API_URL=https://crawler.example.com npx websearch-mcp
# Configure maximum search results
MAX_SEARCH_RESULT=10 npx websearch-mcp
# Configure both
API_URL=https://crawler.example.com MAX_SEARCH_RESULT=10 npx websearch-mcp设置和集成
设置 WebSearch-MCP 涉及两个主要部分:配置执行实际网络搜索的爬虫服务,以及将 MCP 服务器与您的 AI 客户端应用程序集成。
设置爬虫服务
WebSearch MCP 服务器需要爬虫服务来执行实际的 Web 搜索。您可以使用 Docker Compose 轻松设置爬虫服务。
先决条件
启动爬虫服务
创建一个名为
docker-compose.yml的文件,其内容如下:
version: '3.8'
services:
crawler:
image: laituanmanh/websearch-crawler:latest
container_name: websearch-api
restart: unless-stopped
ports:
- "3001:3001"
environment:
- NODE_ENV=production
- PORT=3001
- LOG_LEVEL=info
- FLARESOLVERR_URL=http://flaresolverr:8191/v1
depends_on:
- flaresolverr
volumes:
- crawler_storage:/app/storage
flaresolverr:
image: 21hsmw/flaresolverr:nodriver
container_name: flaresolverr
restart: unless-stopped
environment:
- LOG_LEVEL=info
- TZ=UTC
volumes:
crawler_storage:针对 Mac Apple Silicon 的解决方法
version: '3.8'
services:
crawler:
image: laituanmanh/websearch-crawler:latest
container_name: websearch-api
platform: "linux/amd64"
restart: unless-stopped
ports:
- "3001:3001"
environment:
- NODE_ENV=production
- PORT=3001
- LOG_LEVEL=info
- FLARESOLVERR_URL=http://flaresolverr:8191/v1
depends_on:
- flaresolverr
volumes:
- crawler_storage:/app/storage
flaresolverr:
image: 21hsmw/flaresolverr:nodriver
platform: "linux/arm64"
container_name: flaresolverr
restart: unless-stopped
environment:
- LOG_LEVEL=info
- TZ=UTC
volumes:
crawler_storage:启动服务:
docker-compose up -d验证服务是否正在运行:
docker-compose ps测试爬虫 API 健康端点:
curl http://localhost:3001/health预期响应:
{
"status": "ok",
"details": {
"status": "ok",
"flaresolverr": true,
"google": true,
"message": null
}
}爬虫 API 将在http://localhost:3001上可用。
测试爬虫 API
您可以直接使用 curl 测试爬虫 API:
curl -X POST http://localhost:3001/crawl \
-H "Content-Type: application/json" \
-d '{
"query": "typescript best practices",
"numResults": 2,
"language": "en",
"filters": {
"excludeDomains": ["youtube.com"],
"resultType": "all"
}
}'自定义配置
可以通过修改docker-compose.yml文件中的环境变量来自定义爬虫服务:
PORT:爬虫 API 监听的端口(默认值:3001)LOG_LEVEL:日志级别(选项:debug、info、warn、error)FLARESOLVERR_URL:FlareSolverr 服务的 URL(用于绕过 Cloudflare 保护)
与 MCP 客户端集成
快速参考:MCP 配置
以下是跨不同客户端的 MCP 配置的快速参考:
{
"mcpServers": {
"websearch": {
"command": "npx",
"args": [
"websearch-mcp"
],
"environment": {
"API_URL": "http://localhost:3001",
"MAX_SEARCH_RESULT": "5" // reduce to save your tokens, increase for wider information gain
}
}
}
}由于问题,针对 Windows 的解决方法
{
"mcpServers": {
"websearch": {
"command": "cmd",
"args": [
"/c",
"npx",
"websearch-mcp"
],
"environment": {
"API_URL": "http://localhost:3001",
"MAX_SEARCH_RESULT": "1"
}
}
}
}用法
该软件包使用 stdio 传输实现了一个 MCP 服务器,该服务器公开了一个具有以下参数的web_search工具:
参数
query(必需):要查找的搜索查询numResults(可选):返回的结果数(默认值:5)language(可选):搜索结果的语言代码(例如“en”)region(可选):搜索结果的区域代码(例如“us”)excludeDomains(可选):从结果中排除的域includeDomains(可选):仅在结果中包含这些域excludeTerms(可选):从结果中排除的术语resultType(可选):返回的结果类型(“全部”、“新闻”或“博客”)
搜索响应示例
以下是搜索响应的示例:
{
"query": "machine learning trends",
"results": [
{
"title": "Top Machine Learning Trends in 2025",
"snippet": "The key machine learning trends for 2025 include multimodal AI, generative models, and quantum machine learning applications in enterprise...",
"url": "https://example.com/machine-learning-trends-2025",
"siteName": "AI Research Today",
"byline": "Dr. Jane Smith"
},
{
"title": "The Evolution of Machine Learning: 2020-2025",
"snippet": "Over the past five years, machine learning has evolved from primarily supervised learning approaches to more sophisticated self-supervised and reinforcement learning paradigms...",
"url": "https://example.com/ml-evolution",
"siteName": "Tech Insights",
"byline": "John Doe"
}
]
}本地测试
要在本地测试 WebSearch MCP 服务器,您可以使用附带的测试客户端:
npm run test-client这将启动 MCP 服务器和一个简单的命令行界面,允许您输入搜索查询并查看结果。
您还可以为测试客户端配置 API_URL:
API_URL=https://crawler.example.com npm run test-client作为图书馆
您可以通过编程方式使用此包:
import { createMCPClient } from '@modelcontextprotocol/sdk';
// Create an MCP client
const client = createMCPClient({
transport: { type: 'subprocess', command: 'npx websearch-mcp' }
});
// Execute a web search
const response = await client.request({
method: 'call_tool',
params: {
name: 'web_search',
arguments: {
query: 'your search query',
numResults: 5,
language: 'en'
}
}
});
console.log(response.result);故障排除
爬虫服务问题
API 无法访问:确保爬虫服务正在运行,并且可以通过配置的 API_URL 访问。
搜索结果不可用:检查爬虫服务的日志,查看是否有任何错误:
docker-compose logs crawlerFlareSolverr 问题:某些网站使用 Cloudflare 防护。如果您看到与此相关的错误,请检查 FlareSolverr 是否正常工作:
docker-compose logs flaresolverr
MCP 服务器问题
导入错误:确保您拥有最新版本的 MCP SDK:
npm install -g @modelcontextprotocol/sdk@latest连接问题:确保为您的客户端正确配置了 stdio 传输。
发展
从事此项目:
克隆存储库
安装依赖项:
npm install构建项目:
npm run build以开发模式运行:
npm run dev
服务器需要包含 swagger.json 文件中定义的 WebSearch Crawler API。请确保该 API 在配置的 API_URL 上运行。
项目结构
.gitignore:指定 Git 应该忽略的文件(node_modules、dist、logs 等).npmignore:指定发布到 npm 时不应包含的文件package.json:项目元数据和依赖项src/:源 TypeScript 文件dist/:已编译的 JavaScript 文件(构建时生成)
发布到 npm
要将此包发布到 npm:
确保您拥有 npm 帐户并已登录(
npm login)更新 package.json 中的版本(
npm version patch|minor|major)运行
npm publish
.npmignore文件确保发布的包中只包含必要的文件:
dist/中的编译代码README.md 和 LICENSE 文件
包.json
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
执照
国际学习中心
Available Tools
1 toolweb_searchB
Search the web for information. Use this tool when you need to search the web for information. You can use this tool to search for news, blogs, or all types of information. You can also use this tool to search for information about a specific company or product. You can also use this tool to search for information about a specific person. You can also use this tool to search for information about a specific product. You can also use this tool to search for information about a specific company. You can also use this tool to search for information about a specific event. You can also use this tool to search for information about a specific location. You can also use this tool to search for information about a specific thing. If you request search with 1 result number and failed, retry with bigger results number.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The search query to look up | |
| numResults | No | Number of results to return (default: 5) | |
| language | No | Language code for search results (e.g., 'en') | |
| region | No | Region code for search results (e.g., 'us') | |
| excludeDomains | No | Domains to exclude from results | |
| includeDomains | No | Only include these domains in results | |
| excludeTerms | No | Terms to exclude from results | |
| resultType | No | Type of results to return |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It does not mention potential side effects, rate limits, or permissions. The only behavioral detail is the retry advice, which is insufficient for a tool performing external web requests.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is overly repetitive, listing 'You can also use this tool to search for...' multiple times, which adds no value and wastes tokens. The retry advice is useful but could be condensed. A single sentence covering the core function and filtering options would suffice.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with 8 parameters and no output schema, the description provides a basic overview but lacks details on pagination, error handling beyond the retry note, and the structure of results. The schema covers parameter details, but the description does not fully fill the gaps for a complex tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
All 8 parameters have descriptions in the schema, so the schema coverage is 100%. The description adds no additional parameter-specific information beyond what is in the schema, matching the baseline expectation. The retry advice does not relate to parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Search the web for information,' which defines the tool's purpose. However, it lacks specificity and reads as a general search tool rather than highlighting unique capabilities. There are no sibling tools, so no need for differentiation, but the description could be more concise.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description includes explicit guidance on when to use ('when you need to search the web') and a specific retry strategy for failed requests with small result numbers. No siblings exist, so no alternatives to discuss, but the guidance is clear and actionable.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v1.0.0- First observed
web_search
TDQS
Scored across 1 tool
Only one tool exists, so there is no ambiguity. The single tool's purpose is clearly defined as searching the web.
With only one tool, naming consistency is trivially maintained. The name 'web_search' follows a clear verb_noun pattern.
A single tool for a web search server is minimal but acceptable for basic functionality. However, a more complete server might include tools for fetching page content or image search, making the count borderline.
The server provides only a search tool, missing common complementary tools like fetching web page content or performing advanced searches. This leaves notable gaps for typical workflows.
Maintenance
Related MCP Connectors
MCP server for Firecrawl — web search, scraping, and biomedical/arXiv paper search.
Free web search for AI agents. No API key required. Hosted MCP in active development.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseAqualityCmaintenanceA Model Context Protocol server that provides real-time web search capabilities to AI assistants through pluggable search providers, currently integrated with the Brave Search API.516MIT
- FlicenseAqualityCmaintenanceA Model Context Protocol server that provides web search capabilities using Google Custom Search API and webpage content extraction functionality.26 npm2-
- FlicenseCqualityDmaintenanceA Model Context Protocol server that enables web search capabilities using the Tavily API, allowing AI models to retrieve current information from the internet through natural language commands.3-
- AlicenseBqualityDmaintenanceA Model Context Protocol server that provides web search capabilities using Google Custom Search API and webpage content extraction functionality.2MIT