mcp-server-wazuh

mcp-server-wazuh

mcp-server-wazuh

Category
访问服务器

README

Wazuh MCP Server

A Rust-based server designed to bridge the gap between a Wazuh Security Information and Event Management (SIEM) system and applications requiring contextual security data, specifically tailored for the Claude Desktop Integration using the Model Context Protocol (MCP).

Overview

Modern AI assistants like Claude can benefit significantly from real-time context about the user's environment. For security operations, this means providing relevant security alerts and events. Wazuh is a popular open-source SIEM, but its API output isn't directly consumable by systems expecting MCP format.

Example Use Cases

The Wazuh MCP Server, by bridging Wazuh's security data with MCP-compatible applications, unlocks several powerful use cases:

  • Delegated Alert Triage: Automate alert categorization and prioritization via AI, focusing analyst attention on critical events.
  • Enhanced Alert Correlation: Enrich alerts by correlating with CVEs, OSINT, and other threat intelligence for deeper context and risk assessment.
  • Dynamic Security Visualizations: Generate on-demand reports and visualizations of Wazuh data to answer specific security questions.
  • Multilingual Security Operations: Query Wazuh data and receive insights in multiple languages for global team accessibility.
  • Natural Language Data Interaction: Query Wazuh data using natural language for intuitive access to security information.
  • Contextual Augmentation for Other Tools: Use Wazuh data as context to enrich other MCP-enabled tools and AI assistants.

Requirements

  • An MCP (Model Context Protocol) compatible LLM client (e.g., Claude Desktop)
  • A running Wazuh server (v4.x recommended) with the API enabled and accessible.
  • Network connectivity between this server and the Wazuh API (if API interaction is used).

Installation

Option 1: Download Pre-built Binary (Recommended)

  1. Download the Binary:
    • Go to the Releases page of the mcp-server-wazuh GitHub repository.
    • Download the appropriate binary for your operating system (e.g., mcp-server-wazuh-linux-amd64, mcp-server-wazuh-macos-amd64, mcp-server-wazuh-windows-amd64.exe).
    • Make the downloaded binary executable (e.g., chmod +x mcp-server-wazuh-linux-amd64).
    • (Optional) Rename it to something simpler like mcp-server-wazuh and move it to a directory in your system's PATH for easier access.

Option 2: Build from Source

  1. Prerequisites:

  2. Build:

    git clone https://github.com/gbrigandi/mcp-server-wazuh.git
    cd mcp-server-wazuh
    cargo build --release
    

    The binary will be available at target/release/mcp-server-wazuh.

Configure Your LLM Client

The method for configuring your LLM client will vary depending on the client itself. For clients that support MCP (Model Context Protocol), you will typically need to point the client to the path of the mcp-server-wazuh executable.

Example for Claude Desktop:

Configure your claude_desktop_config.json file:

{
  "mcpServers": {
    "wazuh": {
      "command": "/path/to/mcp-server-wazuh",
      "args": [],
      "env": {
        "WAZUH_HOST": "your_wazuh_host",
        "WAZUH_USER": "admin",
        "WAZUH_PASS": "your_wazuh_password",
        "WAZUH_PORT": "9200",
        "VERIFY_SSL": "false",
        "RUST_LOG": "info"
      }
    }
  }
}

Replace /path/to/mcp-server-wazuh with the actual path to your binary and configure the environment variables as detailed in the Configuration section.

Once configured, your LLM client should be able to launch and communicate with the mcp-server-wazuh to access Wazuh security data.

Configuration

Configuration is managed through environment variables. A .env file can be placed in the project root for local development.

Variable Description Default Required (for API)
WAZUH_HOST Hostname or IP address of the Wazuh API server. localhost Yes
WAZUH_PORT Port number for the Wazuh API. 9200 Yes
WAZUH_USER Username for Wazuh API authentication. admin Yes
WAZUH_PASS Password for Wazuh API authentication. admin Yes
VERIFY_SSL Set to true to verify the Wazuh API's SSL cert. false No
MCP_SERVER_PORT Port for this MCP server to listen on (if HTTP enabled). 8000 No
RUST_LOG Log level (e.g., info, debug, trace). info No

