suricata-mcp 2.0.0 → 3.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 CHANGED
@@ -1,78 +1,88 @@
1
- # Suricata MCP Server
1
+ <p align="center">
2
+ <img src="docs/assets/suricata-mcp-social-preview.jpg" alt="suricata-mcp banner" width="900">
3
+ </p>
2
4
 
3
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue?logo=typescript)](https://www.typescriptlang.org/)
4
- [![Node.js](https://img.shields.io/badge/Node.js-20%2B-green?logo=node.js)](https://nodejs.org/)
5
- [![MCP](https://img.shields.io/badge/MCP-1.x-purple)](https://modelcontextprotocol.io/)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
+ <p align="center">
6
+ <a href="https://lidless.dev"><img src="docs/assets/marks/suricata-mcp-circle.png" width="48" alt="Lidless Labs"></a>
7
+ </p>
8
+ <h1 align="center">suricata-mcp</h1>
7
9
 
8
- An MCP (Model Context Protocol) server for network security monitoring. Provides intelligent analysis of Suricata IDS/IPS and Zeek NSM logs, cross-correlation between sensors, threat intelligence integration (MISP + TheHive), PCAP replay, and advanced analytics including DGA detection, C2 beaconing, data exfiltration, and lateral movement detection.
10
+ <p align="center">
11
+ <strong>An MCP server that lets an AI client read and triage Suricata IDS/IPS and Zeek NSM telemetry, so alert investigation happens in natural language instead of grep over EVE JSON.</strong>
12
+ </p>
9
13
 
10
- ## Features
14
+ <p align="center">
15
+ <a href="https://lidless.dev/suricata-mcp"><strong>Website &amp; docs -&gt; lidless.dev/suricata-mcp</strong></a>
16
+ </p>
11
17
 
12
- - **36 tools** for comprehensive network security analysis
13
- - **5 resources** for quick reference data
14
- - **5 prompts** for guided investigation workflows
15
- - **Suricata EVE JSON** alert querying, flow analysis, protocol inspection, rule management
16
- - **Zeek TSV logs** connection analysis, DNS/HTTP/TLS/SSH/file inspection
17
- - **Cross-correlation** between Suricata alerts and Zeek network metadata
18
- - **Threat intel** integration with MISP IOC lookup and TheHive case/alert creation
19
- - **PCAP management** list and replay PCAPs through Suricata or Zeek
20
- - **Advanced analytics** DGA detection, C2 beaconing, data exfiltration, lateral movement
21
- - **Rule management** create, enable/disable, and reload custom Suricata rules
22
- - Streaming parsers for large files, CIDR-aware filtering, gzip archive support
18
+ <p align="center">
19
+ <img src="https://shieldcn.dev/github/ci/lidless-labs/suricata-mcp.svg?branch=main&workflow=ci.yml" alt="CI status">
20
+ <img src="https://shieldcn.dev/npm/suricata-mcp.svg" alt="npm version">
21
+ <img src="https://shieldcn.dev/badge/MCP-server-8A2BE2.svg" alt="MCP server">
22
+ <img src="https://shieldcn.dev/badge/license-MIT-green.svg" alt="MIT license">
23
+ </p>
23
24
 
24
- ## Prerequisites
25
+ suricata-mcp is a Model Context Protocol (MCP) server for network security monitoring: it exposes Suricata IDS/IPS alerts and Zeek NSM logs to an AI client as structured tools. **Why:** a SOC analyst chasing a single alert normally pivots by hand across `eve.json`, flow records, DNS/HTTP/TLS transactions, and the Zeek logs next to them, which is slow and easy to get wrong under pressure. **How it differs:** instead of a dashboard or a one-shot log shipper, it gives the model query, aggregation, correlation, and threat-hunting tools that run locally against your own log files, with cross-correlation between Suricata and Zeek and built-in analytics for C2 beaconing, DGA, exfiltration, and lateral movement, so the analyst asks questions in plain language and the model does the pivoting.
25
26
 
26
- - Node.js 20+
27
- - Suricata sensor producing EVE JSON logs
28
- - (Optional) Zeek NSM with TSV log output
29
- - (Optional) MISP and/or TheHive instances for threat intel
27
+ ## What it does
28
+
29
+ suricata-mcp is an MCP server for **Suricata** IDS/IPS and **Zeek** network-security monitoring. It reads Suricata **EVE JSON** alerts, flows, and protocol records (DNS, HTTP, TLS/JA3/JA4, SSH, fileinfo, anomalies) and Zeek TSV or JSON logs straight off disk, then exposes them to an AI client as MCP tools for querying, aggregation, timelines, host and alert investigation, and cross-sensor correlation. On top of the raw telemetry it ships intrusion-detection analytics, C2 beaconing detection, DGA domain detection via Shannon entropy, data-exfiltration detection, and lateral-movement detection, plus Suricata rule management and optional threat-intel pivots into MISP and TheHive. Zeek JSON records omit unset fields by default, while unset fields in TSV records are returned as empty strings.
30
+
31
+ The server is **read-only by default**: every analysis tool works out of the box, and the handful of tools that change a live IDS or shell out stay disabled until you explicitly opt in. It speaks MCP over stdio, so it drops into Claude Desktop, Claude Code, Codex CLI, OpenClaw, Hermes, or any MCP-capable agent.
30
32
 
31
33
  ## Installation
32
34
 
35
+ Most clients can run the published package directly with `npx -y suricata-mcp` (see [Quickstart](#quickstart)). To work from source instead:
36
+
33
37
  ```bash
34
- git clone https://github.com/solomonneas/suricata-mcp.git
38
+ git clone https://github.com/lidless-labs/suricata-mcp.git
35
39
  cd suricata-mcp
36
40
  npm install
37
41
  npm run build
38
42
  ```
39
43
 
40
- ## Configuration
44
+ ## Quickstart
41
45
 
42
- Set environment variables to point at your NIDS installation:
46
+ Add suricata-mcp to any MCP client with the published npm package. No clone or build required:
43
47
 
44
- | Variable | Default | Description |
45
- |----------|---------|-------------|
46
- | `SURICATA_EVE_LOG` | `/var/log/suricata/eve.json` | Path to primary EVE JSON log |
47
- | `SURICATA_EVE_ARCHIVE` | `/var/log/suricata/` | Directory for rotated/archived logs |
48
- | `SURICATA_RULES_DIR` | _(none)_ | Suricata rules directory |
49
- | `SURICATA_MAX_RESULTS` | `1000` | Maximum results per query |
50
- | `SURICATA_UNIX_SOCKET` | _(none)_ | Unix socket path for live commands |
51
- | `ZEEK_LOGS_DIR` | _(none)_ | Zeek log directory (enables Zeek tools) |
52
- | `PCAP_DIR` | _(none)_ | PCAP drop directory (enables PCAP tools) |
53
- | `MISP_URL` | _(none)_ | MISP instance URL |
54
- | `MISP_API_KEY` | _(none)_ | MISP API key |
55
- | `THEHIVE_URL` | _(none)_ | TheHive instance URL |
56
- | `THEHIVE_API_KEY` | _(none)_ | TheHive API key |
48
+ ```json
49
+ {
50
+ "mcpServers": {
51
+ "suricata": {
52
+ "command": "npx",
53
+ "args": ["-y", "suricata-mcp"],
54
+ "env": {
55
+ "SURICATA_EVE_LOG": "/var/log/suricata/eve.json",
56
+ "SURICATA_RULES_DIR": "/etc/suricata/rules",
57
+ "ZEEK_LOGS_DIR": "/opt/zeek/logs"
58
+ }
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ That is the entire install. The server starts read-only against the logs you point it at. Everything below is configuration detail and per-client wiring.
57
65
 
58
66
  ## Usage
59
67
 
60
68
  ### Claude Desktop
61
69
 
70
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
71
+
62
72
  ```json
63
73
  {
64
74
  "mcpServers": {
65
75
  "suricata": {
66
- "command": "node",
67
- "args": ["/path/to/suricata-mcp/dist/index.js"],
76
+ "command": "npx",
77
+ "args": ["-y", "suricata-mcp"],
68
78
  "env": {
69
79
  "SURICATA_EVE_LOG": "/opt/nids/suricata/logs/eve.json",
70
80
  "SURICATA_RULES_DIR": "/opt/nids/suricata/rules",
71
81
  "ZEEK_LOGS_DIR": "/opt/nids/zeek/logs",
72
82
  "PCAP_DIR": "/opt/nids/pcaps",
73
- "MISP_URL": "https://misp.local",
83
+ "MISP_URL": "https://misp.example.com",
74
84
  "MISP_API_KEY": "your-key",
75
- "THEHIVE_URL": "http://thehive.local:9000",
85
+ "THEHIVE_URL": "https://thehive.example.com",
76
86
  "THEHIVE_API_KEY": "your-key"
77
87
  }
78
88
  }
@@ -80,6 +90,119 @@ Set environment variables to point at your NIDS installation:
80
90
  }
81
91
  ```
82
92
 
93
+ If you installed from source, set `"command": "suricata-mcp"` (global npm install) or `"command": "node"` with `"args": ["/absolute/path/to/suricata-mcp/dist/index.js"]`.
94
+
95
+ ### Claude Code
96
+
97
+ ```bash
98
+ claude mcp add suricata \
99
+ --env SURICATA_EVE_LOG=/opt/nids/suricata/logs/eve.json \
100
+ --env SURICATA_RULES_DIR=/opt/nids/suricata/rules \
101
+ --env ZEEK_LOGS_DIR=/opt/nids/zeek/logs \
102
+ -- npx -y suricata-mcp
103
+ ```
104
+
105
+ Add `--scope user` to make it available from any directory instead of only the current project.
106
+
107
+ ### OpenClaw
108
+
109
+ If you're running from a source checkout instead of the npm-installed binary, point `command`/`args` at the built `dist/index.js`:
110
+
111
+ ```bash
112
+ openclaw mcp set suricata '{
113
+ "command": "node",
114
+ "args": ["/absolute/path/to/suricata-mcp/dist/index.js"],
115
+ "env": {
116
+ "SURICATA_EVE_LOG": "/opt/nids/suricata/logs/eve.json",
117
+ "SURICATA_RULES_DIR": "/opt/nids/suricata/rules",
118
+ "ZEEK_LOGS_DIR": "/opt/nids/zeek/logs"
119
+ }
120
+ }'
121
+ ```
122
+
123
+ Or, with the published package:
124
+
125
+ ```bash
126
+ openclaw mcp set suricata '{
127
+ "command": "npx",
128
+ "args": ["-y", "suricata-mcp"],
129
+ "env": {
130
+ "SURICATA_EVE_LOG": "/opt/nids/suricata/logs/eve.json",
131
+ "SURICATA_RULES_DIR": "/opt/nids/suricata/rules",
132
+ "ZEEK_LOGS_DIR": "/opt/nids/zeek/logs"
133
+ }
134
+ }'
135
+ ```
136
+
137
+ Then restart the OpenClaw gateway so the new server is picked up:
138
+
139
+ ```bash
140
+ systemctl --user restart openclaw-gateway
141
+ openclaw mcp list # confirm "suricata" is registered
142
+ ```
143
+
144
+ ### Hermes Agent
145
+
146
+ [Hermes Agent](https://github.com/NousResearch/hermes-agent) reads MCP config from `~/.hermes/config.yaml` under the `mcp_servers` key. Add an entry:
147
+
148
+ ```yaml
149
+ mcp_servers:
150
+ suricata:
151
+ command: "npx"
152
+ args: ["-y", "suricata-mcp"]
153
+ env:
154
+ SURICATA_EVE_LOG: "/opt/nids/suricata/logs/eve.json"
155
+ SURICATA_RULES_DIR: "/opt/nids/suricata/rules"
156
+ ZEEK_LOGS_DIR: "/opt/nids/zeek/logs"
157
+ ```
158
+
159
+ Or, when running from a source checkout instead of the published package:
160
+
161
+ ```yaml
162
+ mcp_servers:
163
+ suricata:
164
+ command: "node"
165
+ args: ["/absolute/path/to/suricata-mcp/dist/index.js"]
166
+ env:
167
+ SURICATA_EVE_LOG: "/opt/nids/suricata/logs/eve.json"
168
+ SURICATA_RULES_DIR: "/opt/nids/suricata/rules"
169
+ ZEEK_LOGS_DIR: "/opt/nids/zeek/logs"
170
+ ```
171
+
172
+ Then reload MCP from inside a Hermes session:
173
+
174
+ ```
175
+ /reload-mcp
176
+ ```
177
+
178
+ ### Codex CLI
179
+
180
+ [Codex CLI](https://github.com/openai/codex) registers MCP servers via `codex mcp add`:
181
+
182
+ ```bash
183
+ codex mcp add suricata \
184
+ --env SURICATA_EVE_LOG=/opt/nids/suricata/logs/eve.json \
185
+ --env SURICATA_RULES_DIR=/opt/nids/suricata/rules \
186
+ --env ZEEK_LOGS_DIR=/opt/nids/zeek/logs \
187
+ -- npx -y suricata-mcp
188
+ ```
189
+
190
+ Or, when running from a source checkout:
191
+
192
+ ```bash
193
+ codex mcp add suricata \
194
+ --env SURICATA_EVE_LOG=/opt/nids/suricata/logs/eve.json \
195
+ --env SURICATA_RULES_DIR=/opt/nids/suricata/rules \
196
+ --env ZEEK_LOGS_DIR=/opt/nids/zeek/logs \
197
+ -- node /absolute/path/to/suricata-mcp/dist/index.js
198
+ ```
199
+
200
+ Codex writes the entry to `~/.codex/config.toml` under `[mcp_servers.suricata]`. Verify with:
201
+
202
+ ```bash
203
+ codex mcp list
204
+ ```
205
+
83
206
  ### Standalone
84
207
 
85
208
  ```bash
@@ -136,13 +259,19 @@ npm run lint # Type-check
136
259
  | `suricata_toggle_rule` | Enable or disable a rule by SID |
137
260
  | `suricata_reload_rules_docker` | Reload rules via Docker (suricata-update + SIGUSR2) |
138
261
 
139
- ### Suricata Engine & Live Commands (3 tools)
262
+ ### Suricata Engine & Live Commands (7 tools)
140
263
 
141
264
  | Tool | Description |
142
265
  |------|-------------|
143
266
  | `suricata_engine_stats` | Capture, decoder, detect, and flow statistics |
144
267
  | `suricata_reload_rules` | Live rule reload via Unix socket |
145
268
  | `suricata_iface_stat` | Interface capture statistics via Unix socket |
269
+ | `suricata_uptime` | Engine uptime via Unix socket |
270
+ | `suricata_ruleset_stats` | Loaded and failed ruleset counts via Unix socket |
271
+ | `suricata_ruleset_failed_rules` | Failed rule text from the engine via Unix socket |
272
+ | `suricata_dump_counters` | Performance counters via Unix socket |
273
+
274
+ Socket responses are untrusted data. The shared output envelope caps large results; check `_provenance.truncated` to see whether any output was omitted.
146
275
 
147
276
  ### Suricata Investigation (2 tools)
148
277
 
@@ -195,6 +324,77 @@ npm run lint # Type-check
195
324
  | `thehive_create_case` | Create a TheHive case from investigation findings |
196
325
  | `thehive_create_alert` | Push a Suricata alert to TheHive for triage |
197
326
 
327
+ ## Configuration
328
+
329
+ Set environment variables to point at your NIDS installation:
330
+
331
+ | Variable | Default | Description |
332
+ |----------|---------|-------------|
333
+ | `SURICATA_EVE_LOG` | `/var/log/suricata/eve.json` | Path to primary EVE JSON log |
334
+ | `SURICATA_EVE_ARCHIVE` | `/var/log/suricata/` | Directory for rotated/archived logs |
335
+ | `SURICATA_RULES_DIR` | _(none)_ | Suricata rules directory |
336
+ | `SURICATA_MAX_RESULTS` | `1000` | Maximum results per query |
337
+ | `SURICATA_UNIX_SOCKET` | _(none)_ | Unix socket path for live commands |
338
+ | `ZEEK_LOGS_DIR` | _(none)_ | Zeek log directory (enables Zeek tools) |
339
+ | `ZEEK_LOG_FORMAT` | `auto` | Zeek log format: `auto` detects each file, or force `json` / `tsv`; values are trimmed and case-insensitive, and invalid values fall back to `auto` |
340
+ | `PCAP_DIR` | _(none)_ | PCAP drop directory (enables PCAP tools) |
341
+ | `MISP_URL` | _(none)_ | MISP instance URL |
342
+ | `MISP_API_KEY` | _(none)_ | MISP API key |
343
+ | `THEHIVE_URL` | _(none)_ | TheHive instance URL |
344
+ | `THEHIVE_API_KEY` | _(none)_ | TheHive API key |
345
+ | `SURICATA_ALLOW_MUTATION` | _(off)_ | Set to `1` to enable mutating tools (rule writes, ruleset reload, PCAP replay, TheHive creation). Off by default. |
346
+
347
+ ### Mutating tools (opt-in)
348
+
349
+ By default the server is read-only: every analysis/query tool works, but the
350
+ tools that change a live IDS or shell out are disabled. To enable them you must:
351
+
352
+ 1. Set `SURICATA_ALLOW_MUTATION=1` in the server environment (operator opt-in), **and**
353
+ 2. Pass `confirm: true` on the tool call itself (per-invocation opt-in).
354
+
355
+ Both guards must be satisfied. Otherwise the tool returns an error without
356
+ acting. The gated tools are:
357
+
358
+ - `suricata_create_rule` - appends to `local.rules`. Also enforces a
359
+ local SID range (`sid >= 1000000`) and rejects SIDs that collide with the
360
+ loaded ruleset. Rule text must be a single line with no newline or carriage
361
+ return characters.
362
+ - `suricata_toggle_rule` - enables or disables a rule by SID in `local.rules`.
363
+ - `suricata_reload_rules` - reloads rules through the Unix socket.
364
+ - `thehive_create_case` / `thehive_create_alert` - creates a case or alert in TheHive.
365
+ - `suricata_reload_rules_docker` - runs `suricata-update` + `SIGUSR2` against the
366
+ live container.
367
+ - `pcap_replay_suricata` / `pcap_replay_zeek` - replay a PCAP through the engine.
368
+ Filenames must be a bare name of letters, digits, `.`, `-`, and `_` (anything
369
+ else is rejected), are rejected if they begin with `-` (option-injection), and
370
+ concurrent replays are capped. Docker is invoked with argv arrays, never a
371
+ shell.
372
+
373
+ Threat-intel HTTP calls (MISP/TheHive) use `redirect: "manual"`, so a 3xx from a
374
+ compromised or misconfigured endpoint is refused rather than followed with the
375
+ API key attached.
376
+
377
+ ## Features
378
+
379
+ - **45 tools** for network security analysis
380
+ - **5 resources** for quick reference data
381
+ - **5 prompts** for guided investigation workflows
382
+ - **Suricata EVE JSON** alert querying, flow analysis, protocol inspection, rule management
383
+ - **Zeek TSV or JSON logs** connection analysis, DNS/HTTP/TLS/SSH/file inspection
384
+ - **Cross-correlation** between Suricata alerts and Zeek network metadata
385
+ - **Threat intel** integration with MISP IOC lookup and TheHive case/alert creation
386
+ - **PCAP management** list and replay PCAPs through Suricata or Zeek
387
+ - **Advanced analytics** DGA detection, C2 beaconing, data exfiltration, lateral movement
388
+ - **Rule management** create, enable/disable, and reload custom Suricata rules
389
+ - Streaming parsers for large files, CIDR-aware filtering, gzip archive support
390
+
391
+ ## Prerequisites
392
+
393
+ - Node.js 22+
394
+ - Suricata sensor producing EVE JSON logs
395
+ - (Optional) Zeek NSM with TSV or JSON log output
396
+ - (Optional) MISP and/or TheHive instances for threat intel
397
+
198
398
  ## Resources
199
399
 
200
400
  | URI | Description |
@@ -226,7 +426,7 @@ suricata-mcp/
226
426
  parser/
227
427
  eve.ts # Streaming EVE JSON parser (supports .gz)
228
428
  rules.ts # Suricata rule file parser
229
- zeek.ts # Zeek TSV log parser with header handling
429
+ zeek.ts # Zeek TSV and JSON log parser
230
430
  query/
231
431
  engine.ts # Query engine for EVE files
232
432
  filters.ts # CIDR, wildcard, time range, IP matching
@@ -279,6 +479,20 @@ suricata-mcp/
279
479
  generate-eve.ts # Mock EVE data generator
280
480
  ```
281
481
 
482
+ ## Why not query the logs directly?
483
+
484
+ - **`jq` / `grep` over `eve.json`.** Fine for one field on one file. It does not cross-correlate a Suricata alert with the Zeek `conn`/`dns`/`http`/`ssl` records for the same IP pair and time window, it does not compute beaconing intervals or DNS entropy, and it does not hand an LLM a typed tool surface. suricata-mcp does all of that and streams large, gzip-rotated logs without loading them whole.
485
+ - **A full SIEM (Splunk, Elastic, Wazuh).** A SIEM is the right home for long-term retention, dashboards, and multi-source alerting. suricata-mcp lets an agent inspect the Suricata and Zeek logs already on a sensor, without maintaining an index or running another service.
486
+ - **A generic log-tailing MCP server.** Those stream raw lines. suricata-mcp understands EVE JSON and Zeek TSV/JSON schemas, so it filters by SID, signature, JA3/JA4, MIME type, and CIDR, aggregates top talkers and protocol distributions, and returns structured results an agent can act on instead of text blobs.
487
+ - **Writing your own MCP wrapper.** You could, but you would re-implement streaming EVE/Zeek parsers, CIDR-aware filtering, the analytics, the dual mutation guard, and the redirect-refusing threat-intel client. That work is already done and tested here.
488
+
489
+ ## What suricata-mcp is not
490
+
491
+ - **Not a packet capture or IDS engine.** It does not sniff traffic or run detection. Suricata (and optionally Zeek) produce the logs. This server reads them.
492
+ - **Not a SIEM, log store, or dashboard.** No retention, no UI, no indexing. It analyzes the logs that already exist on disk.
493
+ - **Not write-happy.** By default it cannot modify your ruleset, reload the engine, or replay a PCAP. Mutating tools require both an operator environment opt-in and a per-call `confirm: true`.
494
+ - **Not a hosted service.** It runs locally over stdio against your own files. Nothing is sent anywhere except the optional, explicit MISP/TheHive calls you configure.
495
+
282
496
  ## Testing
283
497
 
284
498
  ```bash
@@ -286,6 +500,18 @@ npm test # Run all 158 tests
286
500
  npm run test:watch # Watch mode
287
501
  ```
288
502
 
503
+ ## Contributing
504
+
505
+ Issues and pull requests are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for the contribution path and [SECURITY.md](SECURITY.md) before reporting a vulnerability. By participating you agree to the [Code of Conduct](CODE_OF_CONDUCT.md).
506
+
289
507
  ## License
290
508
 
291
- MIT
509
+ [MIT](LICENSE)
510
+
511
+ ---
512
+
513
+ <p align="center"><a href="https://lidless.dev">Part of <strong>Lidless Labs</strong></a> &middot; the eye does not close</p>
514
+
515
+ <p align="center"><sub><strong>Security / SOC:</strong> <a href="https://github.com/lidless-labs/soc-stack">soc-stack</a> &middot; <a href="https://github.com/lidless-labs/wazuh-mcp">wazuh-mcp</a> &middot; <a href="https://github.com/lidless-labs/misp-mcp">misp-mcp</a> &middot; <a href="https://github.com/lidless-labs/thehive-mcp">thehive-mcp</a> &middot; <a href="https://github.com/lidless-labs/cortex-mcp">cortex-mcp</a> &middot; <a href="https://github.com/lidless-labs/mitre-mcp">mitre-mcp</a> &middot; <a href="https://github.com/lidless-labs/zeek-mcp">zeek-mcp</a> &middot; <a href="https://github.com/lidless-labs/hotwash">hotwash</a></sub></p>
516
+
517
+ <p align="center"><sub><a href="https://lidless.dev">All tools</a> &middot; <a href="https://github.com/lidless-labs">Lidless Labs on GitHub</a></sub></p>