FortiGate MCP Server
Enables AI assistants to manage FortiGate firewalls from bootstrap to production, with safe preview/apply changes and secure credential handling. Covers inventory, VDOMs, interfaces, routing, firewall policies, VPN, security analysis, and documentation generation.
README
<p align="center"> <img src="https://img.shields.io/badge/FortiGate-MCP%20Server-blue?style=for-the-badge&logo=fortinet&logoColor=white" alt="FortiGate MCP Server"/> </p>
<h1 align="center">FortiGate MCP Server</h1>
<p align="center"> <strong>Take a FortiGate from out-of-the-box to fully configured through Claude (or any MCP client) -- safely, with every change previewed before it's applied.</strong> </p>
<p align="center"> <img src="https://img.shields.io/badge/python-3.12+-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.12+"/> <img src="https://img.shields.io/badge/MCP-1.0-green?style=flat-square" alt="MCP 1.0"/> <img src="https://img.shields.io/badge/tools-115-brightgreen?style=flat-square" alt="115 tools"/> <img src="https://img.shields.io/badge/tests-548%20passing-brightgreen?style=flat-square" alt="Tests"/> <img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="MIT License"/> </p>
<p align="center"> <a href="#overview">Overview</a> • <a href="#features">Features</a> • <a href="docs/INSTALLATION.md">Installation</a> • <a href="docs/USAGE.md">Usage</a> • <a href="docs/TOOLS.md">Tool Reference</a> • <a href="#architecture">Architecture</a> • <a href="#security-model">Security</a> • <a href="#known-limitations">Limitations</a> </p>
Overview
This is an MCP (Model Context Protocol) server that lets an AI assistant manage FortiGate firewalls -- from a single lab device to a multi-tenant estate of dozens of customers, sites, and clusters.
It's built around three ideas that most FortiGate automation tooling doesn't have all three of at once:
- Nothing mutates without a preview. Every create/update/delete call returns a diff and a
change_idinstead of executing immediately. A separatechange_applycall is what actually runs it, and it re-checks the live state for drift before doing so. There is no single-shot "just do it" mode, even for trusted automation. - Claude never sees a real credential. Device passwords/API tokens are provisioned through a local, non-MCP CLI (
fortinet-mcp-cred) straight into your OS credential store (Windows Credential Manager / macOS Keychain / Linux Secret Service). The MCP tool surface only ever handles an opaquecredential_id. - It covers the whole lifecycle, not just policy CRUD. Device bootstrap (DNS/NTP/syslog/SNMP/admin/HA), VDOM multi-tenancy, interfaces/zones/DHCP, routing, firewall policy, VPN (IPsec + SSL), security/compliance analysis, and documentation generation are all first-class tool namespaces -- see the full Tool Reference (115 tools).
Features
| Domain | What you get |
|---|---|
| Inventory & multi-tenancy | Customer -> Site -> Device -> VDOM hierarchy in a local SQLite store. Resolve a device by name, site, customer, or IP -- never by typing an IP into a prompt. |
| Device bootstrap | DNS, NTP, syslog, SNMP (sysinfo + v1/v2c communities), global settings (hostname/timezone/admin ports), local admin accounts, HA -- everything needed to take a device from factory defaults to production-ready. |
| VDOM lifecycle | Create/delete VDOMs, create/delete inter-VDOM links. |
| Network topology | Interfaces (VLAN sub-interfaces, loopbacks, vdom-link members), zones, DHCP servers, static routes. |
| Firewall & NAT | Policies, address/service objects, virtual IPs -- full CRUD. |
| VPN | IPsec site-to-site tunnels (phase1/phase2) with live status; SSL VPN visibility. |
| Change safety | READ_ONLY / SAFE / FULL operating modes, preview -> apply -> rollback for every mutation, drift detection at apply time. |
| Analysis & compliance | Duplicate/shadowed/any-any policy detection, unused object detection, subnet overlap, best-practice checks (policy and system config), a heuristic 0-100 security score, a combined compliance report. |
| Documentation generation | Topology diagrams (Mermaid/drawio/PlantUML), policy/routing/VPN/system-config Markdown docs, a combined export. |
| Fleet operations | Compare devices, search for an object across the whole estate, sync objects, replicate config, fleet-wide reports. |
| Natural-language intents | Composite tools (intent_create_policy, intent_explain_policy_failure, ...) that resolve fuzzy names and compose the primitives above. |
See docs/TOOLS.md for the complete, generated list of all 115 tools.
Quick Start
git clone https://github.com/Serrinho02/fortigate-mcp-server.git
cd fortigate-mcp-server
uv sync
Create a minimal config/config.json (the legacy single-file device list is optional once you're using the inventory system below -- see Installation):
{ "fortigate": { "devices": {} } }
Point your MCP client (e.g. Claude Desktop) at the server:
{
"mcpServers": {
"fortigate": {
"command": "/absolute/path/to/fortigate-mcp-server/.venv/bin/python",
"args": ["-m", "src.fortigate_mcp.server"],
"env": {
"FORTIGATE_MCP_CONFIG": "/absolute/path/to/fortigate-mcp-server/config/config.json",
"FORTINET_MCP_MODE": "full"
}
}
}
}
Then, from Claude: register a device (inventory_register_device_pending), provision its credential locally with fortinet-mcp-cred set <credential_id>, and call get_device_status. Full walkthrough, Windows paths, and Docker instructions: docs/INSTALLATION.md. Concept guide and worked examples: docs/USAGE.md.
Architecture
Seven layers, dependency flows one direction only:
flowchart TB
Transport["MCP Tool Layer -- inventory.*, connection.*, policy/network/routing/vip.*, vpn.*, system.*, vdom.*, analysis.*, doc.*, fleet.*, intent.*, change.*"]
Services["Service Layer -- one Service per capability, mode enforcement, error translation"]
Domain["Domain / Analysis Engines -- pure functions: DiffEngine, policy analyzers, scoring"]
Repo["Repository Layer -- inventory/change/snapshot persistence"]
Adapters["Vendor Adapter Layer -- FortinetProductAdapter Protocol (the plugin boundary)"]
Clients["Vendor API Client -- FortiOSRestClient (httpx, persistent per-device connection)"]
Infra["Infra -- ConnectionManager, CredentialManager (keyring), SQLite/SQLAlchemy"]
Transport --> Services
Services --> Domain
Services --> Repo
Domain --> Repo
Repo --> Adapters
Adapters --> Clients
Services -.uses.-> Infra
FortinetProductAdapter is the only extensibility boundary: today FortiOSAdapter is the sole implementation, but adding another Fortinet product means writing one new adapter against the same Protocol -- nothing above that layer changes.
Operating Modes
Set via FORTINET_MCP_MODE (default full):
| Mode | Behavior |
|---|---|
read_only |
No mutation may even be previewed. |
safe |
Delete operations are rejected; create/update still require preview -> apply. |
full |
Every operation is allowed, but still requires preview -> apply -- there is no single-shot fast path in any mode. |
Security Model
- Device credentials are never a tool argument and never appear in a conversation.
inventory_register_device_pendingonly collects metadata (host, name, customer, site) and mints an opaquecredential_id; the actual secret is entered once, locally, viafortinet-mcp-cred set <credential_id>, straight into the OS credential store. connection_connect/ any tool needing a live session will fail with a clear "credential not provisioned" error until that CLI step is done -- there's no fallback path that lets a secret flow through MCP.- Two documented exceptions, both flagged directly in their tool descriptions: an IPsec tunnel's PSK (
vpn_create_ipsec_tunnel) and a local admin account's password (system_create_admin) are normal tool arguments, because FortiOS itself never returns them on GET -- there is no way to preview/diff them without the value passing through the call once.
Known Limitations
- No declarative "apply this desired state" tool. By design -- Claude composes the granular tools itself (see
intent.*for the pattern), rather than this server owning a Terraform/Ansible-style apply engine. - Docker + headless Linux: the credential manager wraps the OS
keyringlibrary. On a container/headless Linux host with no Secret Service daemon, you need thekeyrings.cryptfilefallback (not wired up by default) -- see docs/INSTALLATION.md. Native install on Windows/macOS/desktop Linux works out of the box. - SNMP: only v1/v2c communities are supported; no SNMPv3 users yet.
- No FortiManager/FortiWeb/other Fortinet product adapters yet -- the adapter Protocol supports it, nothing is implemented beyond FortiOS.
- Verified end-to-end with real HTTP traffic captured against a mocked FortiOS REST API; if you hit a real-device quirk, please open an issue with the FortiOS version and endpoint.
Testing
uv run pytest
548 tests, no external dependencies required (device interaction is mocked at the HTTP transport layer for the full suite).
Contributing
Issues and PRs welcome. If you're adding a new resource type, look at how the VPN or system-configuration domains were added (services/vpn_service.py, services/system_service.py, services/change_dispatch.py) -- every new mutating resource follows the same adapter -> change_dispatch -> service -> MCP tool pattern.
Author
Built and maintained by Nicola Serra.
License
MIT -- see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。