Note on VERIFY_SSL: For production environments using the Wazuh API, it is strongly recommended to set VERIFY_SSL=true and ensure proper certificate validation. Setting it to false disables certificate checks, which is insecure.

Architecture

The server is built using the rmcp framework and facilitates communication between MCP clients (e.g., Claude Desktop, IDE extensions) and the Wazuh MCP Server via stdio transport. The server interacts with the Wazuh Indexer API to fetch security alerts and other data.

sequenceDiagram
    participant ClientApp as Client Application (e.g., IDE Extension / Claude Desktop)
    participant WazuhMCPServer as Wazuh MCP Server (this application)
    participant WazuhAPI as Wazuh API

    ClientApp->>+WazuhMCPServer: (stdio) MCP Initialize
    WazuhMCPServer-->>-ClientApp: (stdout) MCP Initialized
    
    ClientApp->>+WazuhMCPServer: (stdio) MCP Request (tools/list)
    WazuhMCPServer->>WazuhMCPServer: Parse MCP Request
    WazuhMCPServer->>WazuhMCPServer: Process internally
    WazuhMCPServer-->>-ClientApp: (stdout) MCP Response (available tools)
    
    ClientApp->>+WazuhMCPServer: (stdio) MCP Request (tools/call for wazuhAlerts)
    WazuhMCPServer->>WazuhMCPServer: Parse MCP Request
    WazuhMCPServer->>+WazuhAPI: Request Wazuh Alerts (with WAZUH_USER, WAZUH_PASS)
    WazuhAPI-->>-WazuhMCPServer: Wazuh Alert Data (JSON)
    WazuhMCPServer->>WazuhMCPServer: Transform Wazuh Alerts to MCP Format
    WazuhMCPServer-->>-ClientApp: (stdout) MCP Response (alerts)

Data Flow (stdio focus):

  1. An application (e.g., an IDE extension, a CLI tool) launches the Wazuh MCP Server as a child process.
  2. The application sends MCP-formatted requests (commands) to the server's stdin.
  3. The Wazuh MCP Server reads the command from stdin.
  4. Processing:
    • The server parses the MCP command.
    • If the command requires fetching data from Wazuh (e.g., "get latest alerts"):
      • The server connects to the Wazuh API (authenticating if necessary using configured credentials like WAZUH_USER, WAZUH_PASS).
      • It fetches the required data (e.g., security alerts).
      • The server's transformation logic (src/mcp/transform.rs) processes each alert, mapping Wazuh fields to MCP fields.
    • If the command is internal (e.g., a status check specific to the MCP server), it processes it directly.
  5. The server sends an MCP-formatted JSON response (e.g., transformed alerts, command acknowledgment, or error messages) to the application via its stdout.
  6. The application reads and processes the MCP response from the server's stdout.

This stdio interaction allows for tight integration with local development tools or other applications that can manage child processes. An optional HTTP endpoint (/mcp) may also be available for clients that prefer polling.

Building

Prerequisites

Local Development

  1. Clone the repository:
    git clone https://github.com/gbrigandi/mcp-server-wazuh.git 
    cd mcp-server-wazuh
    
  2. Configure (if using Wazuh API):
    • Copy the example environment file: cp .env.example .env
    • Edit the .env file with your specific Wazuh API details (WAZUH_HOST, WAZUH_PORT, WAZUH_USER, WAZUH_PASS).
  3. Build:
    cargo build
    
  4. Run:
    cargo run
    # Or use the run script (which might set up stdio mode):
    # ./run.sh
    
    If the HTTP server is enabled, it will start listening on the port specified by MCP_SERVER_PORT (default 8000). Otherwise, it will operate in stdio mode.

Stdio Mode Operation

The server communicates via stdin and stdout using JSON-RPC 2.0 messages, adhering to the Model Context Protocol (MCP).

