这是一个提供勇敢搜索功能的模型上下文协议(MCP)服务器,它集成了服务器发送事件(SSE)。该服务可以部署到 Coolify 并作为实时搜索服务使用,为用户提供高效、实时的搜索体验。
.env
文件并添加你的 Brave API 密钥:BRAVE_API_KEY=your_api_key_here
PORT=3001
npm install
npm run dev
使用 docker-compose 构建并运行:
docker-compose up --build
npm run build
npm start
GET http://你的服务器:3001/sse
通过 SSE 端点提供实时搜索结果。使用 EventSource API 连接:
const eventSource = new EventSource('http://你的服务器:3001/sse');
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
// 处理搜索结果
console.log(data);
};
eventSource.onerror = (error) => {
console.error('SSE 错误:', error);
eventSource.close();
};
POST http://你的服务器:3001/messages
Content-Type: application/json
{
"query": "你的搜索查询",
"count": 10 // 可选, 默认值:10,最大值:20
}
使用此端点触发搜索,结果将广播到所有连接的 SSE 客户端。
服务器提供以下 MCP 工具:
brave_web_search
:通过 Brave Search API 执行网络搜索{
query: string; // 搜索查询
count?: number; // 结果数量(1-20, 默认值:10)
}
{
"type": "error",
"error": "错误信息"
}