Skip to main content
Glama
crowdsec-local-mcp

crowdsec-local-mcp

Official

Life is too short to write YAML, just ask nicely!

A Model Context Protocol (MCP) server to generate, validate, and deploy CrowdSec WAF rules & Scenarios.

Features

WAF Rules Features

  • WAF Rule Generation: Generate CrowdSec WAF rules from user input or a CVE reference

  • Validation: Validate syntaxical correctness of WAF rules

  • Linting: Get warnings and hints to improve your WAF rules

  • Deployment Guide: Step-by-step deployment instructions

  • Docker Test Harness: Spin up CrowdSec + nginx + bouncer to exercise rules for false positives/negatives

  • Nuclei Lookup: Quickly jump to existing templates in the official projectdiscovery/nuclei-templates repository for a given CVE

Scenarios Features

  • CrowdSec Scenarios Generation: Generate CrowdSec scenarios

  • Validation: Validate syntaxical correctness of scenarios

  • Linting: Get warnings and hints to improve your scenarios

  • Deployment Guide: Step-by-step deployment instructions

  • Docker Test Harness: Spin up CrowdSec to test scenario behavior

Related MCP server: Gen0Sec WAF Rule MCP Server

Demo

WAF Rules Creation and testing

Scenario Creation and testing

Prerequisites

  • uv 0.4 or newer, which provides the uvx runner used in the examples below.

  • Docker with the Compose plugin (Compose v2).

Installation

You can install the MCP using uvx or use packaged .mcpb file for claude code.

Using .mcpb package

If you're using claude desktop, you can configure the MCP directly by double-clicking the .mcpb file that accompanies the release.

IMPORTANT

On MacOS, configureuv path in the extension settings if uv isn't installed in the standard path.

Using uvx

  • Configure supported clients automatically with uvx --from crowdsec-local-mcp init <client>, where <client> is one of claude-desktop, claude-code, chatgpt, vscode, or stdio:

uvx --from crowdsec-local-mcp init --dry-run claude-code

Run uvx --from crowdsec-local-mcp init --help to see all flags and supported targets.

What init configures

The init helper writes the CrowdSec MCP server definition into the client’s JSON configuration:

  • claude-desktop → claude_desktop_config.json in the Claude Desktop settings directory

  • claude-code → invoke claude mcp command with needed args

  • chatgpt → config.json in the ChatGPT Desktop settings directory

  • vscode → mcp.json for VS Code (stable and insiders are both detected)

If the client's configuration file already exists, a .bak backup is created before the MCP server block is updated. When the file is missing you can either pass --force to create it, or point --config-path to a custom location. Combine --dry-run with these options to preview the JSON without making any changes.

By default the CLI launches the server with uvx --from crowdsec-local-mcp crowdsec-mcp. If neither uvx nor uv is available, it falls back to your current Python interpreter; you can override the executable with --command and the working directory with --cwd.

Using the stdio target

stdio does not modify any files. Instead, init stdio prints a ready-to-paste JSON snippet that you can drop into any stdio-compatible MCP client configuration. This is useful when you want to manually wire the server into tools that do not have built-in automation support yet.

Troubleshooting

If you just installed the mcp extension via .mcpb and uv or uvx isn't in the standard path, check the extension settings to configure uv path.

Logging

  • The MCP server writes its log file to your operating system's temporary directory. On Linux/macOS this is typically /tmp/crowdsec-mcp.log; on Windows it resolves via %TEMP%\crowdsec-mcp.log.

Available Tools

24 tools
curl_waf_endpointB

