sigma-mcp-server 0.2.0__tar.gz

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.
Files changed (30) hide show
  1. sigma_mcp_server-0.2.0/LICENSE +21 -0
  2. sigma_mcp_server-0.2.0/PKG-INFO +368 -0
  3. sigma_mcp_server-0.2.0/README.md +337 -0
  4. sigma_mcp_server-0.2.0/pyproject.toml +71 -0
  5. sigma_mcp_server-0.2.0/sigma/mcp/__init__.py +0 -0
  6. sigma_mcp_server-0.2.0/sigma/mcp/config.py +71 -0
  7. sigma_mcp_server-0.2.0/sigma/mcp/coverage.py +218 -0
  8. sigma_mcp_server-0.2.0/sigma/mcp/data/windows_event_index.json +247 -0
  9. sigma_mcp_server-0.2.0/sigma/mcp/index.py +367 -0
  10. sigma_mcp_server-0.2.0/sigma/mcp/index_manager.py +358 -0
  11. sigma_mcp_server-0.2.0/sigma/mcp/knowledge/__init__.py +1 -0
  12. sigma_mcp_server-0.2.0/sigma/mcp/knowledge/correlation.py +257 -0
  13. sigma_mcp_server-0.2.0/sigma/mcp/knowledge/logsources.py +438 -0
  14. sigma_mcp_server-0.2.0/sigma/mcp/knowledge/specification.py +185 -0
  15. sigma_mcp_server-0.2.0/sigma/mcp/knowledge/windows_events.py +79 -0
  16. sigma_mcp_server-0.2.0/sigma/mcp/main.py +22 -0
  17. sigma_mcp_server-0.2.0/sigma/mcp/naming.py +137 -0
  18. sigma_mcp_server-0.2.0/sigma/mcp/pipelines.py +532 -0
  19. sigma_mcp_server-0.2.0/sigma/mcp/prompts.py +151 -0
  20. sigma_mcp_server-0.2.0/sigma/mcp/py.typed +0 -0
  21. sigma_mcp_server-0.2.0/sigma/mcp/reference_data.py +160 -0
  22. sigma_mcp_server-0.2.0/sigma/mcp/repo.py +175 -0
  23. sigma_mcp_server-0.2.0/sigma/mcp/resources.py +221 -0
  24. sigma_mcp_server-0.2.0/sigma/mcp/server.py +41 -0
  25. sigma_mcp_server-0.2.0/sigma/mcp/tools/__init__.py +1 -0
  26. sigma_mcp_server-0.2.0/sigma/mcp/tools/index.py +200 -0
  27. sigma_mcp_server-0.2.0/sigma/mcp/tools/pipelines.py +131 -0
  28. sigma_mcp_server-0.2.0/sigma/mcp/tools/rules.py +343 -0
  29. sigma_mcp_server-0.2.0/sigma/mcp/validation.py +188 -0
  30. sigma_mcp_server-0.2.0/sigma/mcp/workflows.py +181 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thomas Patzke
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,368 @@
1
+ Metadata-Version: 2.4
2
+ Name: sigma-mcp-server
3
+ Version: 0.2.0
4
+ Summary: MCP server for Sigma detection engineering: create, validate and search Sigma rules, and build and test processing pipelines with pySigma
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: sigma,mcp,detection engineering,siem,pysigma,security
8
+ Author: Thomas Patzke
9
+ Author-email: thomas@patzke.org
10
+ Requires-Python: <4.0,>=3.11
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Information Technology
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Security
21
+ Classifier: Typing :: Typed
22
+ Requires-Dist: fastmcp (>=4.1.1,<5.0.0)
23
+ Requires-Dist: httpx (>=0.27,<1.0.0)
24
+ Requires-Dist: pysigma (>=2.0.1,<3.0.0)
25
+ Requires-Dist: pyyaml (>=6.0,<7.0)
26
+ Project-URL: Homepage, https://github.com/SigmaHQ/sigma-mcp-server
27
+ Project-URL: Issues, https://github.com/SigmaHQ/sigma-mcp-server/issues
28
+ Project-URL: Repository, https://github.com/SigmaHQ/sigma-mcp-server
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Sigma MCP Server
32
+
33
+ An [MCP](https://modelcontextprotocol.io/) server that exposes
34
+ [pySigma](https://github.com/SigmaHQ/pySigma) functionality to AI assistants
35
+ and other MCP clients.
36
+
37
+ ## Features
38
+
39
+ ### Tools
40
+
41
+ | Tool | Description |
42
+ |---|---|
43
+ | `validate_rule` | Validate Sigma rules (YAML, several documents and correlation rules allowed) against all configured validators; returns detailed issue reports with severity levels |
44
+ | `configure_validators` | Persist a custom validator allow-list / exclusion-list for the current MCP session |
45
+ | `generate_uuid` | Generate a UUID v4 for a rule's `id` field |
46
+ | `get_logsource_info` | Suggest logsources for an activity, with fields, event IDs, tips and how SigmaHQ rules use them |
47
+ | `suggest_rule_filename` | Suggest a file name following the SigmaHQ conventions (logsource prefix, length, characters) and check it against existing SigmaHQ rules |
48
+ | `search_rules` | Search the SigmaHQ rule repository for rules similar to a detection idea |
49
+ | `get_rule` | Return the full YAML of a SigmaHQ rule by ID or path |
50
+ | `get_logsource_statistics` | Show how many SigmaHQ rules use each logsource and which fields they use most |
51
+ | `update_sigma_repository` | Download the latest SigmaHQ rules and rebuild the rule index in the background |
52
+ | `get_index_status` | Report the state of the SigmaHQ rule index |
53
+ | `validate_pipeline` | Validate a processing pipeline (YAML); returns errors, style warnings and a summary of its transformations |
54
+ | `apply_pipeline` | Apply one or more processing pipelines to a rule and show the result: field mappings, failures, state and the transformed detections |
55
+ | `analyze_pipeline_coverage` | Measure which SigmaHQ logsources and fields a processing pipeline supports, maps, rejects or leaves untouched |
56
+ | `list_resources` / `read_resource` | List and read every resource below, for clients that support tools but not resources |
57
+
58
+ ### Resources
59
+
60
+ | Resource | Description |
61
+ |---|---|
62
+ | `sigma://validators` | JSON dict mapping validator identifiers → human-readable descriptions |
63
+ | `sigma://modifiers` | JSON dict mapping modifier names (e.g. `contains`, `re`, `base64`) → descriptions |
64
+ | `sigma://logsources` | JSON array of valid Sigma log source combinations from the official specification |
65
+ | `sigma://fields/{category}` | JSON array of known field names for a Sigma log source category (e.g. `process_creation`) |
66
+ | `sigma://tags` | JSON dict mapping tag namespaces (e.g. `attack`, `cve`, `detection`) → descriptions |
67
+ | `sigma://specification` | Full Sigma Rules Specification document as Markdown |
68
+ | `sigma://specification/correlation` | Sigma Correlation Rules Specification as Markdown (offline reference if it cannot be fetched) |
69
+ | `sigma://events/windows` | JSON dict of documented Windows Security Auditing events grouped by log channel |
70
+ | `sigma://events/windows/{channel}/{event_id}` | Full Microsoft documentation for a specific Windows event as Markdown |
71
+ | `sigma://statistics/logsources` | JSON statistics of all logsources in the SigmaHQ rules: rule counts and field usage |
72
+ | `sigma://pipelines/transformations` | All processing pipeline transformations, conditions, postprocessing steps and finalizers with descriptions |
73
+
74
+ ### Prompts
75
+
76
+ | Prompt | Description |
77
+ |---|---|
78
+ | `create_sigma_rules` | Interactive workflow for creating Sigma rules: hypotheses, check SigmaHQ for existing rules, choose logsource and fields, draft, validate, save. Optional `task` argument |
79
+ | `create_processing_pipeline` | Interactive workflow for creating a processing pipeline: gather the environment, draft, validate, test with SigmaHQ rules, analyse coverage. Optional `task` argument |
80
+ | `create_sigma_rule_from_description` | Guide an LLM to create and validate a Sigma detection rule from a natural language description |
81
+ | `create_sigma_rules_from_url` | Guide an LLM to extract and validate Sigma rules from a blog post or threat report URL |
82
+
83
+ ## Requirements
84
+
85
+ - Python ≥ 3.11
86
+
87
+ ## Installation
88
+
89
+ The server is published on [PyPI](https://pypi.org/project/sigma-mcp-server/).
90
+ Run it without installing with [uv](https://docs.astral.sh/uv/):
91
+
92
+ ```bash
93
+ uvx sigma-mcp-server
94
+ ```
95
+
96
+ or install it with [pipx](https://pipx.pypa.io/) (or pip):
97
+
98
+ ```bash
99
+ pipx install sigma-mcp-server
100
+ ```
101
+
102
+ For development, see [Development](#development).
103
+
104
+ ## Usage
105
+
106
+ ### Running the server
107
+
108
+ ```bash
109
+ sigma-mcp-server
110
+ ```
111
+
112
+ The server listens on **stdio** by default (standard MCP transport).
113
+
114
+ ### Configuring in VS Code / Claude Desktop
115
+
116
+ Add the following entry to your MCP client configuration (e.g.
117
+ `~/.config/claude/claude_desktop_config.json`):
118
+
119
+ ```json
120
+ {
121
+ "mcpServers": {
122
+ "sigma": {
123
+ "command": "sigma-mcp-server"
124
+ }
125
+ }
126
+ }
127
+ ```
128
+
129
+ Adjust the `command` path to the installed binary if it is not on `PATH`.
130
+
131
+ ### Using with Claude Code
132
+
133
+ Register the server with Claude Code; `uvx` downloads and runs it:
134
+
135
+ ```bash
136
+ claude mcp add sigma -- uvx sigma-mcp-server
137
+ ```
138
+
139
+ If you installed it with pipx, use `claude mcp add sigma -- sigma-mcp-server`.
140
+
141
+ The workflows are available as commands in Claude Code:
142
+
143
+ - `/mcp__sigma__create_sigma_rules` creates Sigma rules from a description
144
+ or a threat report URL.
145
+ - `/mcp__sigma__create_processing_pipeline` builds a processing pipeline for
146
+ your SIEM.
147
+
148
+ Claude Code then uses the server's tools to search SigmaHQ, validate rules
149
+ and pipelines, test pipelines against SigmaHQ rules and measure coverage,
150
+ and its own tools to read URLs and write files.
151
+
152
+ ### Using the workflows in your own agent
153
+
154
+ The workflow prompts double as system prompts: fetch `create_sigma_rules` or
155
+ `create_processing_pipeline` without arguments and use the text as the
156
+ agent's instructions. Agents that cannot read MCP resources use the
157
+ `list_resources` and `read_resource` tools instead.
158
+
159
+ ### SigmaHQ rule index
160
+
161
+ `search_rules`, `get_rule`, `get_logsource_statistics` and
162
+ `sigma://statistics/logsources` work on a local index of the
163
+ [SigmaHQ rule repository](https://github.com/SigmaHQ/sigma).
164
+
165
+ When the server starts, it loads the index saved by an earlier run. If
166
+ there is none, or it is older than the maximum age, the server downloads the
167
+ rules from GitHub (all `rules*` directories) and rebuilds the index **in the
168
+ background**. The server answers requests at once: until the index is ready,
169
+ the index tools return an `index_status` and a `message` instead of results,
170
+ and `get_index_status` shows the progress. While an update runs, the
171
+ previous index stays in use. Several server processes share the data
172
+ directory; a lock file makes sure only one of them downloads at a time.
173
+
174
+ | Environment variable | Default | Description |
175
+ |---|---|---|
176
+ | `SIGMA_MCP_DATA_DIR` | user cache dir (`~/.cache/sigma-mcp-server`, `~/Library/Caches/sigma-mcp-server`, `%LOCALAPPDATA%\sigma-mcp-server`) | Where the downloaded rules (`sigma-rules/`) and the index (`index.json`) are stored |
177
+ | `SIGMA_MCP_INDEX_MAX_AGE_DAYS` | `7` | Rebuild the index at startup when it is older than this; `0` disables automatic updates |
178
+ | `SIGMA_MCP_NO_WARMUP` | unset | Set to `1` to skip loading/building the index at startup; a saved index is then loaded on first use, and `update_sigma_repository` builds one on demand |
179
+
180
+ The first download needs access to `codeload.github.com`.
181
+
182
+ ### MITRE ATT&CK and D3FEND data
183
+
184
+ The validators `attacktag` and `d3_fendtag` need the MITRE ATT&CK and D3FEND
185
+ data, which pySigma downloads once and caches (in `~/.cache/pysigma`). The
186
+ server loads it in the background at startup. Until it is available,
187
+ `validate_rule` skips these validators and reports a `ValidatorSkipped`
188
+ issue; after a failed download it tries again at most every 10 minutes.
189
+ `ValidatorSkipped` and `ValidatorError` issues are not problems with the
190
+ rule.
191
+
192
+ ### Processing pipelines
193
+
194
+ `validate_pipeline`, `apply_pipeline` and `analyze_pipeline_coverage` parse
195
+ pipelines with pySigma's safe policy: regular expressions use RE2, template
196
+ directories and external sources are refused. Template `vars` files, which
197
+ make pySigma execute Python code, are always refused, even when
198
+ `PYSIGMA_ALLOW_VARS_EXECUTION` is set.
199
+
200
+ `analyze_pipeline_coverage` runs the pipeline with pySigma on probe rules for
201
+ every logsource in the SigmaHQ rule index, and for every field used by at
202
+ least 5 % of that logsource's rules. It reports logsources as `covered`,
203
+ `uncovered` or `unsupported` (rejected by a `rule_failure`) and fields as
204
+ `mapped`, `unmapped`, `unsupported` (rejected by a `detection_item_failure`)
205
+ or `dropped`.
206
+
207
+ ---
208
+
209
+ ## Tool Reference
210
+
211
+ ### `validate_rule`
212
+
213
+ Validate one or more Sigma rules. Several rules go into one YAML string,
214
+ separated by `---`; a correlation rule should be accompanied by the rules it
215
+ references.
216
+
217
+ **Arguments**
218
+
219
+ | Name | Type | Description |
220
+ |---|---|---|
221
+ | `rule_yaml` | `string` | Complete Sigma rule(s) in YAML format |
222
+
223
+ **Returns**
224
+
225
+ A JSON array of validation issue objects. Each object contains:
226
+
227
+ | Key | Type | Description |
228
+ |---|---|---|
229
+ | `validator` | `string` | Validator identifier that produced the issue |
230
+ | `type` | `string` | Issue class name (e.g. `IdentifierExistenceIssue`) |
231
+ | `severity` | `string` | `low`, `medium`, or `high` |
232
+ | `description` | `string` | Human-readable description of the issue class |
233
+ | `rules` | `array[string]` | Rule IDs / titles affected by the issue |
234
+
235
+ Additional subclass-specific fields (e.g. `identifier`) may also be present.
236
+
237
+ Rules that cannot be parsed are reported with `validator: "parser"`,
238
+ `type: "SigmaParseError"` and the pySigma exception class in `error_class`;
239
+ they are not run through the validators.
240
+
241
+ An **empty array** means the rule passed all active validators.
242
+
243
+ ---
244
+
245
+ ### `configure_validators`
246
+
247
+ Persist a custom validator configuration for the current MCP session.
248
+ All subsequent `validate_rule` calls within the same session will use this
249
+ configuration.
250
+
251
+ **Arguments**
252
+
253
+ | Name | Type | Default | Description |
254
+ |---|---|---|---|
255
+ | `validator_names` | `array[string] \| null` | `null` | Explicit allow-list of validator identifiers. `null` = use all. |
256
+ | `exclusions` | `array[string] \| null` | `null` (= `[]`) | Validator identifiers to exclude after the allow-list is applied. |
257
+
258
+ **Returns**
259
+
260
+ On success: `{"validator_names": ..., "exclusions": [...]}` confirming the stored config.
261
+ On error: `{"error": "<description>"}` when an unknown identifier is supplied.
262
+
263
+ **Example – exclude a single validator:**
264
+
265
+ ```json
266
+ {"exclusions": ["identifier_existence"]}
267
+ ```
268
+
269
+ **Example – use only two validators:**
270
+
271
+ ```json
272
+ {"validator_names": ["identifier_existence", "identifier_uniqueness"]}
273
+ ```
274
+
275
+ ---
276
+
277
+ ## Resource Reference
278
+
279
+ ### `sigma://validators`
280
+
281
+ Returns a JSON object mapping validator identifier strings to their
282
+ human-readable descriptions. Validator identifiers are used with
283
+ `configure_validators`.
284
+
285
+ **Example response (truncated):**
286
+
287
+ ```json
288
+ {
289
+ "identifier_existence": "Checks if rule has identifier.",
290
+ "identifier_uniqueness": "Check rule UUID uniqueness.",
291
+ ...
292
+ }
293
+ ```
294
+
295
+ ### `sigma://modifiers`
296
+
297
+ Returns a sorted JSON array of Sigma value modifier names that can be used in
298
+ detection conditions (e.g. `contains`, `startswith`, `re`, `base64`).
299
+
300
+ ---
301
+
302
+ ## Development
303
+
304
+ Development uses [Poetry](https://python-poetry.org/):
305
+
306
+ ```bash
307
+ git clone https://github.com/SigmaHQ/sigma-mcp-server
308
+ cd sigma-mcp-server
309
+ poetry install
310
+
311
+ # Run the server from the checkout
312
+ poetry run sigma-mcp-server
313
+
314
+ # Run tests
315
+ poetry run pytest
316
+
317
+ # Run tests with coverage report
318
+ poetry run pytest --cov=sigma/mcp --cov-report=term-missing
319
+
320
+ # Type checking
321
+ poetry run mypy sigma/mcp/ tests/
322
+
323
+ # Code formatting
324
+ poetry run black sigma/ tests/ conftest.py
325
+ ```
326
+
327
+ Test coverage must remain ≥ 95 %. All code must pass `mypy --strict` and be
328
+ formatted with `black` in its default configuration.
329
+
330
+ The GitHub workflow `tests.yml` runs these checks on Python 3.11, 3.12 and
331
+ 3.13 for every pull request.
332
+
333
+ ### Releasing
334
+
335
+ Releases have two stages, as in pySigma:
336
+
337
+ 1. Set the new version in `pyproject.toml` (`poetry version <version>`) and
338
+ merge it into `main`.
339
+ 2. Push the tag `v<version>` (e.g. `git tag v0.2.0 && git push origin v0.2.0`).
340
+ The workflow `release.yml` checks that the tag matches the package
341
+ version, runs the checks, builds the package and publishes it to
342
+ [TestPyPI](https://test.pypi.org/project/sigma-mcp-server/). Try it in a
343
+ fresh virtual environment (dependencies come from PyPI):
344
+
345
+ ```bash
346
+ python -m venv /tmp/sigma-mcp-test
347
+ /tmp/sigma-mcp-test/bin/pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ sigma-mcp-server==<version>
348
+ ```
349
+
350
+ 3. Create and publish a GitHub release for that tag. The workflow builds
351
+ the package again and publishes it to [PyPI](https://pypi.org/project/sigma-mcp-server/).
352
+
353
+ Creating a GitHub release together with a new tag runs both stages at the
354
+ same time; push the tag first to test the package before releasing it.
355
+
356
+ Uploads use [trusted publishing](https://docs.pypi.org/trusted-publishers/),
357
+ so no API token is stored. One-time setup:
358
+
359
+ - on test.pypi.org and on pypi.org, add a trusted publisher for the
360
+ repository `SigmaHQ/sigma-mcp-server` with the workflow `release.yml` and
361
+ the environment `testpypi` or `pypi` respectively;
362
+ - in the repository settings, create the environments `testpypi` and `pypi`
363
+ (optionally with required reviewers for `pypi`).
364
+
365
+ ## License
366
+
367
+ MIT
368
+