Wazuh 安全智能
STDIO基于AI的Wazuh安全运营平台
基于AI的Wazuh安全运营平台
A production-ready, enterprise-grade MCP-compliant remote server that provides seamless integration with Wazuh SIEM platform using the latest Streamable HTTP transport (MCP 2025-06-18).
Latest Standard: Streamable HTTP transport with
/mcpendpoint (2025-06-18)Backwards Compatible: Legacy
/sseendpoint maintainedCompliance: ✅ 100% compliant with MCP 2025-06-18 specification
/mcp endpoint with dynamic SSE upgrade/sse endpoint for older clientsThis implementation 100% complies with the latest MCP specification:
| Standard | Status | Implementation |
|---|---|---|
| 🔗 Streamable HTTP | ✅ COMPLIANT | /mcp endpoint with POST/GET/DELETE support |
| 📡 Protocol Versioning | ✅ COMPLIANT | MCP-Protocol-Version header validation |
| ⚡ Dynamic Streaming | ✅ COMPLIANT | JSON or SSE based on Accept header |
| 🔐 Authentication | ✅ COMPLIANT | Bearer token (JWT) authentication |
| 🛡️ Security | ✅ COMPLIANT | HTTPS, origin validation, rate limiting |
| 🔄 Legacy Support | ✅ COMPLIANT | Legacy /sse endpoint maintained |
| 📋 Session Management | ✅ COMPLIANT | Full session lifecycle with DELETE support |
Perfect Score: 33/33 Requirements Met ⭐
📋 View Full Compliance Verification →
References:
Supported Wazuh Versions: 4.8.0 - 4.14.1 ✅
Comprehensive toolkit for security operations including:
Alert Management (4 tools)
Agent Management (6 tools)
Vulnerability Management (3 tools)
Security Analysis (6 tools)
System Monitoring (10 tools)
OS-Agnostic Deployment: Everything runs in Docker containers. Works on Windows, macOS, and Linux identically.
git clone <your-repository-url> cd Wazuh-MCP-Server
# Copy environment template cp .env.example .env # Edit configuration (required) # Windows: notepad .env # macOS/Linux: nano .env
Essential Configuration:
# Wazuh Server Connection WAZUH_HOST=https://your-wazuh-server.com WAZUH_USER=your-api-user WAZUH_PASS=your-api-password WAZUH_PORT=55000 # MCP Remote Server Configuration MCP_HOST=0.0.0.0 MCP_PORT=3000 # Authentication (JWT Secret Key) AUTH_SECRET_KEY=your-secret-key-here # CORS for Claude Desktop ALLOWED_ORIGINS=https://claude.ai,https://*.anthropic.com
Option 1: Python Deployment Script (Recommended - Works on all platforms)
# Windows python deploy.py # macOS/Linux python3 deploy.py
Option 2: Platform-Specific Scripts
# Linux/macOS ./deploy-production.sh # Windows (PowerShell/CMD) deploy.bat # Or use Docker Compose directly (all platforms) docker compose up -d --wait
# Server will generate an API key on startup (check logs) docker compose logs wazuh-mcp-remote-server | grep "API key" # Exchange API key for JWT token curl -X POST http://localhost:3000/auth/token \ -H "Content-Type: application/json" \ -d '{"api_key": "wazuh_your-generated-api-key"}'
# Test the official /sse endpoint curl -H "Authorization: Bearer your-jwt-token" \ -H "Origin: http://localhost" \ -H "Accept: text/event-stream" \ http://localhost:3000/sse # Check service status docker compose ps # Health check curl http://localhost:3000/health
| Variable | Description | Default | Required |
|---|---|---|---|
WAZUH_HOST | Wazuh server URL | - | ✅ |
WAZUH_USER | API username | - | ✅ |
WAZUH_PASS | API password | - | ✅ |
WAZUH_PORT | API port | 55000 | ❌ |
MCP_HOST | Server bind address | 127.0.0.1 | ❌ |
MCP_PORT | Server port | 3000 | ❌ |
AUTH_SECRET_KEY | JWT signing key | - | ✅ |
LOG_LEVEL | Logging level | INFO | ❌ |
WAZUH_VERIFY_SSL | SSL verification | false | ❌ |
ALLOWED_ORIGINS | CORS origins | https://claude.ai | ❌ |
REDIS_URL | Redis URL for serverless sessions | - | ❌ |
SESSION_TTL_SECONDS | Session TTL (Redis only) | 1800 | ❌ |
The compose.yml follows Docker Compose v2 latest naming convention and includes:
Option 1: Docker Development Environment
# Run with development compose file docker compose -f compose.dev.yml up -d --build # View logs docker compose -f compose.dev.yml logs -f
Option 2: Native Python Development
# Create virtual environment python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate # Install dependencies pip install -r requirements.txt # Run development server python -m wazuh_mcp_server
src/wazuh_mcp_server/
├── __main__.py # Application entry point
├── server.py # MCP-compliant FastAPI server
├── config.py # Configuration management
├── auth.py # Authentication & authorization
├── security.py # Security middleware & validation
├── monitoring.py # Metrics & health checks
├── resilience.py # Circuit breakers & retry logic
├── api/
│ └── wazuh_client.py # Wazuh API client
└── tools/ # MCP tools implementation
└── core.py # 3 essential security tools
# Build for current platform docker build -t wazuh-mcp-server:custom . # Multi-platform build docker buildx build --platform linux/amd64,linux/arm64 -t wazuh-mcp-server:multi .
# Generate secure API key openssl rand -hex 32 # Set restrictive file permissions chmod 600 .env chmod 700 deploy-production.sh # Regular security updates docker compose pull docker compose up -d
The server includes production-grade HA features for maximum reliability:
Circuit Breakers
Retry Logic
Graceful Shutdown
Implementation:
# Automatically applied to all Wazuh API calls # No configuration required - works out of the box
Enable horizontally scalable, serverless deployments with external session storage:
Default Mode: In-Memory Sessions
# Single-instance deployments (default) # No configuration needed docker compose up -d
Serverless Mode: Redis Sessions
# Multi-instance/serverless deployments # Configure Redis in .env file REDIS_URL=redis://redis:6379/0 SESSION_TTL_SECONDS=1800 # 30 minutes # Deploy with Redis docker compose -f compose.yml -f compose.redis.yml up -d
Redis Setup (Optional):
# compose.redis.yml services: redis: image: redis:7-alpine ports: - "6379:6379" volumes: - redis-data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s volumes: redis-data:
Verification:
# Check session storage mode curl http://localhost:3000/health | jq '.session_storage' # Output: # { # "type": "InMemorySessionStore" # or "RedisSessionStore" # "sessions_count": 5 # }
# Application health curl http://localhost:3000/health # Detailed metrics curl http://localhost:3000/metrics # Container health docker inspect wazuh-mcp-server --format='{{.State.Health.Status}}'
# Follow live logs docker compose logs -f --timestamps wazuh-mcp-server # Export logs docker compose logs --since=24h wazuh-mcp-server > server.log
/metrics endpoint/health with detailed status# Deploy/Update ./deploy-production.sh # View status docker compose ps --format table # Scale service docker compose up --scale wazuh-mcp-server=2 -d # Stop services docker compose down --timeout 30 # Full cleanup docker compose down --volumes --remove-orphans
# Update images docker compose pull && docker compose up -d # Backup configuration tar -czf backup-$(date +%Y%m%d).tar.gz .env compose.yml # View resource usage docker stats wazuh-mcp-server --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}"
| Endpoint | Method | Description |
|---|---|---|
/sse | GET | Official MCP SSE endpoint (required for Claude Desktop) |
/ | POST | JSON-RPC 2.0 endpoint (alternative API access) |
/auth/token | POST | Authentication token generation |
/health | GET | Health check and status |
/metrics | GET | Prometheus metrics |
/docs | GET | OpenAPI documentation |
Important: Claude Desktop must use the
/sseendpoint with Bearer authentication
# Get access token curl -X POST http://localhost:3000/auth/token \ -H "Content-Type: application/json" \ -d '{"api_key": "your-api-key"}' # Use token in requests curl -H "Authorization: Bearer <token>" http://localhost:3000/
First, get your JWT token for Claude Desktop authentication:
# 1. Get the API key from server logs (generated on startup) docker compose logs wazuh-mcp-remote-server | grep "Created default API key" # 2. Exchange API key for JWT token curl -X POST http://localhost:3000/auth/token \ -H "Content-Type: application/json" \ -d '{"api_key": "wazuh_your-generated-api-key"}' # Response includes the bearer token { "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...", "token_type": "bearer", "expires_in": 86400 }
Recommended Configuration (Streamable HTTP - 2025-06-18):
{ "mcpServers": { "wazuh-security": { "url": "https://your-server-domain.com/mcp", "headers": { "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...", "MCP-Protocol-Version": "2025-06-18" } } } }
Legacy Configuration (SSE only - for older clients):
{ "mcpServers": { "wazuh-security": { "url": "https://your-server-domain.com/sse", "headers": { "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." } } } }
For Local Development:
{ "mcpServers": { "wazuh-security": { "url": "http://localhost:3000/mcp", "headers": { "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...", "MCP-Protocol-Version": "2025-06-18" } } } }
After saving the configuration, restart Claude Desktop to load the new MCP server connection.
✅ Requirements Checklist:
- ✅ Use
/mcpendpoint for latest features (recommended)- ✅ Use
/sseendpoint for legacy clients only- ✅
Authorization: Bearer <token>header required- ✅
MCP-Protocol-Versionheader recommended for/mcpendpoint- ✅ HTTPS required for production
- ✅ Token expires in 24 hours (renewable)
Using the official /sse endpoint:
import httpx import asyncio async def connect_to_mcp_sse(): """Connect to MCP server using SSE endpoint.""" async with httpx.AsyncClient() as client: # Get authentication token first auth_response = await client.post( "http://localhost:3000/auth/token", json={"api_key": "your-api-key"} ) token = auth_response.json()["access_token"] # Connect to SSE endpoint async with client.stream( "GET", "http://localhost:3000/sse", headers={ "Authorization": f"Bearer {token}", "Accept": "text/event-stream", "Origin": "http://localhost" } ) as response: async for chunk in response.aiter_text(): print(f"Received: {chunk}") # Run the SSE client asyncio.run(connect_to_mcp_sse())
Using JSON-RPC endpoint (alternative):
import httpx async def query_wazuh_mcp(): async with httpx.AsyncClient() as client: # Get authentication token auth_response = await client.post( "http://localhost:3000/auth/token", json={"api_key": "your-api-key"} ) token = auth_response.json()["access_token"] # Make JSON-RPC request response = await client.post( "http://localhost:3000/", headers={ "Authorization": f"Bearer {token}", "Origin": "http://localhost" }, json={ "jsonrpc": "2.0", "id": "1", "method": "tools/list" } ) return response.json()
MCP /sse Endpoint Issues
# Test SSE endpoint authentication curl -I http://localhost:3000/sse # Expected: 401 Unauthorized (good - auth required) # Test with valid token curl -H "Authorization: Bearer your-jwt-token" \ -H "Origin: http://localhost" \ -H "Accept: text/event-stream" \ http://localhost:3000/sse # Expected: 200 OK with SSE stream # Get new authentication token curl -X POST http://localhost:3000/auth/token \ -H "Content-Type: application/json" \ -d '{"api_key": "your-api-key"}'
Claude Desktop Connection Issues
# Verify Claude Desktop can reach the server curl http://localhost:3000/health # Expected: {"status": "healthy"} # Check CORS configuration grep ALLOWED_ORIGINS .env # Should include: https://claude.ai,https://*.anthropic.com
Connection Refused
# Check service status docker compose ps docker compose logs wazuh-mcp-remote-server # Verify port availability netstat -ln | grep 3000
Authentication Errors
# Verify Wazuh credentials curl -u "$WAZUH_USER:$WAZUH_PASS" "$WAZUH_HOST:$WAZUH_PORT/" # Check API key in server logs docker compose logs wazuh-mcp-remote-server | grep "API key"
SSL/TLS Issues
# Disable SSL verification for testing echo "WAZUH_VERIFY_SSL=false" >> .env docker compose up -d
This project is licensed under the MIT License - see the LICENSE file for details.
Built for the security community with production-ready MCP compliance.
We're looking for hands-on testers to deploy this MCP server in real-world environments and provide feedback!
What We Need:
How to Contribute:
Deploy & Test
# Follow the Quick Start guide git clone https://github.com/gensecaihq/Wazuh-MCP-Server.git cd Wazuh-MCP-Server python deploy.py
Report Findings
What to Report
We Value:
Recognition: All contributors who provide valuable feedback will be acknowledged in the project!
📧 Questions? Open a Discussion or file an Issue
This production-ready remote MCP server implementation includes:
The Wazuh MCP Remote Server represents a gold standard implementation of Anthropic's MCP remote server specifications:
🎯 100% MCP Compliant - Perfect compliance score (33/33 requirements)
⚡ Streamable HTTP & Legacy SSE - Latest /mcp endpoint plus backward-compatible /sse
🔐 Enterprise Security - JWT authentication, rate limiting, CORS protection
🛡️ Production Ready - Docker containerized, multi-platform, health monitoring
🔧 29 Security Tools - Comprehensive Wazuh SIEM integration
📊 Observable - Prometheus metrics, structured logging, health checks
This implementation is immediately deployable in production environments and provides:
The result is a robust, secure, and highly capable MCP remote server that sets the standard for enterprise AI-SIEM integrations.