Batfish Configuration Analysis
MCP Server
- Source: Built-in (mcp-servers/batfish-mcp/)
- Command:
python3 -u mcp-servers/batfish-mcp/batfish_mcp_server.py (stdio transport)
- Requires: Batfish Docker container running,
BATFISH_HOST and BATFISH_PORT environment variables
- Python: 3.10+
- Dependencies:
pybatfish, mcp[cli], python-dotenv
Available Tools (8)
| Tool |
Parameters |
What It Does |
batfish_upload_snapshot |
snapshot_name, configs/config_path, network |
Upload device configs to Batfish and create a named snapshot |
batfish_validate_config |
snapshot_name, network |
Validate configs with per-device pass/fail status, vendor detection, warnings |
batfish_test_reachability |
snapshot_name, src_ip, dst_ip, protocol, dst_port |
Test if traffic can flow between two endpoints with full path trace |
batfish_trace_acl |
snapshot_name, device, filter_name, src_ip, dst_ip, protocol, dst_port |
Trace a packet through ACL rules to find matching permit/deny rule |
batfish_diff_configs |
reference_snapshot, candidate_snapshot, include_routes, include_reachability |
Compare two snapshots for route and reachability differences |
batfish_check_compliance |
snapshot_name, policy_type |
Check configs against compliance policies (6 built-in policy types) |
batfish_list_snapshots |
network |
List all available snapshots |
batfish_delete_snapshot |
snapshot_name, network |
Delete a snapshot |
Workflow: Pre-Change Validation
When a user wants to validate configurations before deployment:
- Upload configs:
batfish_upload_snapshot with inline configs dict or path to config directory
- Validate:
batfish_validate_config to check parse status, vendor detection, warnings/errors
- Test reachability:
batfish_test_reachability for critical traffic paths
- Check compliance:
batfish_check_compliance against organizational policies
- Report: Structured pass/fail results with specific findings
- GAIT: All operations automatically logged
Example: Validate Before Deploy
# Upload proposed configs
batfish_upload_snapshot snapshot_name="pre-change-site-a" config_path="/path/to/configs/"
# Validate parse status
batfish_validate_config snapshot_name="pre-change-site-a"
# Test critical path
batfish_test_reachability snapshot_name="pre-change-site-a" src_ip="10.1.1.1" dst_ip="10.2.2.1" protocol="TCP" dst_port=443
# Check compliance
batfish_check_compliance snapshot_name="pre-change-site-a" policy_type="interface_descriptions"
Workflow: Change Impact Analysis
When comparing before/after configurations:
- Upload "before" snapshot:
batfish_upload_snapshot with current configs
- Upload "after" snapshot:
batfish_upload_snapshot with proposed configs
- Diff:
batfish_diff_configs to find route and reachability differences
- Investigate: Use
batfish_trace_acl on any newly denied traffic
- Report: Structured diff showing added/removed/changed routes and flows
Workflow: ACL Troubleshooting
When investigating access control issues:
- Upload configs:
batfish_upload_snapshot with device configs
- Trace packet:
batfish_trace_acl with device, ACL name, and packet headers
- Review: Identify matching rule, line number, permit/deny action
- Test alternatives: Modify config, re-upload, trace again
Integration with Other Skills
| Skill |
Integration |
| pyats-config-mgmt |
Validate configs with Batfish before pushing via pyATS |
| gait-session-tracking |
All Batfish operations automatically logged |
| servicenow-change-workflow |
Reference Batfish validation in change request evidence |
| fwrule-analyzer |
Complement ACL trace with cross-vendor overlap analysis |
| cml-lab-lifecycle |
Validate CML lab configs with Batfish analysis |
Important Rules
- All operations are strictly read-only -- Batfish analyzes uploaded configs, never modifies network devices
- GAIT audit mandatory -- All operations logged automatically
- Snapshots are ephemeral -- Batfish manages snapshot lifecycle; use GAIT for persistent records
- Multi-vendor -- Supports Cisco IOS/IOS-XE/NX-OS, JunOS, Arista EOS, Palo Alto, F5
Error Handling
- BATFISH_UNREACHABLE: Verify Docker container is running (
docker ps | grep batfish)
- SNAPSHOT_NOT_FOUND: Use
batfish_list_snapshots to see available snapshots
- INVALID_INPUT: Check configs dict is non-empty or config_path exists
- DEVICE_NOT_FOUND: Use
batfish_validate_config to list devices in snapshot
- FILTER_NOT_FOUND: Verify ACL/filter name exists on the specified device
Environment Variables
BATFISH_HOST -- Batfish hostname (default: localhost)
BATFISH_PORT -- Batfish port (default: 9997)
BATFISH_NETWORK -- Default network name (default: netclaw)
1---
2name: batfish-config-analysis
3description: "Batfish network configuration analysis -- pre-deployment validation, reachability testing, ACL/firewall tracing, differential analysis, compliance checking. Use when validating configs before deployment, testing traffic paths, tracing ACL rules, comparing config versions, or auditing compliance policies. Strictly read-only."
4license: Apache-2.0
5user-invocable: true
6metadata:
7 { "openclaw": { "requires": { "bins": ["python3", "docker"], "env": ["BATFISH_HOST"] } } }
8---
9
10# Batfish Configuration Analysis
11
12## MCP Server
13
14- **Source**: Built-in (mcp-servers/batfish-mcp/)
15- **Command**: `python3 -u mcp-servers/batfish-mcp/batfish_mcp_server.py` (stdio transport)
16- **Requires**: Batfish Docker container running, `BATFISH_HOST` and `BATFISH_PORT` environment variables
17- **Python**: 3.10+
18- **Dependencies**: `pybatfish`, `mcp[cli]`, `python-dotenv`
19
20## Available Tools (8)
21
22| Tool | Parameters | What It Does |
23|------|-----------|--------------|
24| `batfish_upload_snapshot` | `snapshot_name`, `configs`/`config_path`, `network` | Upload device configs to Batfish and create a named snapshot |
25| `batfish_validate_config` | `snapshot_name`, `network` | Validate configs with per-device pass/fail status, vendor detection, warnings |
26| `batfish_test_reachability` | `snapshot_name`, `src_ip`, `dst_ip`, `protocol`, `dst_port` | Test if traffic can flow between two endpoints with full path trace |
27| `batfish_trace_acl` | `snapshot_name`, `device`, `filter_name`, `src_ip`, `dst_ip`, `protocol`, `dst_port` | Trace a packet through ACL rules to find matching permit/deny rule |
28| `batfish_diff_configs` | `reference_snapshot`, `candidate_snapshot`, `include_routes`, `include_reachability` | Compare two snapshots for route and reachability differences |
29| `batfish_check_compliance` | `snapshot_name`, `policy_type` | Check configs against compliance policies (6 built-in policy types) |
30| `batfish_list_snapshots` | `network` | List all available snapshots |
31| `batfish_delete_snapshot` | `snapshot_name`, `network` | Delete a snapshot |
32
33## Workflow: Pre-Change Validation
34
35When a user wants to validate configurations before deployment:
36
371. **Upload configs**: `batfish_upload_snapshot` with inline configs dict or path to config directory
382. **Validate**: `batfish_validate_config` to check parse status, vendor detection, warnings/errors
393. **Test reachability**: `batfish_test_reachability` for critical traffic paths
404. **Check compliance**: `batfish_check_compliance` against organizational policies
415. **Report**: Structured pass/fail results with specific findings
426. **GAIT**: All operations automatically logged
43
44### Example: Validate Before Deploy
45
46```bash
47# Upload proposed configs
48batfish_upload_snapshot snapshot_name="pre-change-site-a" config_path="/path/to/configs/"
49
50# Validate parse status
51batfish_validate_config snapshot_name="pre-change-site-a"
52
53# Test critical path
54batfish_test_reachability snapshot_name="pre-change-site-a" src_ip="10.1.1.1" dst_ip="10.2.2.1" protocol="TCP" dst_port=443
55
56# Check compliance
57batfish_check_compliance snapshot_name="pre-change-site-a" policy_type="interface_descriptions"
58```
59
60## Workflow: Change Impact Analysis
61
62When comparing before/after configurations:
63
641. **Upload "before" snapshot**: `batfish_upload_snapshot` with current configs
652. **Upload "after" snapshot**: `batfish_upload_snapshot` with proposed configs
663. **Diff**: `batfish_diff_configs` to find route and reachability differences
674. **Investigate**: Use `batfish_trace_acl` on any newly denied traffic
685. **Report**: Structured diff showing added/removed/changed routes and flows
69
70## Workflow: ACL Troubleshooting
71
72When investigating access control issues:
73
741. **Upload configs**: `batfish_upload_snapshot` with device configs
752. **Trace packet**: `batfish_trace_acl` with device, ACL name, and packet headers
763. **Review**: Identify matching rule, line number, permit/deny action
774. **Test alternatives**: Modify config, re-upload, trace again
78
79## Integration with Other Skills
80
81| Skill | Integration |
82|-------|-------------|
83| **pyats-config-mgmt** | Validate configs with Batfish before pushing via pyATS |
84| **gait-session-tracking** | All Batfish operations automatically logged |
85| **servicenow-change-workflow** | Reference Batfish validation in change request evidence |
86| **fwrule-analyzer** | Complement ACL trace with cross-vendor overlap analysis |
87| **cml-lab-lifecycle** | Validate CML lab configs with Batfish analysis |
88
89## Important Rules
90
91- **All operations are strictly read-only** -- Batfish analyzes uploaded configs, never modifies network devices
92- **GAIT audit mandatory** -- All operations logged automatically
93- **Snapshots are ephemeral** -- Batfish manages snapshot lifecycle; use GAIT for persistent records
94- **Multi-vendor** -- Supports Cisco IOS/IOS-XE/NX-OS, JunOS, Arista EOS, Palo Alto, F5
95
96## Error Handling
97
98- **BATFISH_UNREACHABLE**: Verify Docker container is running (`docker ps | grep batfish`)
99- **SNAPSHOT_NOT_FOUND**: Use `batfish_list_snapshots` to see available snapshots
100- **INVALID_INPUT**: Check configs dict is non-empty or config_path exists
101- **DEVICE_NOT_FOUND**: Use `batfish_validate_config` to list devices in snapshot
102- **FILTER_NOT_FOUND**: Verify ACL/filter name exists on the specified device
103
104## Environment Variables
105
106- `BATFISH_HOST` -- Batfish hostname (default: localhost)
107- `BATFISH_PORT` -- Batfish port (default: 9997)
108- `BATFISH_NETWORK` -- Default network name (default: netclaw)