@modular-intelligence/wazuh 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +462 -0
- package/dist/index.js +44874 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
# Wazuh MCP Server
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server for Wazuh SIEM/HIDS integration. This server provides read-only access to Wazuh security monitoring data including agents, alerts, vulnerabilities, compliance assessments, and file integrity monitoring.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Agent Management**: List and monitor Wazuh agents with status filtering
|
|
8
|
+
- **Alert Search**: Query security alerts with advanced filtering options
|
|
9
|
+
- **Vulnerability Assessment**: Retrieve CVE data and vulnerability reports
|
|
10
|
+
- **Security Configuration Assessment (SCA)**: Access compliance policy results
|
|
11
|
+
- **File Integrity Monitoring (FIM)**: Monitor file changes and integrity
|
|
12
|
+
- **Rule Management**: Browse Wazuh detection rules with compliance mappings
|
|
13
|
+
- **Statistics**: View aggregated security metrics and trends
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
- **Wazuh Manager**: Version 4.x or later
|
|
18
|
+
- **HTTPS Access**: Wazuh API must be accessible via HTTPS
|
|
19
|
+
- **API Credentials**: Valid Wazuh API user with read permissions
|
|
20
|
+
- **Bun Runtime**: v1.0 or later
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cd /path/to/mi-mcp-servers/packages/wazuh
|
|
26
|
+
bun install
|
|
27
|
+
bun run build
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
Set the following environment variables:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
export WAZUH_API_URL="https://your-wazuh-manager:55000"
|
|
36
|
+
export WAZUH_API_USER="your-api-user"
|
|
37
|
+
export WAZUH_API_PASSWORD="your-api-password"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Security Requirements
|
|
41
|
+
|
|
42
|
+
1. **HTTPS Only**: The server enforces HTTPS connections to the Wazuh API
|
|
43
|
+
2. **Read-Only**: All tools are read-only; no write or remediation operations
|
|
44
|
+
3. **Blocked Endpoints**: The following endpoint patterns are blocked for safety:
|
|
45
|
+
- `/active-response` - Active response commands
|
|
46
|
+
- `/agents/restart` - Agent restart operations
|
|
47
|
+
- `/agents/upgrade` - Agent upgrade operations
|
|
48
|
+
- `/manager/restart` - Manager restart operations
|
|
49
|
+
|
|
50
|
+
### Authentication
|
|
51
|
+
|
|
52
|
+
The server uses JWT token authentication with automatic token caching:
|
|
53
|
+
- Tokens are cached for 14 minutes (15-minute validity)
|
|
54
|
+
- Automatic re-authentication when tokens expire
|
|
55
|
+
- Basic auth only used for initial token acquisition
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
### Running the Server
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
bun run start
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### MCP Client Configuration
|
|
66
|
+
|
|
67
|
+
Add to your MCP client configuration (e.g., Claude Desktop):
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"mcpServers": {
|
|
72
|
+
"wazuh": {
|
|
73
|
+
"command": "bun",
|
|
74
|
+
"args": ["run", "/path/to/mi-mcp-servers/packages/wazuh/src/index.ts"],
|
|
75
|
+
"env": {
|
|
76
|
+
"WAZUH_API_URL": "https://your-wazuh-manager:55000",
|
|
77
|
+
"WAZUH_API_USER": "your-api-user",
|
|
78
|
+
"WAZUH_API_PASSWORD": "your-api-password"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Available Tools
|
|
86
|
+
|
|
87
|
+
### 1. wazuh_agent_list
|
|
88
|
+
|
|
89
|
+
List Wazuh agents with optional status filtering.
|
|
90
|
+
|
|
91
|
+
**Parameters:**
|
|
92
|
+
- `status` (string, optional): Filter by connection status
|
|
93
|
+
- Options: `active`, `disconnected`, `pending`, `never_connected`, `all`
|
|
94
|
+
- Default: `all`
|
|
95
|
+
- `limit` (number, optional): Max results (1-500, default: 50)
|
|
96
|
+
- `offset` (number, optional): Pagination offset (default: 0)
|
|
97
|
+
|
|
98
|
+
**Returns:**
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"total": 10,
|
|
102
|
+
"agents": [
|
|
103
|
+
{
|
|
104
|
+
"id": "001",
|
|
105
|
+
"name": "web-server-01",
|
|
106
|
+
"ip": "10.0.1.100",
|
|
107
|
+
"os": "Ubuntu 22.04",
|
|
108
|
+
"status": "active",
|
|
109
|
+
"last_keep_alive": "2024-01-15T10:30:00Z",
|
|
110
|
+
"group": ["web", "production"],
|
|
111
|
+
"version": "4.7.0"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 2. wazuh_alert_search
|
|
118
|
+
|
|
119
|
+
Search and filter security alerts.
|
|
120
|
+
|
|
121
|
+
**Parameters:**
|
|
122
|
+
- `query` (string, optional): Search query string
|
|
123
|
+
- `level` (number, optional): Alert severity level (1-15)
|
|
124
|
+
- `agent_id` (string, optional): Filter by agent ID
|
|
125
|
+
- `date_range` (object, optional): Time range filter
|
|
126
|
+
- `start` (string): ISO datetime (e.g., "2024-01-01T00:00:00Z")
|
|
127
|
+
- `end` (string): ISO datetime
|
|
128
|
+
- `limit` (number, optional): Max results (1-500, default: 50)
|
|
129
|
+
- `offset` (number, optional): Pagination offset (default: 0)
|
|
130
|
+
|
|
131
|
+
**Returns:**
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"total": 42,
|
|
135
|
+
"alerts": [
|
|
136
|
+
{
|
|
137
|
+
"id": "alert-123",
|
|
138
|
+
"timestamp": "2024-01-15T10:30:15Z",
|
|
139
|
+
"agent_id": "001",
|
|
140
|
+
"agent_name": "web-server-01",
|
|
141
|
+
"rule_id": 5710,
|
|
142
|
+
"rule_description": "sshd: Attempt to login using a non-existent user",
|
|
143
|
+
"rule_level": 5,
|
|
144
|
+
"rule_groups": ["authentication_failed", "syslog", "sshd"],
|
|
145
|
+
"location": "/var/log/auth.log",
|
|
146
|
+
"full_log": "Jan 15 10:30:15 web-01 sshd[1234]: Invalid user admin from 192.168.1.100"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 3. wazuh_vulnerability_list
|
|
153
|
+
|
|
154
|
+
List vulnerabilities detected on an agent.
|
|
155
|
+
|
|
156
|
+
**Parameters:**
|
|
157
|
+
- `agent_id` (string, required): Agent ID (3+ digits)
|
|
158
|
+
- `severity` (string, optional): Filter by severity
|
|
159
|
+
- Options: `Critical`, `High`, `Medium`, `Low`, `Untriaged`
|
|
160
|
+
- `limit` (number, optional): Max results (1-500, default: 50)
|
|
161
|
+
- `offset` (number, optional): Pagination offset (default: 0)
|
|
162
|
+
|
|
163
|
+
**Returns:**
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"total": 15,
|
|
167
|
+
"vulnerabilities": [
|
|
168
|
+
{
|
|
169
|
+
"cve": "CVE-2024-1234",
|
|
170
|
+
"name": "openssh-server",
|
|
171
|
+
"version": "8.2p1-4ubuntu0.5",
|
|
172
|
+
"severity": "High",
|
|
173
|
+
"cvss_score": 7.5,
|
|
174
|
+
"detection_time": "2024-01-15T09:00:00Z",
|
|
175
|
+
"status": "pending",
|
|
176
|
+
"external_references": ["https://nvd.nist.gov/vuln/detail/CVE-2024-1234"]
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 4. wazuh_sca_results
|
|
183
|
+
|
|
184
|
+
Retrieve Security Configuration Assessment results.
|
|
185
|
+
|
|
186
|
+
**Parameters:**
|
|
187
|
+
- `agent_id` (string, required): Agent ID (3+ digits)
|
|
188
|
+
- `policy_id` (string, optional): Specific policy ID for detailed results
|
|
189
|
+
- `limit` (number, optional): Max results (1-500, default: 50)
|
|
190
|
+
- `offset` (number, optional): Pagination offset (default: 0)
|
|
191
|
+
|
|
192
|
+
**Returns (Policy Overview):**
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"total": 3,
|
|
196
|
+
"policies": [
|
|
197
|
+
{
|
|
198
|
+
"policy_id": "cis_ubuntu22-04",
|
|
199
|
+
"name": "CIS Benchmark for Ubuntu Linux 22.04",
|
|
200
|
+
"description": "Center for Internet Security benchmark",
|
|
201
|
+
"pass": 85,
|
|
202
|
+
"fail": 12,
|
|
203
|
+
"invalid": 3,
|
|
204
|
+
"score": 87
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Returns (Detailed Checks - when policy_id specified):**
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"total": 100,
|
|
214
|
+
"checks": [
|
|
215
|
+
{
|
|
216
|
+
"id": "1234",
|
|
217
|
+
"title": "Ensure password expiration is 90 days or less",
|
|
218
|
+
"description": "Password expiration should be configured",
|
|
219
|
+
"rationale": "Reduces risk of compromised credentials",
|
|
220
|
+
"remediation": "Set PASS_MAX_DAYS to 90 in /etc/login.defs",
|
|
221
|
+
"result": "passed",
|
|
222
|
+
"status": "compliant",
|
|
223
|
+
"reason": "PASS_MAX_DAYS is set to 90"
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 5. wazuh_integrity_check
|
|
230
|
+
|
|
231
|
+
Retrieve File Integrity Monitoring (FIM/Syscheck) results.
|
|
232
|
+
|
|
233
|
+
**Parameters:**
|
|
234
|
+
- `agent_id` (string, required): Agent ID (3+ digits)
|
|
235
|
+
- `file_path` (string, optional): Filter by file path (supports wildcards)
|
|
236
|
+
- `limit` (number, optional): Max results (1-500, default: 50)
|
|
237
|
+
- `offset` (number, optional): Pagination offset (default: 0)
|
|
238
|
+
|
|
239
|
+
**Returns:**
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"total": 25,
|
|
243
|
+
"files": [
|
|
244
|
+
{
|
|
245
|
+
"file": "/etc/passwd",
|
|
246
|
+
"size": 2048,
|
|
247
|
+
"permissions": "rw-r--r--",
|
|
248
|
+
"uid": "0",
|
|
249
|
+
"gid": "0",
|
|
250
|
+
"md5": "5d41402abc4b2a76b9719d911017c592",
|
|
251
|
+
"sha1": "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d",
|
|
252
|
+
"sha256": "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
|
|
253
|
+
"mtime": "2024-01-15T08:30:00Z",
|
|
254
|
+
"event": "modified",
|
|
255
|
+
"date": "2024-01-15T08:30:15Z"
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### 6. wazuh_rule_list
|
|
262
|
+
|
|
263
|
+
List Wazuh detection rules with filtering.
|
|
264
|
+
|
|
265
|
+
**Parameters:**
|
|
266
|
+
- `level` (number, optional): Filter by severity level (1-15)
|
|
267
|
+
- `group` (string, optional): Filter by rule group (e.g., "authentication", "web", "syslog")
|
|
268
|
+
- `search` (string, optional): Search in rule descriptions
|
|
269
|
+
- `limit` (number, optional): Max results (1-500, default: 50)
|
|
270
|
+
- `offset` (number, optional): Pagination offset (default: 0)
|
|
271
|
+
|
|
272
|
+
**Returns:**
|
|
273
|
+
```json
|
|
274
|
+
{
|
|
275
|
+
"total": 3500,
|
|
276
|
+
"rules": [
|
|
277
|
+
{
|
|
278
|
+
"id": 5710,
|
|
279
|
+
"level": 5,
|
|
280
|
+
"description": "sshd: Attempt to login using a non-existent user",
|
|
281
|
+
"groups": ["authentication_failed", "syslog", "sshd"],
|
|
282
|
+
"file": "0095-sshd_rules.xml",
|
|
283
|
+
"pci_dss": ["10.2.4", "10.2.5"],
|
|
284
|
+
"gdpr": ["IV_35.7.d", "IV_32.2"],
|
|
285
|
+
"hipaa": ["164.312.b"],
|
|
286
|
+
"nist": ["AU.14", "AC.7"]
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### 7. wazuh_stats
|
|
293
|
+
|
|
294
|
+
Retrieve aggregated statistics for manager or specific agent.
|
|
295
|
+
|
|
296
|
+
**Parameters:**
|
|
297
|
+
- `agent_id` (string, optional): Agent ID for agent-specific stats
|
|
298
|
+
- `date` (string, optional): Date in YYYY-MM-DD format (defaults to today)
|
|
299
|
+
|
|
300
|
+
**Returns:**
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"total_alerts": 1234,
|
|
304
|
+
"by_level": {
|
|
305
|
+
"3": 450,
|
|
306
|
+
"5": 380,
|
|
307
|
+
"7": 250,
|
|
308
|
+
"10": 120,
|
|
309
|
+
"12": 34
|
|
310
|
+
},
|
|
311
|
+
"by_agent": {
|
|
312
|
+
"001": 450,
|
|
313
|
+
"002": 380,
|
|
314
|
+
"003": 404
|
|
315
|
+
},
|
|
316
|
+
"top_rules": [
|
|
317
|
+
{
|
|
318
|
+
"rule_id": 5710,
|
|
319
|
+
"description": "sshd: Attempt to login using a non-existent user",
|
|
320
|
+
"count": 125
|
|
321
|
+
}
|
|
322
|
+
],
|
|
323
|
+
"hourly_distribution": {
|
|
324
|
+
"00": 45,
|
|
325
|
+
"01": 32,
|
|
326
|
+
"02": 28,
|
|
327
|
+
"...": "..."
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
## Error Handling
|
|
333
|
+
|
|
334
|
+
The server provides detailed error messages for common issues:
|
|
335
|
+
|
|
336
|
+
- **Missing credentials**: "WAZUH_API_URL, WAZUH_API_USER, and WAZUH_API_PASSWORD are required"
|
|
337
|
+
- **Invalid URL**: "Wazuh API URL must use HTTPS"
|
|
338
|
+
- **Authentication failure**: "Wazuh auth failed: 401"
|
|
339
|
+
- **Invalid agent ID**: "Agent ID must be a 3+ digit number"
|
|
340
|
+
- **Blocked endpoint**: "Endpoint /active-response is blocked for safety"
|
|
341
|
+
- **API errors**: "Wazuh API error: 404 Not Found"
|
|
342
|
+
|
|
343
|
+
## Security Considerations
|
|
344
|
+
|
|
345
|
+
1. **Credentials**: Store API credentials securely, never commit to version control
|
|
346
|
+
2. **HTTPS Only**: Non-HTTPS connections are rejected
|
|
347
|
+
3. **Read-Only**: No write operations supported
|
|
348
|
+
4. **Token Caching**: Minimizes authentication requests
|
|
349
|
+
5. **Endpoint Blocking**: Dangerous endpoints are explicitly blocked
|
|
350
|
+
6. **Input Validation**: All inputs validated with Zod schemas
|
|
351
|
+
7. **Agent ID Validation**: Ensures valid agent ID format
|
|
352
|
+
|
|
353
|
+
## Best Practices
|
|
354
|
+
|
|
355
|
+
1. **Use Dedicated User**: Create a Wazuh API user with read-only permissions
|
|
356
|
+
2. **Monitor Access**: Review API access logs regularly
|
|
357
|
+
3. **Rotate Credentials**: Change API passwords periodically
|
|
358
|
+
4. **Limit Network Access**: Restrict API access to authorized hosts
|
|
359
|
+
5. **Use Pagination**: For large result sets, use limit/offset parameters
|
|
360
|
+
6. **Filter Results**: Use available filters to reduce data transfer
|
|
361
|
+
|
|
362
|
+
## API Compatibility
|
|
363
|
+
|
|
364
|
+
This server is compatible with Wazuh API v4.x. Tested with:
|
|
365
|
+
- Wazuh 4.7.0
|
|
366
|
+
- Wazuh 4.6.0
|
|
367
|
+
- Wazuh 4.5.0
|
|
368
|
+
|
|
369
|
+
## Troubleshooting
|
|
370
|
+
|
|
371
|
+
### Authentication Issues
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
# Test API connectivity
|
|
375
|
+
curl -k -u user:password -X POST https://your-wazuh-manager:55000/security/user/authenticate
|
|
376
|
+
|
|
377
|
+
# Verify credentials
|
|
378
|
+
echo $WAZUH_API_USER
|
|
379
|
+
echo $WAZUH_API_URL
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Connection Errors
|
|
383
|
+
|
|
384
|
+
- Ensure Wazuh API port (55000) is accessible
|
|
385
|
+
- Verify SSL certificate if using self-signed certificates
|
|
386
|
+
- Check firewall rules allow HTTPS traffic
|
|
387
|
+
|
|
388
|
+
### No Data Returned
|
|
389
|
+
|
|
390
|
+
- Verify agent is connected: Check with `wazuh_agent_list`
|
|
391
|
+
- Confirm data exists in Wazuh Manager
|
|
392
|
+
- Check date range filters are correct
|
|
393
|
+
- Verify user has read permissions
|
|
394
|
+
|
|
395
|
+
## Development
|
|
396
|
+
|
|
397
|
+
### Project Structure
|
|
398
|
+
|
|
399
|
+
```
|
|
400
|
+
wazuh/
|
|
401
|
+
├── package.json # Dependencies and scripts
|
|
402
|
+
├── tsconfig.json # TypeScript configuration
|
|
403
|
+
├── README.md # This file
|
|
404
|
+
└── src/
|
|
405
|
+
├── index.ts # Main server entry point
|
|
406
|
+
├── schemas.ts # Zod validation schemas
|
|
407
|
+
├── security.ts # Authentication and security
|
|
408
|
+
└── tools/
|
|
409
|
+
├── wazuh-agent-list.ts
|
|
410
|
+
├── wazuh-alert-search.ts
|
|
411
|
+
├── wazuh-vulnerability-list.ts
|
|
412
|
+
├── wazuh-sca-results.ts
|
|
413
|
+
├── wazuh-integrity-check.ts
|
|
414
|
+
├── wazuh-rule-list.ts
|
|
415
|
+
└── wazuh-stats.ts
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Building
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
bun run build
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Testing
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
# Set environment variables
|
|
428
|
+
export WAZUH_API_URL="https://your-wazuh-manager:55000"
|
|
429
|
+
export WAZUH_API_USER="test-user"
|
|
430
|
+
export WAZUH_API_PASSWORD="test-password"
|
|
431
|
+
|
|
432
|
+
# Run server
|
|
433
|
+
bun run start
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## License
|
|
437
|
+
|
|
438
|
+
MIT
|
|
439
|
+
|
|
440
|
+
## Contributing
|
|
441
|
+
|
|
442
|
+
Contributions are welcome! Please ensure:
|
|
443
|
+
1. All Zod schemas have `.describe()` on every field
|
|
444
|
+
2. Error handling is comprehensive
|
|
445
|
+
3. Documentation is updated
|
|
446
|
+
4. Security best practices are followed
|
|
447
|
+
|
|
448
|
+
## Support
|
|
449
|
+
|
|
450
|
+
For issues and questions:
|
|
451
|
+
- Wazuh Documentation: https://documentation.wazuh.com/
|
|
452
|
+
- Wazuh API Reference: https://documentation.wazuh.com/current/user-manual/api/reference.html
|
|
453
|
+
- MCP Documentation: https://modelcontextprotocol.io/
|
|
454
|
+
|
|
455
|
+
## Changelog
|
|
456
|
+
|
|
457
|
+
### 1.0.0
|
|
458
|
+
- Initial release
|
|
459
|
+
- 7 read-only tools for Wazuh integration
|
|
460
|
+
- JWT authentication with token caching
|
|
461
|
+
- Comprehensive error handling
|
|
462
|
+
- Security endpoint blocking
|