delta-source/sonicwall-mcp
If you are the rightful owner of sonicwall-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
MCP (Model Context Protocol) server for SonicWall firewall management and monitoring
SonicMCP -- SonicWall Firewall Management via MCP
A Model Context Protocol (MCP) server for full-featured management of SonicWall firewalls through their REST API. Built with Python and the FastMCP SDK, designed to be used from Cursor or any MCP-compatible AI assistant.
What It Does
SonicMCP gives an AI assistant authenticated access to your SonicWall's entire management API. The assistant can read configuration, create and modify resources, and commit changes -- covering network segmentation, access rules, NAT, DHCP, VPN, and every other domain the SonicOS API exposes.
Tools
Read Tools (Network Segmentation)
list_zones/get_zone-- Firewall zones and security typeslist_interfaces/get_interface-- Physical and VLAN interfaceslist_vlan_interfaces-- VLAN sub-interfaceslist_access_rules/get_access_rule-- IPv4 access ruleslist_security_policies/get_security_policy-- IPv4 security policieslist_address_objects/get_address_object-- IPv4 address objectslist_address_groups/get_address_group-- IPv4 address groupslist_nat_policies-- IPv4 NAT policieslist_service_objects/list_service_groups-- Service definitionsget_dhcp_server_config/list_dhcp_scopes-- DHCP configurationget_routing_config-- Routing configurationget_pending_changes-- Uncommitted configuration changes
Write Tools (with dry-run safety)
create_zone/update_zone/delete_zonecreate_address_object/update_address_object/delete_address_objectcreate_address_group/update_address_group/delete_address_groupcreate_access_rule/update_access_rule/delete_access_rulecreate_nat_policy/delete_nat_policycreate_dhcp_scope/delete_dhcp_scopecommit_pending_changes/rollback_pending_changes
Generic Tools (escape hatch for any API endpoint)
raw_api_get/raw_api_post/raw_api_put/raw_api_deleteexplore_api-- Browse any API endpointget_system_status-- Verify connectivity
All write tools default to dry-run mode (confirm=False). They show what they would do without making changes. The AI must explicitly pass confirm=True after you approve.
Prerequisites
- SonicWall with SonicOS API enabled and RFC-2617 HTTP Basic Auth enabled
- Python 3.13+
- 1Password CLI (
op) for credential management - 1Password item named
sonic_mcpwith fields:username,password, and TOTP configured
Setup
# Clone/navigate to the project
cd sonicwall-mcp
# Create virtual environment and install dependencies
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Cursor Configuration
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"sonicmcp": {
"command": "/path/to/sonicwall-mcp/venv/bin/python",
"args": ["/path/to/sonicwall-mcp/src/main.py"],
"cwd": "/path/to/sonicwall-mcp",
"env": {
"PYTHONPATH": "/path/to/sonicwall-mcp/src"
}
}
}
}
Environment Variables
| Variable | Description | Default |
|---|---|---|
SONICWALL_HOST | SonicWall IP or hostname | 192.168.100.1 |
SONICWALL_PORT | HTTPS port | 443 |
Credentials are fetched from 1Password CLI. If you prefer environment variables, set SONICWALL_USERNAME, SONICWALL_PASSWORD, and SONICWALL_TOTP.
Architecture
- FastMCP -- uses the modern MCP Python SDK with
@mcp.tool()decorators - Auto-reconnect -- fetches a fresh TOTP from 1Password on every re-authentication, solving the stale-TOTP problem
- Token lifecycle -- tracks bearer token expiry, proactively refreshes before timeout
- Dry-run safety -- all write operations preview changes before execution
- Generic escape hatch --
raw_api_*tools can hit any API endpoint, so the server is never missing a capability
File Structure
src/
main.py -- FastMCP server, all tool definitions
sonicwall_client.py -- API client with auth interceptor
credentials.py -- 1Password credential fetching
Warning
This tool can modify firewall configurations. All write operations require explicit confirmation. Test in a non-production environment before using on critical infrastructure.