rsigma mcp serve

rsigma mcp serve

Added in v0.16.0

Run the Model Context Protocol server, exposing the RSigma Sigma toolchain (parse, lint, validate, evaluate, convert, reverse-convert, tune, test exemplars, fields, pipelines) as MCP tools to AI agents such as Cursor and Claude Code.

Synopsis

rsigma mcp serve [OPTIONS]

The server speaks JSON-RPC over stdio: stdin and stdout are the transport, so all human-readable diagnostics go to stderr. Run it under an MCP client rather than interactively.

Description

mcp serve starts a stdio MCP server backed by the same crates the CLI uses. An agent connects, calls tools/list to discover the tool surface, and calls tools with either inline content (e.g. yaml or query) or a file path. Tool outputs are structured JSON: ASTs, lint findings with spans and fix availability, evaluation matches, backend queries, reverse-converted drafts, and field inventories.

For the full tool reference, client setup, and the agentic write-lint-evaluate loop, see the MCP server guide.

The command is gated behind the opt-in mcp Cargo feature: build from source with --features mcp. The prebuilt binaries and Docker image (built with --all-features) include it. See Feature Flags.

Flags

Flag Default Description
--config <PATH> discovery Load only this YAML config file instead of the discovery chain. Unlike a discovered project file, it may set the security-sensitive mcp.* keys (see Project config trust). CLI flags still override its values. Unreleased
--lint-config <PATH> lint defaults A lint config file (.rsigma-lint.yml) applied by the lint_rules tool (disabled rules, severity overrides, extra tag namespaces). Config key: mcp.lint_config.
--rules-dir <PATH> none Root directory for path arguments in tool calls. Relative paths resolve against it, and any path that leaves it (absolute, ../, or through a symlink) is refused. Without it, tools can read any file the server’s OS user can read, fix_rules cannot write, --http refuses to start, and stdio prints a startup warning. Config key: mcp.rules_dir.
--allow-unconfined-paths off Run without --rules-dir, leaving path arguments unconfined. Required to serve --http without a root; on stdio it silences the startup warning. fix_rules still cannot write without a root. Config key: mcp.allow_unconfined_paths. Added in v0.25.0
--allow-sigma-cli off Allow the convert_rules tool to delegate targets without a native backend to an installed sigma-cli, reaching the full pySigma backend set. Delegated calls spawn a subprocess (60s timeout, at most 2 concurrent); path and file-based pipelines inputs stay confined to --rules-dir when it is set. Config key: mcp.allow_sigma_cli.
--daemon-url <URL> none Base URL of a running rsigma daemon (http://127.0.0.1:9090). Registers the Operate-cycle read tools against that API. Unix-socket URLs are unsupported; use TCP loopback. Config key: mcp.daemon_url. Added in v0.22.0
--daemon-ca <PATH> none Extra root CA (PEM) for a self-signed daemon TLS listener. Config key: mcp.daemon_ca. Added in v0.22.0
--daemon-token <TOKEN> none Bearer token sent to the daemon as Authorization: Bearer <token>. Also read from RSIGMA_MCP_DAEMON_TOKEN. Flag/env only: secrets are never read from config files. Added in v0.22.0
--allow-operate-writes off Register create_silence and post_disposition. Requires --daemon-url. Config key: mcp.allow_operate_writes. Added in v0.22.0
--http <ADDR> stdio Serve over the Streamable HTTP transport on this address (e.g. 127.0.0.1:9100) instead of stdio. The MCP endpoint is mounted at /mcp. Config key: mcp.http_addr.
--auth-token <TOKEN> none Require this static bearer token on every HTTP request (Authorization: Bearer <token>); requests without it get 401. Also read from RSIGMA_MCP_AUTH_TOKEN. Flag/env only: secrets are never read from config files.
--allow-unauthenticated off Serve --http on a non-loopback address without --auth-token. Without it, such a bind refuses to start, because anyone who can reach the port could call every tool. Loopback binds never need it. Flag only. Unreleased
--allowed-host <HOST> see below Accept this Host header value (a host name or host:port) on the HTTP transport. Repeatable. Adds to localhost, 127.0.0.1, ::1, and a specific bind IP; other hosts get 403. Without it, a non-loopback bind with --auth-token accepts any host. Flag only. Unreleased
--allow-plaintext off Allow binding plaintext HTTP on a non-loopback address without TLS. Loopback binds never need it.
--tls-cert <PATH> none TLS certificate (PEM) for the HTTP transport. Requires --tls-key and a build with the daemon-tls feature.
--tls-key <PATH> none TLS private key (PEM) for the HTTP transport. Requires --tls-cert.

--http, --lint-config, --rules-dir, --allow-unconfined-paths, --allow-sigma-cli, --daemon-url, --daemon-ca, and --allow-operate-writes also resolve from the layered config (mcp section) and the RSIGMA_MCP__* environment layer; the MCP HTTP auth token and the daemon token stay flag/env-only.

The global flags (--log-format, --quiet, …) are accepted but stdout stays reserved for the MCP transport; use --log-format to send structured diagnostics to stderr.

Tools

Tool Purpose
parse_rule Parse Sigma YAML (rules, correlations, filters) to AST JSON.
parse_condition Parse a condition expression to a parse-tree.
lint_rules Lint rules; findings carry rule id, severity, line, and fix availability.
validate_rules Parse + compile + correlation checks, optional pipelines, source resolution, and fail_level.
evaluate_events Run events against rules (detections and correlations).
convert_rules Convert rules to a backend query (postgres/lynxdb/fibratus natively; other targets via sigma-cli with --allow-sigma-cli).
reverse_convert Reverse-convert a SIEM query (dialect: lucene) into a draft Sigma rule (YAML).
list_backends List conversion targets and their formats (plus installed sigma-cli targets with --allow-sigma-cli).
list_fields List the event fields rules reference, with provenance.
resolve_pipeline Inspect a builtin or file pipeline; optionally resolve dynamic sources.
list_builtin_pipelines List the builtin pipelines (ecs_windows, fibratus_windows, sysmon).
fix_rules Apply safe auto-fixes; optionally persist with write: true (requires --rules-dir).
format_rules Format Sigma YAML into the canonical layout; optionally persist with write: true (requires --rules-dir). Unreleased
author_ads Scaffold or render ADS detection metadata for a rule.
tune_rules Propose a verified Sigma filter from false-positive and true-positive event arrays.
test_exemplars Replay embedded rsigma.exemplars and return the pass/fail report. Added in v0.22.0
list_incidents List open incidents (--daemon-url). Added in v0.22.0
get_incident Fetch one open incident by id. Added in v0.22.0
get_incident_bundle Fetch the evidence bundle for one incident (json or markdown). Added in v0.22.0
list_risk_entities List open risk entities. Added in v0.22.0
get_rule_quality Fetch the per-rule quality view. Added in v0.22.0
list_silences List operator silences. Added in v0.22.0
create_silence Create a TTL-bounded silence (--allow-operate-writes). Added in v0.22.0
post_disposition Record an analyst verdict (--allow-operate-writes). Added in v0.22.0

Plus four read-only resources: rsigma://lint/catalogue, rsigma://ads/schema, rsigma://reference/modifiers, and rsigma://reference/mitre-tactics. See the MCP server guide for the three-tier registration model.

Example: register with Cursor

Add to your mcp.json:

{
  "mcpServers": {
    "rsigma": {
      "command": "rsigma",
      "args": ["mcp", "serve", "--rules-dir", "/path/to/rules"]
    }
  }
}

Streamable HTTP

For remote agents, serve over HTTP instead of stdio:

# Local, loopback (no TLS or token required)
rsigma mcp serve --http 127.0.0.1:9100 --rules-dir /path/to/rules

# Authenticated (bearer token), behind a TLS-terminating proxy
RSIGMA_MCP_AUTH_TOKEN=$(openssl rand -hex 32) \
  rsigma mcp serve --http 0.0.0.0:9100 --rules-dir /path/to/rules --allow-plaintext

# Native TLS (requires the `daemon-tls` feature), restricted to one host name
rsigma mcp serve --http 0.0.0.0:9100 --rules-dir /path/to/rules \
  --auth-token "$TOKEN" --allowed-host mcp.example.com \
  --tls-cert /etc/rsigma/tls/cert.pem --tls-key /etc/rsigma/tls/key.pem

The endpoint is https?://<addr>/mcp. Plaintext binds on non-loopback addresses are refused unless --allow-plaintext is set (use it when a sidecar proxy terminates TLS). Native TLS reuses the daemon’s rustls loader and is only available when the binary is built with daemon-tls.

Unreleased A non-loopback bind also needs --auth-token, or --allow-unauthenticated to opt out. Every request’s Host header is checked to stop DNS-rebinding pages from reaching the server. The accepted hosts depend on the bind:

Bind Accepted Host values
Loopback, such as 127.0.0.1:9100 localhost, 127.0.0.1, ::1, the bind IP, and each --allowed-host.
Non-loopback with --auth-token and no --allowed-host Any host. The bearer token is the access control, and startup logs a note.
Non-loopback with --allowed-host The loopback names, a specific bind IP (not 0.0.0.0 or ::), and each --allowed-host.
Non-loopback with --allow-unauthenticated The same list. Startup logs the accepted hosts; pass --allowed-host for the names clients use.

A host without a port matches any port. Other hosts get 403 Forbidden.

A request carrying an Origin header must name one of the accepted hosts over http or https (for example http://localhost:6274 for a browser-based inspector), or it gets 403 Forbidden. Requests without Origin are unaffected, and a bind that accepts any host skips the check.

--http refuses to start without --rules-dir unless --allow-unconfined-paths is set, because any client that reaches the endpoint could otherwise read files outside a rules tree. Added in v0.25.0

Exit codes

Code Meaning
0 The server ran and the client disconnected cleanly.
2 The server failed (transport error).
3 The --lint-config file could not be loaded, an invalid config value (e.g. mcp.http_addr), --http without --rules-dir or --allow-unconfined-paths, a non-loopback --http without --auth-token or --allow-unauthenticated, an empty --auth-token or RSIGMA_MCP_AUTH_TOKEN, or a plaintext non-loopback --http without --tls-cert/--tls-key or --allow-plaintext.

See also