Getting started
By the end of this you will have a read-only API admin on a FortiGate, an MCP client that can reach it, and an answer back from the appliance confirming the whole path works.
Roughly ten minutes, most of it on the firewall.
What you need
Section titled “What you need”A FortiGate running FortiOS 6.4 or later, administrative access to it, and a
machine that can reach its management interface. You also need
uv installed, which is what uvx comes from.
-
Create a read-only admin profile
Section titled “Create a read-only admin profile”The API user needs a profile, and the built-in ones grant more than this server can use. Make one that grants read and nothing else.
In the web UI: System > Admin Profiles > Create New. Name it
readonly-apiand set every permission group you care about to Read. The groups that matter are System, Network, Firewall, and — if the appliance has radios — WiFi & Switch Controller.From the CLI, which is faster and less error-prone:
config system accprofileedit "readonly-api"set secfabgrp readset ftviewgrp readset authgrp readset sysgrp readset netgrp readset loggrp readset fwgrp readset vpngrp readset utmgrp readset wifi readnextend -
Create the REST API admin
Section titled “Create the REST API admin”System > Administrators > Create New > REST API Admin.
Give it a username, set Administrator Profile to
readonly-api, leave PKI Group disabled, and set Trusted Hosts to the address of the machine that will run the server.The CLI form, with the trusted host set to the machine you will run from:
config system api-useredit "mcp-readonly"set accprofile "readonly-api"set vdom "root"config trusthostedit 1set ipv4-trusthost 192.0.2.10 255.255.255.255nextendnextend -
Generate the token
Section titled “Generate the token”Saving the API admin in the web UI shows the token once, in a dialog. There is no way to retrieve it afterwards — you generate a new one instead — so copy it somewhere before closing.
From the CLI:
execute api-user generate-key mcp-readonly -
Check it from the command line first
Section titled “Check it from the command line first”Before involving an MCP client, confirm the credential works. This is the step that separates the token is wrong from the client configuration is wrong, and doing it now saves a confusing half hour later.
Terminal window curl -sk "https://fgt.example.com/api/v2/cmdb/system/global?access_token=YOUR_TOKEN" \| head -c 200A JSON body with
"status": "success"means the token, the trusted host, and the profile are all correct. HTTP 401 means the token is wrong or the source address is not in the trusted hosts list. -
Add the server to your MCP client
Section titled “Add the server to your MCP client”Terminal window claude mcp add fortigate \--env FORTIGATE_HOST=fgt.example.com \--env FORTIGATE_TOKEN=your-token \-- uvx mcfortigateIn
claude_desktop_config.json:{"mcpServers": {"fortigate": {"command": "uvx","args": ["mcfortigate"],"env": {"FORTIGATE_HOST": "fgt.example.com","FORTIGATE_TOKEN": "your-token"}}}}The server runs over stdio. The command is
uvx mcfortigate, and configuration arrives entirely through the environment:Terminal window FORTIGATE_HOST=fgt.example.com FORTIGATE_TOKEN=your-token uvx mcfortigateuvxfetches and runs the package without installing it anywhere permanent, so there is no virtualenv to manage and upgrades are automatic. -
Ask it something
Section titled “Ask it something”Restart the client so it picks up the new server, then ask:
What FortiGates can you reach?
The model calls
list_targetsand reports one appliance with its URL, VDOM, and auth mode. No credentials come back — they never leave the server process.Then ask for the appliance itself:
What model and firmware is it running?
That is
get_system_status, and a serial number in the answer means the whole path works, because the serial comes from a part of the FortiOS response that a broken read would have thrown away.
If something did not work
Section titled “If something did not work”A client that shows the server as failed usually has a configuration error rather than a connection problem. The server prints its version and its configured targets to stderr at startup, and clients that surface server logs will show it:
mcfortigate v2026.9.11 | targets: fgt.example.comIf that line says targets: none configured, the environment variables did not
reach the process, which is a client configuration problem rather than a
FortiGate one. Troubleshooting covers the rest.
Three questions worth asking first walks through what the tools are actually good at, using a real appliance.