fwrule-mcp

fwrule-mcp

An MCP server that analyzes firewall rule overlap, duplication, shadowing, and conflicts across multi-vendor firewall policies.

Category
访问服务器

README

FWRule MCP — Firewall Rule Analyzer

An MCP server that analyzes firewall rule overlap, duplication, shadowing, and conflicts across multi-vendor firewall policies.

Supported Vendors

Vendor Format Versions
Palo Alto PAN-OS / Panorama XML config export 9.x - 11.x
Cisco ASA show running-config text 9.x+
Cisco FTD JSON export from FMC 6.x - 7.x
Cisco IOS / IOS-XE show running-config text 12.x - 17.x
Cisco IOS-XR show running-config text 6.x+
Check Point JSON show-access-rulebase R80.x - R82.x
Juniper SRX display set format 19.x+
Juniper Junos (MX/PTX/QFX) display set format 18.x+
Nokia SR OS MD-CLI info/flat format 20.x+
Fortinet FortiOS / FortiGate show full-configuration text 6.x - 7.x

Quick Start

# Install
uv sync

# Run tests
uv run pytest

# Start the MCP server
uv run fwrule-mcp

MCP Tools

analyze_firewall_rule_overlap

Analyze whether a candidate firewall rule overlaps with an existing ruleset. Supports two input modes.

Mode 1 — Vendor-native configs (built-in parsers):

  • vendor — Vendor identifier (panos, asa, ftd, ios, iosxr, checkpoint, juniper, junos, sros, fortios)
  • ruleset_payload — Complete firewall config in vendor-native format
  • candidate_rule_payload — Single candidate rule in vendor-native format
  • os_version — Optional OS version string
  • context_objects — Optional JSON with supplemental object definitions

Mode 2 — Pre-normalized JSON (caller extracts structured rules):

  • existing_rules — JSON string: array of normalized rule objects
  • candidate_rule — JSON string: single normalized rule object

Shared:

  • candidate_position — Optional 1-based intended insertion position

Normalized rule schema:

{
  "id": "rule-1",
  "position": 1,
  "enabled": true,
  "action": "permit",
  "source_zones": ["trust"],
  "destination_zones": ["untrust"],
  "source_addresses": ["10.0.0.0/24", "192.168.1.0/24"],
  "destination_addresses": ["any"],
  "services": [{"protocol": "tcp", "ports": "443"}],
  "applications": ["any"]
}

Detects:

  • Exact duplicates
  • Shadowed rules (candidate would never fire)
  • Action conflicts (overlapping traffic, opposing actions)
  • Partial overlaps
  • Superset/subset relationships

parse_policy

Parse a vendor-native firewall config and return normalized JSON rules. Use this to inspect what the built-in parser extracts before running overlap analysis.

  • vendor — Vendor identifier
  • ruleset_payload — Complete firewall config
  • os_version — Optional OS version string
  • context_objects — Optional JSON with supplemental object definitions

Returns the same normalized schema accepted by analyze_firewall_rule_overlap.

batch_analyze_overlap

Analyze multiple candidate rules against the same existing ruleset in a single call. More efficient than calling analyze_firewall_rule_overlap multiple times — existing rules are parsed once and reused for each candidate.

  • existing_rules — Array of normalized rule objects (from parse_policy output)
  • candidate_rules — Array of candidate rule objects to analyze

Returns {"success": true, "results": [{"candidate_id": "...", ...analysis result...}, ...]}.

list_supported_vendors

List all supported firewall vendors with format requirements.

Testing

# Full test suite
uv run pytest

# Mock payload tests (vendor parsers)
uv run pytest tests/test_mock_payloads.py -v

# Normalized input tests
uv run pytest tests/test_normalized_input.py -v

# Testing agent with formatted report
uv run python tests/test_agent.py

# Single vendor / scenario
uv run python tests/test_agent.py --vendor panos --scenario conflict --verbose

Architecture

MCP Client Request
       │
       ├── Mode 1: vendor + raw config
       │         │
       │         v
       │    Vendor Parser (plugin registry)
       │    [PAN-OS │ ASA │ FTD │ IOS │ IOS-XR │ CP │ SRX │ Junos │ SR OS │ FortiOS]
       │         │
       │         v
       │    Normalization Layer (object resolution, address expansion)
       │         │
       │         └──────────────┐
       │                        v
       ├── Mode 2: normalized JSON ──> Schema Validation
       │                        │
       │                        v
       └──────────────────> Analysis Engine (6-dimension set intersection)
                                │
                                v
                          Result Generator
                                │
                                v
                       Compact JSON Response

License

Apache 2.0


Addendum: Why Two Input Modes?

This MCP server is designed for automated compliance checking over large firewall rulesets where false positives and false negatives have real security consequences. The architecture balances two competing concerns:

The case for built-in parsers (Mode 1)

Firewall configs contain named object graphs — a rule may reference PROD-SERVERS, which is an address group containing WEB-TIER and DB-TIER, each referencing CIDRs. Resolving these correctly requires recursive expansion with cycle detection and conservative fallback (unresolvable references treated as any to avoid false negatives). The built-in parsers do this deterministically. An LLM doing this via reasoning will occasionally miss nested group members or hallucinate resolutions — margins that matter for security policy decisions.

The case for normalized input (Mode 2)

The vendor parsers are the fragility source. Each parser is ~400 lines of format-specific code that can break when vendor OS versions change output formats. We've already seen bugs in the PAN-OS parser (wrong XML element selection in wrapped configs). When a parser gets a format wrong, the analysis engine produces incorrect results — and the caller has no way to know.

The hybrid solution

Mode 2 (normalized JSON) addresses the fragility problem while preserving correctness:

  • When the caller already has structured data (e.g., from a REST API, or when the AI agent can reliably extract fields), it bypasses the fragile parsers entirely and sends resolved addresses directly to the analysis engine.
  • When the caller has raw CLI/config output, Mode 1's parsers handle the complex extraction and object resolution.
  • parse_policy bridges the gap — the caller can inspect what the parser extracted, verify rule counts and address resolution, and decide whether to trust the parser output or re-extract manually.

The analysis engine — the part that does CIDR arithmetic, port range intersection, and multi-dimensional set comparison — is the irreplaceable value. It's vendor-agnostic, deterministic, and well-tested. The parsers are a convenience layer; the normalized schema is the true API surface.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选