WAF MCP Server
Provides tools for managing OWASP ModSecurity CRS via Docker, including monitoring container logs, executing commands, and managing Docker Compose services.
Provides tools for managing OWASP ModSecurity Core Rule Set (CRS), including rule enable/disable, paranoia level setting, engine mode switching, and false positive analysis.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@WAF MCP Servershow waf overview for last 24 hours"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
WAF MCP Server
An MCP (Model Context Protocol) server for managing OWASP ModSecurity CRS via Docker. Gives AI assistants like Claude direct access to WAF monitoring, analysis, and configuration through a structured drill-down pipeline.
Built for Claude Code but works with any MCP-compatible client.
Why
LLM proxy services (LiteLLM, OpenRouter, etc.) sit behind WAFs that generate massive amounts of false positives — prompts contain code, SQL, HTML, shell commands that trigger every content-inspection rule in the book. Managing these WAFs requires constant monitoring, tuning exclusions, and investigating events.
This MCP server lets an AI assistant do that work directly:
Overview — see total events, unique IPs, active rules at a glance
Drill down — filter events by IP or rule, inspect matched data
Act — disable rules, whitelist IPs, change engine mode — all without leaving the conversation
Tools
Analysis (drill-down pipeline)
Tool | Description |
| Dashboard: total events, unique IPs/rules, events last hour |
| Top IPs by event count with geo enrichment (ipinfo.io) |
| Most triggered rules with severity and description |
| Rules that fired on HTTP 2xx responses (false positive candidates) |
| Events filtered by source IP |
| Events filtered by rule ID |
| Full event: headers, request body, all rule matches with matched data |
Actions
Tool | Description |
| Container health, engine mode, rules loaded, paranoia level |
| Switch between |
| Set CRS paranoia level (1–4) |
| Disable a rule by ID (adds |
| Re-enable a previously disabled rule |
| Whitelist an IP (bypass WAF entirely) |
| Remove an IP from whitelist |
| Run test suite: scanner detection, SQLi, XSS, path traversal |
Common parameters
since — All analysis tools accept a since parameter to control the time window. Default is "24h". Supports Docker duration syntax: "1h", "24h", "7d", "30m". Days are automatically converted to hours (Docker's --since doesn't support the d suffix natively).
waf_overview(since: "7d") # last 7 days
waf_events_by_ip(ip: "1.2.3.4", since: "1h") # last hourverbose — waf_events_by_ip, waf_events_by_rule, and waf_event_detail accept verbose: true. By default, matchedData and requestBody are truncated to keep responses within context limits:
Field | Default | Verbose |
| 150–200 chars | 4000 chars |
| 500 chars | 8000 chars |
Prerequisites
Docker with a running owasp/modsecurity-crs container
Docker Compose managing the ModSecurity container
Node.js 18+
ModSecurity configured with JSON Serial audit log (
SecAuditLogFormat JSON)
Installation
git clone https://github.com/KratosUAE/waf_mcp.git
cd waf_mcp
npm install
npm run buildConfiguration
Environment variables
Variable | Required | Default | Description |
| Yes | — | Path to directory containing |
| No |
| Domain for WAF test requests |
| No |
| Default time window for log queries |
| No |
| Grep pattern to find the ModSecurity container |
| No |
| Path to CRS exclusions file (relative to compose dir) |
| No |
| Docker Compose filename |
| No | — | ipinfo.io token for IP geolocation |
| No | — | Set to any value to enable debug logging |
Connect to Claude Code
claude mcp add --transport stdio --scope user \
-e WAF_COMPOSE_DIR=/path/to/your/compose/dir \
-e WAF_DOMAIN=https://your-domain.com \
waf -- node /path/to/waf_mcp/dist/index.jsOr manually add to ~/.claude.json:
{
"mcpServers": {
"waf": {
"type": "stdio",
"command": "node",
"args": ["/path/to/waf_mcp/dist/index.js"],
"env": {
"WAF_COMPOSE_DIR": "/path/to/your/compose/dir",
"WAF_DOMAIN": "https://your-domain.com"
}
}
}
}Docker Compose setup
The server expects a ModSecurity container managed by Docker Compose. Example service definition:
modsecurity:
image: owasp/modsecurity-crs:nginx-alpine
environment:
- BACKEND=http://your-app:8080
- MODSEC_RULE_ENGINE=DetectionOnly
- MODSEC_AUDIT_LOG=/dev/stderr
- MODSEC_AUDIT_LOG_FORMAT=JSON
- MODSEC_AUDIT_LOG_TYPE=Serial
- MODSEC_AUDIT_ENGINE=RelevantOnly
- MODSEC_REQ_BODY_ACCESS=On
- MODSEC_REQ_BODY_LIMIT=52428800
- MODSEC_RESP_BODY_ACCESS=Off
- PARANOIA=1
- ANOMALY_INBOUND=5
volumes:
- ./modsecurity/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf:/etc/modsecurity.d/owasp-crs/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf:roKey settings:
MODSEC_AUDIT_LOG=/dev/stderr— sends audit log to Docker logs (required for the MCP server to read events)MODSEC_AUDIT_LOG_FORMAT=JSON— JSON format for structured parsingExclusions file mount — allows hot-reload of rule exclusions via
nginx -s reload
CRS exclusions for LLM traffic
LLM API endpoints receive prompts containing code, SQL, HTML, and shell commands — all legitimate content that triggers WAF rules. Create an exclusions file to disable content-inspection rules on API paths:
# modsecurity/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
SecRule REQUEST_URI "@rx ^(/v1/)?(chat/completions|completions|embeddings|responses|messages)|^/anthropic/" \
"id:1000,phase:1,nolog,pass,\
ctl:ruleRemoveById=921000-944999"This disables rules 921000–944999 (all content-inspection categories: SQLi, XSS, RCE, LFI, RFI, etc.) on LLM API endpoints while keeping protocol enforcement, scanner detection, DoS protection, and IP reputation checks active.
Usage example
Typical workflow in Claude Code:
You: "Check the WAF — anything suspicious?"
Claude: [calls waf_overview]
→ 332 events, 4 unique IPs, 12 rules triggered
Claude: [calls waf_top_ips]
→ 135.237.83.23 (Washington, US, Microsoft) — 320 events
Claude: [calls waf_events_by_ip, ip: "135.237.83.23", count: 5]
→ All POST /chat/completions, HTTP 200, rules: 942360, 932100...
Claude: [calls waf_event_detail, index: 42]
→ User-Agent: OpenAI/JS 6.26.0, body contains tool descriptions
→ Rule 942360 matched "update" in cron action descriptions
Claude: "This is your OpenClaw bot — all false positives.
Want me to whitelist this IP?"
You: "Yes"
Claude: [calls waf_allow_ip, ip: "135.237.83.23"]
→ Done. IP whitelisted.Investigating older events:
You: "Check IP 185.206.249.230 — it was flagged yesterday"
Claude: [calls waf_events_by_ip, ip: "185.206.249.230", since: "7d"]
→ 2 events from Apr 7, GET /v1/skills, HTTP 401, no rules triggered
→ Apple Private Relay IP (Singapore), just unauthorized API probesDevelopment
npm run build # Compile TypeScript
npm test # Run tests (43 tests)
npm run test:watch # Watch mode
WAF_DEBUG=1 npm start # Run with debug loggingArchitecture
src/
├── index.ts # MCP server setup, tool registration
├── waf-manager.ts # Core service: Docker exec, log parsing, config management
├── types.ts # TypeScript interfaces
├── config.ts # Environment-based configuration
├── logger.ts # stderr-only logger (stdout reserved for MCP protocol)
└── tools/
├── overview.ts # L0: dashboard
├── top-ips.ts # L1: IP aggregation
├── top-rules.ts # L1: rule aggregation
├── fp-candidates.ts # L1: false positive detection
├── events-by-ip.ts # L2: drill-down by IP
├── events-by-rule.ts # L2: drill-down by rule
├── event-detail.ts # L3: full event inspection
├── status.ts # Container status
├── set-engine.ts # Engine mode control
├── set-paranoia.ts # Paranoia level control
├── disable-rule.ts # Rule management
├── enable-rule.ts # Rule management
├── allow-ip.ts # IP whitelist
├── deny-ip.ts # IP whitelist
├── test.ts # WAF test suite
└── utils.ts # Shared utilitiesEvents are parsed from Docker logs and cached for 30 seconds. Rapid drill-down calls (overview → top IPs → events by IP → event detail) hit the cache instead of re-parsing. The cache is invalidated when the since parameter changes.
License
MIT
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/KratosUAE/waf_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server