# ThinkDrop网页搜索服务
一个具备MCP(模型上下文协议)支持的、可投入生产的网络搜索微服务,专为ThinkDrop AI设计。
特点/特性
- 🔍 多提供商搜索NewsAPI(主用)+ DuckDuckGo(备用)
- ⚡(闪电符号,无具体文字含义,可表示快速、电、能量等概念) 智能缓存时间敏感的查询缓存10分钟,一般查询缓存24小时
- 🔄 旋转(或循环) 自动降级在故障时无缝切换提供商
- 🛡️ 翻译成中文是:盾牌 速率限制客户端限速以遵守API配额
- 📊(表格图标,无具体文字含义,通常用于表示数据或统计信息) 指标与监控内置健康检查和性能追踪
- 🐳 这个表情符号在中文中通常被理解为“海豚”或“可爱的海豚”,不过具体含义可能因上下文和个人理解而有所差异。在没有具体上下文的情况下,它主要传达了一种可爱、活泼或友善的感觉。 Docker 准备就绪全面支持集装箱化
快速入门
先决条件
- Node.js >= 18.0.0
- 无需API密钥!DuckDuckGo免费且开放
安装
# Clone the repository
git clone https://github.com/your-org/thinkdrop-web-search-service.git
cd thinkdrop-web-search-service
# Install dependencies
npm install
# Set up environment
cp .env.example .env
# Edit .env and add your NEWSAPI_KEY
# Initialize database
npm run db:init
# Start development server
npm run dev服务器将在 http://localhost:3002
环境变量
见 .env.example 对于所有可用的配置选项。
要求:
API_KEYAPI身份验证的密钥(例如。,test-key-123)
可选(Brave 搜索):
BRAVE_API_AI_KEY您的Brave AI搜索API密钥(请在https://brave.com/search/api/获取)BRAVE_AI_URL- Brave AI API URL(默认:https://api.search.brave.com/res/v1/chat/completions)BRAVE_API_WEB_KEY- 您的Brave网络搜索API密钥(与AI密钥相同)BRAVE_WEB_URL根据上面的信息,执行如下指令:
可选(其他):
PORT- 服务器端口(默认:3002)CACHE_ENABLED- 启用/禁用缓存(默认:true)RATE_LIMIT_ENABLED- 启用/禁用速率限制(默认:true)NEWSAPI_KEY- 如需新闻特定功能,可选择提供NewsAPI密钥
API 端点
健康检查
GET /service.health能力
GET /service.capabilities网页搜索
POST /web.search
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"version": "mcp.v1",
"service": "web-search",
"action": "web.search",
"requestId": "uuid-123",
"payload": {
"query": "latest AI developments",
"provider": "auto",
"maxResults": 10
}使用Brave AI的示例(默认设置 - 获取带来源的AI答案):
{
"version": "mcp.v1",
"service": "web-search",
"action": "web.search",
"requestId": "unique-id",
"payload": {
"query": "who is the current president of usa",
"maxResults": 10,
"provider": "auto"
}
}以特定提供商为例:
{
"version": "mcp.v1",
"service": "web-search",
"action": "web.search",
"requestId": "unique-id",
"payload": {
"query": "artificial intelligence",
"maxResults": 10,
"provider": "brave-ai"
}
}智能回退策略(自动模式 - 默认):
- DuckDuckGo(注:这是一个搜索引擎的名称,直接翻译为“鸭鸭搜搜”并不符合其实际含义和品牌认知,因此通常保留原名) (免费,无限制)- 首次尝试
- 勇敢的人工智能 (每月2000次免费)- 仅当DuckDuckGo返回空结果时
- 勇敢的网络 (需要API密钥)- 最终备用方案
可用提供者(手动选择):
auto- 智能回退(默认,推荐)duckduckgo- 仅使用DuckDuckGo搜索brave-ai- 基于人工智能的搜索,提供有根据的答案brave-web- Brave浏览器的传统网页搜索newsapi新闻专用搜索(需要API密钥)
新闻搜索
POST /web.news
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"version": "mcp.v1",
"service": "web-search",
"action": "web.news",
"requestId": "uuid-456",
"payload": {
"query": "artificial intelligence",
"category": "technology",
"maxResults": 5
}
}Docker 部署
# Build image
docker build -t thinkdrop-web-search-service .
# Run with docker-compose
docker-compose up -d
# Check logs
docker-compose logs -f测试
# Run all tests
npm test
# Run integration tests
npm run test:integration
# Run load tests
npm run test:load建筑学
src/
├── database/ # DuckDB database setup
├── providers/ # NewsAPI & DuckDuckGo integrations
├── services/ # Core business logic (search, cache, metrics)
├── middleware/ # Auth, rate limiting
├── routes/ # MCP endpoints
└── index.js # Express server演出
- p50潜伏期\50 请求/秒
许可证
MIT 许可证 - 请参阅 LICENSE 文件
支持
- 问题:https://github.com/your-org/thinkdrop-web-search-service/issues
- 文档:请参阅 AGENT_SPEC_WebSearch.md