Example interaction flow:

  1. Client Application (e.g., IDE extension) starts the mcp-server-wazuh process.

  2. Client sends initialize request to server's stdin:

    {
      "jsonrpc": "2.0",
      "id": 0,
      "method": "initialize",
      "params": {
        "protocolVersion": "2024-11-05",
        "capabilities": {
          "sampling": {},
          "roots": { "listChanged": true }
        },
        "clientInfo": {
          "name": "mcp-inspector",
          "version": "0.11.0"
        }
      }
    }
    
  3. Server sends initialize response to client via stdout:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
        "protocolVersion": "2024-11-05",
        "capabilities": {
          "prompts": {},
          "resources": {},
          "tools": {}
        },
        "serverInfo": {
          "name": "rmcp",
          "version": "0.1.5"
        },
        "instructions": "This server provides tools to interact with a Wazuh SIEM instance for security monitoring and analysis.\nAvailable tools:\n- 'get_wazuh_alert_summary': Retrieves a summary of Wazuh security alerts. Optionally takes 'limit' parameter to control the number of alerts returned (defaults to 100)."
      }
    }
    
  4. Client sends notifications/initialized to server's stdin: (This is a notification, so id is omitted by the client.)

    {
      "jsonrpc": "2.0",
      "method": "notifications/initialized"
    }
    
  5. Client requests available tools by sending tools/list to server's stdin:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "tools/list",
      "params": {}
    }
    
  6. Server responds with the list of tools to client via stdout:

    {
      "jsonrpc": "2.0",
      "id": 2,
      "result": {
        "tools": [
          {
            "name": "get_wazuh_alert_summary",
            "description": "Retrieves a summary of Wazuh security alerts. Returns formatted alert information including ID, timestamp, and description.",
            "inputSchema": {
              "$schema": "http://json-schema.org/draft-07/schema#",
              "properties": {
                "limit": {
                  "description": "Maximum number of alerts to retrieve (default: 100)",
                  "format": "uint32",
                  "minimum": 0.0,
                  "type": ["integer", "null"]
                }
              },
              "title": "GetAlertSummaryParams",
              "type": "object"
            }
          }
        ]
      }
    }
    
  7. Client calls the get_wazuh_alert_summary tool by sending tools/call to server's stdin:

    {
      "jsonrpc": "2.0",
      "id": 3,
      "method": "tools/call",
      "params": {
        "name": "get_wazuh_alert_summary",
        "arguments": {
          "limit": 5
        }
      }
    }
    
  8. Server receives on stdin, processes the get_wazuh_alert_summary call (which involves querying the Wazuh Indexer API and transforming the data).

  9. Server sends tools/call response with formatted alerts to client via stdout:

    {
      "jsonrpc": "2.0",
      "id": 3,
      "result": {
        "content": [
          {
            "type": "text",
            "text": "Alert ID: 1747091815.1212763\nTime: 2024-01-15T10:30:45.123Z\nAgent: web-server-01\nLevel: 7\nDescription: Attached USB Storage"
          },
          {
            "type": "text", 
            "text": "Alert ID: 1747066333.1207112\nTime: 2024-01-15T10:25:12.456Z\nAgent: database-server\nLevel: 5\nDescription: New dpkg (Debian Package) installed."
          }
        ],
        "isError": false
      }
    }
    

    Or, if no alerts are found:

    {
      "jsonrpc": "2.0",
      "id": 3,
      "result": {
        "content": [
          {
            "type": "text",
            "text": "No Wazuh alerts found."
          }
        ],
        "isError": false
      }
    }
    

    Or, if there's an error connecting to Wazuh:

    {
      "jsonrpc": "2.0",
      "id": 3,
      "result": {
        "content": [
          {
            "type": "text",
            "text": "Error retrieving alerts from Wazuh: HTTP request error: connection refused"
          }
        ],
        "isError": true
      }
    }
    

Development & Testing

  • Code Style: Uses standard Rust formatting (cargo fmt).
  • Linting: Uses Clippy (cargo clippy).
  • Testing: Contains unit tests for transformation logic and integration tests. For stdio, tests might involve piping input/output to a test harness. For HTTP, tests use a mock Wazuh API server (httpmock) and a test MCP client.
    # Run all tests
    cargo test
    
    # Run specific integration test (example for HTTP tests)
    # cargo test --test integration_test
    
    # Run tests with detailed logging
    RUST_LOG=debug cargo test
    
  • See tests/README.md for more details on running tests and using the test client CLI.

License

This project is licensed under the MIT License.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选