WebSearch 是一款强大的网页信息检索工具,借助 MCP 协议与模型交互。它能解析结构化搜索结果,还提供丰富的自定义选项,可灵活适配不同的使用场景。
WebSearch 可通过 MCP 协议与模型进行交互,下面是一个简单的使用示例:
import { createMCPClient } from '@modelcontextprotocol/sdk';
// 创建 MCP 客户端
const client = createMCPClient({
transport: { type: 'subprocess', command: 'npx websearch-mcp' }
});
// 执行一次网络搜索
const response = await client.request({
method: 'call_tool',
params: {
name: 'web_search',
arguments: {
query: 'machine learning trends',
numResults: 5,
language: 'en'
}
}
});
console.log(response.result);
以下是一个典型的搜索响应示例:
{
"query": "machine learning trends",
"results": [
{
"title": "2025年人工智能趋势预测",
"snippet": "2025年的人工智能发展趋势包括多模态AI、生成式模型和量子人工智能在企业中的应用...",
"url": "https://example.com/ml-trends-2025",
"siteName": "AI研究今日",
"byline": "简·史密斯博士"
},
{
"title": "2020至2025年人工智能演变历程",
"snippet": "过去五年中,人工智能已经从监督学习方法发展到更复杂的自监督和强化学习范式...",
"url": "https://example.com/ml-evolution",
"siteName": "科技见解",
"byline": "约翰·多伊"
}
]
}
npm install websearch-mcp-sdk
git clone https://github.com/yourusername/websearch.git
cd websearch
npm install
websearch/
├── .gitignore
├── .npmignore
├── package.json
├── src/
│ ├── index.ts
│ └── types/
└── dist/
└── main.js
npm install
npm run dev
docker-compose logs crawler
docker-compose logs flaresolverr
本项目采用 ISC 许可证。