Execute an HTTP request against the local WAF test endpoint (http://localhost:8081)

Inputs: path (required), method (required), body, headers, +1 more.

deploy_scenarioC

Retrieve guidance for packaging and deploying a CrowdSec scenario

Inputs: no named parameters.

deploy_waf_ruleB

Get deployment instructions for CrowdSec WAF rules

Inputs: no named parameters.

explain_scenarioA
    Shows how crowdsec processes a single log line: what is extracted by the parsers, and which scenarios match.
    A match does not mean an alert is generated, only that the event was of interest for the scenario.
    This tool MUST NEVER be called with multiple log lines. If you need to test whether a scenario generates an alert, use the `test_scenario` tool instead.
    The scenario stack (manage_scenario_stack) must be running to use this tool.
    

Inputs: log_line (required), log_type (required), collections (required), scenario_yaml (required).

fetch_nuclei_exploitA

Retrieve nuclei templates from the official repository for a CVE to help with generation of WAF rules

Inputs: cve (required).

generate_waf_ruleB

Get the complete WAF rule generation prompt (main prompt + examples) for CrowdSec

Inputs: nuclei_template.

generate_waf_testsC

Get the WAF test generation prompt for producing config.yaml and adapted Nuclei templates

Inputs: rule_filename, nuclei_template.

get_scenario_examplesA

Retrieve example CrowdSec scenarios and annotations

Inputs: no named parameters.

get_scenario_expr_helpersA

Retrieve helper expressions for CrowdSec scenario authoring

Inputs: no named parameters.

get_scenario_promptB

Retrieve the base prompt for authoring CrowdSec scenarios

Inputs: no named parameters.

get_waf_examplesB

Get WAF rule generation examples for CrowdSec

Inputs: no named parameters.

get_waf_promptA

Get the main WAF rule generation prompt for CrowdSec

Inputs: no named parameters.

get_waf_pr_promptB

Get the WAF PR preparation prompt for writing test assets and drafting a PR comment

Inputs: no named parameters.

get_waf_rule_challenge_promptB

Get the prompt for challenging drafted WAF rules to reduce false positives and weak detections

Inputs: no named parameters.

get_waf_top_level_promptA

Get the top-level CrowdSec WAF workflow prompt that explains how to approach rule and test creation

Inputs: no named parameters.

lint_scenario_yamlB

Lint CrowdSec scenario YAML and highlight potential improvements

Inputs: scenario_yaml (required).

lint_waf_ruleA

Lint a CrowdSec WAF rule and provide warnings/hints for improvement

Inputs: rule_yaml (required).

manage_scenario_stackA

Manage the lifecycle of the scenario testing stack (ONLY USE FOR TESTING SCENARIOS)

Inputs: action (required).

manage_waf_stackA

Start or stop the Docker-based CrowdSec AppSec test stack so the rule can be exercised with allowed and blocked requests. If this action fails because docker isn't present or cannot be run, prompt the user to set it up manually.

Inputs: action (required), rule_yaml.

prepare_waf_prB

Help prepare a pull request in a local clone of the CrowdSec hub repository by adding the generated WAF rule and associated test files.

Inputs: hub_dir (required), rule_yaml (required), rule_filename (required), nuclei_filename (required), +3 more.

run_waf_testsA

Start the WAF harness and execute the provided nuclei test template against it. If this action fails because docker isn't present or cannot be run, prompt the user to set it up manually.

Inputs: rule_yaml (required), nuclei_yaml (required).

test_scenarioB

Test a CrowdSec scenario against multiple log lines (effectively replaying the events as if they were occurring in real-time).

Inputs: log_type (required), log_lines (required), collections (required), scenario_yaml (required).

validate_scenario_yamlB

Validate CrowdSec scenario YAML structure for required fields

Inputs: scenario_yaml (required).

validate_waf_ruleB

Validate that a CrowdSec WAF rule YAML is syntactically correct

Inputs: rule_yaml (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 24 tools

    Disambiguation2/5

    Many tools have overlapping purposes, especially the prompt-getting tools (get_waf_top_level_prompt, get_waf_prompt, get_waf_examples, generate_waf_rule). The testing workflow is ambiguous between run_waf_tests, manage_waf_stack, and curl_waf_endpoint. Agents could easily confuse which tool to use for a given task.

    Naming Consistency3/5

    Most names use snake_case with verb_noun pattern, but verbs vary inconsistently (get, generate, validate, lint, deploy, prepare, fetch, manage, curl, explain, test). Some tools omit the 'waf' prefix (e.g., fetch_nuclei_exploit, manage_scenario_stack) breaking the pattern. The naming is readable but not uniform.

    Tool Count3/5

    24 tools is on the higher side, but the server covers two distinct domains (WAF rules and scenarios). However, many prompt-related tools could be consolidated (e.g., get_waf_prompt, get_waf_top_level_prompt, get_waf_examples). The count feels slightly bloated.

    Completeness4/5

    The tool set covers the full lifecycle for both WAF rules and scenarios: generation, validation, linting, testing, deployment, and PR preparation. Minor gaps like missing a direct 'update' operation, but the domain is authoring-oriented, which is well-covered.

    Maintenance

    ActivityMaintained
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers