Skip to main content
Glama

OpenSearch MCP Server

by cyberbalsa

OpenSearch MCP 服务器

用于查询和分析存储在 OpenSearch 中的 Wazuh 安全日志的模型上下文协议 (MCP) 服务器。

特征

  • 使用高级过滤功能搜索安全警报

  • 获取有关特定警报的详细信息

  • 生成安全事件统计数据

  • 可视化随时间变化的警报趋势

  • 长期运行操作的进度报告

  • 结构化错误处理

Related MCP server: OpenSearch MCP Server

先决条件

  • Node.js v16 或更高版本

  • 访问包含 Wazuh 安全日志的 OpenSearch 实例

安装

选项 1:直接从 GitHub 使用 npx(推荐)

您可以使用 npx 直接运行此工具,而无需克隆存储库:

# Run the latest version from GitHub npx github:jetbalsa/mcp-opensearch-js # Run with debug mode enabled npx github:jetbalsa/mcp-opensearch-js --debug # You can also specify a specific branch or commit npx github:jetbalsa/mcp-opensearch-js#main

选项 2:本地安装

  1. 克隆此存储库:

git clone https://github.com/jetbalsa/mcp-opensearch-js.git cd mcp-opensearch-js
  1. 安装依赖项:

npm install
  1. 配置环境变量:

cp .env.example .env
  1. 使用您的 OpenSearch 连接详细信息编辑.env文件:

OPENSEARCH_URL=https://your-opensearch-endpoint:9200 OPENSEARCH_USERNAME=your-username OPENSEARCH_PASSWORD=your-password DEBUG=false

运行服务器

启动服务器:

npm start

这将以 stdio 模式启动服务器。

启用调试日志记录:

npm run stdio:debug

使用 MCP CLI 进行测试:

npm run dev

这将使用 FastMCP CLI 工具运行服务器进行交互式测试。

使用 MCP Inspector 进行测试:

npm run inspect

这将启动服务器并将其连接到 MCP Inspector 进行可视化调试。

服务器工具

该服务器提供以下工具:

1. 搜索提醒

在 Wazuh 数据中搜索安全警报。

参数:

  • query :搜索查询文本

  • timeRange :时间范围(例如 1h、24h、7d)

  • maxResults :返回的最大结果数

  • index :要搜索的索引模式

2. 获取警报详细信息

通过 ID 获取有关特定警报的详细信息。

参数:

  • id :警报 ID

  • index :索引模式

3. 警报统计

获取有关安全警报的统计数据。

参数:

  • timeRange :时间范围(例如 1h、24h、7d)

  • field :要聚合的字段(例如,rule.level、agent.name)

  • index :索引模式

4. 可视化警报趋势

可视化随时间变化的警报趋势。

参数:

  • timeRange :时间范围(例如 1h、24h、7d)

  • interval :分组的时间间隔(例如 1h、1d)

  • query :查询过滤警报

  • index :索引模式

示例用法

使用 MCP CLI 工具:

> tools Available tools: - searchAlerts: Search for security alerts in Wazuh data - getAlertDetails: Get detailed information about a specific alert by ID - alertStatistics: Get statistics about security alerts - visualizeAlertTrend: Visualize alert trends over time > 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); // Use tools const result = await client.executeTool("searchAlerts", { query: "rule.level:>10", timeRange: "24h", maxResults: 10 }); console.log(result);

执照

麻省理工学院

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyberbalsa/mcp-opensearch-js'

If you have feedback or need assistance with the MCP directory API, please join our Discord server