一个用于查询和分析存储在 OpenSearch 中的 Wazuh 安全日志的模型上下文协议(MCP)服务器。
您可以直接使用 npx 运行此工具,无需克隆仓库:
# 从 GitHub 运行最新版本
npx github:jetbalsa/mcp-opensearch-js
# 启用调试模式运行
npx github:jetbalsa/mcp-opensearch-js --debug
# 您也可以指定特定分支或提交
npx github:jetbalsa/mcp-opensearch-js#main
git clone https://github.com/jetbalsa/mcp-opensearch-js.git
cd mcp-opensearch-js
npm install
cp .env.example .env
.env 文件,填写您的 OpenSearch 连接详情:OPENSEARCH_URL=https://your-opensearch-endpoint:9200
OPENSEARCH_USERNAME=your-username
OPENSEARCH_PASSWORD=your-password
DEBUG=false
npm start
这将以标准 I/O 模式启动服务器。
npm run stdio:debug
npm run dev
这将以 FastMCP CLI 工具运行服务器,进行交互式测试。
npm run inspect
这将启动服务器并连接到 MCP Inspector 进行可视化调试。
服务器提供了以下工具:
在 Wazuh 数据中搜索安全警报。
参数:
query: 搜索查询文本timeRange: 时间范围(例如,1h, 24h, 7d)maxResults: 返回的最大结果数index: 要搜索的索引模式通过 ID 获取特定警报的详细信息。
参数:
id: 警报 IDindex: 索引模式获取有关安全警报的统计信息。
参数:
timeRange: 时间范围(例如,1h, 24h, 7d)field: 要聚合的字段(例如,rule.level, agent.name)index: 索引模式可视化警报随时间的趋势。
参数:
timeRange: 时间范围(例如,1h, 24h, 7d)interval: 分组的时间间隔(例如,1h, 1d)query: 过滤警报的查询index: 索引模式使用 MCP CLI 工具:
> tools
可用工具:
- searchAlerts: 在 Wazuh 数据中搜索安全警报
- getAlertDetails: 通过 ID 获取特定警报的详细信息
- alertStatistics: 获取有关安全警报的统计信息
- visualizeAlertTrend: 可视化警报随时间的趋势
> tools.searchAlerts(query: "rule.level:>10", timeRange: "12h", maxResults: 5)
要使用此 MCP 服务器与客户端实现一起使用:
import { Client } from "@modelcontextprotocol/sdk";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
const client = new Client(
{
name: "example-client",
version: "1.0.0",
},
{
capabilities: {},
},
);
const transport = new SSEClientTransport(new URL(`http://localhost:3000/sse`));
await client.connect(transport);
// 使用工具
const result = await client.executeTool("searchAlerts", {
query: "rule.level:>10",
timeRange: "24h",
maxResults: 10
});
console.log(result);
MIT