Wazuh OpenSearch Analytics

by jetbalsa

Not rated
GitHub

About

Enables security analysts to query, analyze, and visualize Wazuh security logs stored in OpenSearch databases for efficient incident investigation and monitoring.

Details

Author
jetbalsa
Repository
cyberbalsa/mcp-opensearch-js
Categories
AI, Design, Developer Tools, Search, Security, Frontend, Infrastructure
Tags
#analytics

- Search for security alerts with advanced filtering
- Get detailed information about specific alerts
- Generate statistics on security events
- Visualize alert trends over time
- Progress reporting for long-running operations
- Structured error handling

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Wazuh OpenSearch Analytics
    Command (node, npx, python, etc.) npx
    Arguments
    • Argument 1 -y
    • Argument 2 @highlight/mcp-server

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

1. Clone this repository:

git clone https://github.com/jetbalsa/mcp-opensearch-js.git
cd mcp-opensearch-js

2. Install dependencies:

npm install

3. Configure your environment variables:

cp .env.example .env

4. Edit the .env file with your OpenSearch connection details:

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

Using the MCP CLI tool:

> 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)

searchAlerts

Search for security alerts in Wazuh data. Parameters: query (string), timeRange (string), maxResults (integer), index (string)

getAlertDetails

Get detailed information about a specific alert by ID. Parameters: id (string), index (string)

alertStatistics

Get statistics about security alerts. Parameters: timeRange (string), field (string), index (string)

visualizeAlertTrend

Visualize alert trends over time. Parameters: timeRange (string), interval (string), query (string), index (string)

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "wazuh opensearch analytics": {
            "env": {},
            "args": [
                "-y",
                "@highlight/mcp-server"
            ],
            "command": "npx"
        }
    }
}

Linux

{
    "env": [],
    "args": [
        "-y",
        "@highlight/mcp-server"
    ],
    "command": "npx"
}

Macos

{
    "env": [],
    "args": [
        "-y",
        "@highlight/mcp-server"
    ],
    "command": "npx"
}

Windows

{
    "env": [],
    "args": [
        "/c",
        "npx",
        "-y",
        "@highlight/mcp-server"
    ],
    "command": "cmd"
}

OpenSearch MCP Server

A Model Context Protocol (MCP) server for querying and analyzing Wazuh security logs stored in OpenSearch.

Features

- Search for security alerts with advanced filtering
- Get detailed information about specific alerts
- Generate statistics on security events
- Visualize alert trends over time
- Progress reporting for long-running operations
- Structured error handling

Prerequisites

- Node.js v16 or higher
- Access to an OpenSearch instance containing Wazuh security logs

Installation

Option 1: Use with npx directly from GitHub (recommended)

You can run this tool directly using npx without cloning the repository:

# 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

Option 2: Local Installation

1. Clone this repository:

git clone https://github.com/jetbalsa/mcp-opensearch-js.git
cd mcp-opensearch-js

2. Install dependencies:

npm install

3. Configure your environment variables:

cp .env.example .env

4. Edit the .env file with your OpenSearch connection details:

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

Running the Server

Start the server:

npm start

This will start the server in stdio mode.

Enable debug logging:

npm run stdio:debug

Test with MCP CLI:

npm run dev

This runs the server with the FastMCP CLI tool for interactive testing.

Test with MCP Inspector:

npm run inspect

This starts the server and connects it to the MCP Inspector for visual debugging.

Server Tools

The server provides the following tools:

1. Search Alerts

Search for security alerts in Wazuh data.

Parameters:
- query: The search query text
- timeRange: Time range (e.g., 1h, 24h, 7d)
- maxResults: Maximum number of results to return
- index: Index pattern to search

2. Get Alert Details

Get detailed information about a specific alert by ID.

Parameters:
- id: The alert ID
- index: Index pattern

3. Alert Statistics

Get statistics about security alerts.

Parameters:
- timeRange: Time range (e.g., 1h, 24h, 7d)
- field: Field to aggregate by (e.g., rule.level, agent.name)
- index: Index pattern

4. Visualize Alert Trend

Visualize alert trends over time.

Parameters:
- timeRange: Time range (e.g., 1h, 24h, 7d)
- interval: Time interval for grouping (e.g., 1h, 1d)
- query: Query to filter alerts
- index: Index pattern

Example Usage

Using the MCP CLI tool:

> 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)

Using with a Client

To use this MCP server with a client implementation:

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);

License

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.