A Model Context Protocol (MCP) server for Fortinet FortiGate management via REST API.
This MCP server provides a comprehensive interface to manage FortiGate firewalls through the FortiOS REST API v7.4.9. It supports multi-device management, structured responses, and comprehensive firewall operations including policies, addresses, VPN, routing, and system monitoring.
- π₯ Multi-Device Management: Manage multiple FortiGate devices from a single MCP server
- π Structured Responses: All tools return parsed, structured JSON data
- π‘οΈ Comprehensive Coverage: 20+ tools covering all major FortiGate operations
- π³ Docker Support: Easy deployment with Docker Compose
- π Secure: API key authentication with SSL verification support
- π Well Documented: Complete examples and API documentation
get_system_status- Get system information and statusget_system_resources- Monitor CPU, memory, and disk usagelist_active_sessions- View active network sessionsget_interface_statistics- Network interface statistics
list_firewall_policies- List all firewall policiesget_firewall_policy- Get specific policy detailscreate_firewall_policy- Create new firewall policyupdate_firewall_policy- Update existing policydelete_firewall_policy- Delete firewall policy
list_firewall_addresses- List address objectsget_firewall_address- Get specific address objectcreate_firewall_address- Create address objectupdate_firewall_address- Update address objectdelete_firewall_address- Delete address object
list_vpn_ipsec_tunnels- List IPsec VPN tunnelsget_vpn_tunnel_status- Get VPN tunnel statuslist_static_routes- List static routeslist_policy_routes- List policy-based routes
get_ha_status- Get HA cluster status
- Python 3.8+
- FortiGate device with API access enabled
- API token for authentication
- Clone the repository:
git clone https://github.com/0xEkho/FORTINET-FortiGate-MCP.git
cd FORTINET-FortiGate-MCP- Install dependencies:
pip install -r requirements.txt-
Configure your devices (see Configuration section below)
-
Run the server:
python -m fortigate_server.server- Clone the repository:
git clone https://github.com/0xEkho/FORTINET-FortiGate-MCP.git
cd FORTINET-FortiGate-MCP-
Configure your devices (see Configuration section below)
-
Build and start:
cd deploy
docker-compose up -dThe server will be available on http://localhost:8085
Create a devices.json file at the root of the project:
{
"devices": [
{
"name": "firewall-hq",
"host": "192.168.1.1",
"api_key": "your-api-key-here",
"verify_ssl": false,
"vdom": "root"
},
{
"name": "firewall-branch",
"host": "192.168.2.1",
"api_key": "another-api-key",
"verify_ssl": true,
"vdom": "root"
}
]
}You can use devices.json.example as a template.
name: Unique identifier for the device (used in tool calls)host: FortiGate IP address or hostnameapi_key: API token generated from FortiGateverify_ssl: Enable/disable SSL certificate verificationvdom: Virtual domain (usually "root")
- Log into your FortiGate web interface
- Go to
System > Administrators - Create a new REST API Admin
- Generate an API key
- Set appropriate access permissions
Call tools via HTTP POST:
curl -X POST http://localhost:8085/tools/call \
-H "Content-Type: application/json" \
-d '{
"tool": "get_system_status",
"arguments": {
"device_name": "firewall-hq"
}
}'Response:
{
"success": true,
"result": {
"model": {
"name": "FortiGate",
"number": "80F",
"full": "FGT80F"
},
"hostname": "FW-HQ",
"serial": "FGT80FXXXXXXXXXX",
"version": "v7.4.9",
"build": 2829,
"vdom": "root",
"status": "success"
}
}Configure your MCP client (e.g., Claude Desktop) to use this server:
{
"mcpServers": {
"fortigate": {
"url": "http://localhost:8085"
}
}
}See the examples/ directory for detailed usage examples of each tool:
- System Status
- List Firewall Policies
- Create Firewall Policy
- Address Management
- VPN Monitoring
- And more...
The server implements FortiOS REST API v7.4.9. Full API documentation is available in the docs/ directory.
FORTINET-FortiGate-MCP/
βββ fortigate_server/ # Main server code
β βββ server.py # SSE server implementation
β βββ fortigate_client.py # FortiGate API client
β βββ tools/ # Tool implementations
β βββ parsers/ # Response parsers
βββ deploy/ # Docker deployment files
βββ docs/ # API documentation
βββ examples/ # Usage examples
βββ ressources/ # API specifications
βββ devices.json # Device configuration
- Add tool definition in
fortigate_server/server.py - Implement tool logic in
fortigate_server/tools/ - Create parser in
fortigate_server/parsers/ - Add example in
examples/
- Verify FortiGate is reachable:
ping <host> - Check API access is enabled on FortiGate
- Verify API key is valid and has correct permissions
- Check SSL settings (
verify_ssl) match your setup
- Ensure port 8085 is not already in use
- Verify
devices.jsonexists and is properly mounted - Check logs:
docker logs fortigate-mcp-server
- API Keys: Keep API keys secure, never commit to version control
- SSL Verification: Use
verify_ssl: truein production - Network Access: Restrict access to the MCP server port
- Permissions: Use least-privilege API keys on FortiGate
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - See LICENSE file for details
Created by 0xEkho
- π Issues: GitHub Issues
- π§ Contact: Via GitHub
- Fortinet for FortiGate and FortiOS API
- MCP (Model Context Protocol) specification