Valkyrian Labs

forti-cli

Latest releaseCILicense

forti reads FortiGate configuration and monitor data through the FortiOS REST API, and changes it through validated, stored plans. It is built on the forti-api SDK and shares its command engine with forti-mcp, so AI clients get the same bounded surface as you do at the terminal.

1forti configure                       # address, API key (hidden), client certificate, mode; checked2forti get firewall/policy             # or: forti get firewall policy3forti mcp install                     # the FortiGate tools for Claude Code and Codex, in ~/.forti4cd ~/.forti && claude                 # or: codex

At the terminal:

1forti get firewall/policy --fields policyid,name,action,status2forti plan set firewall/address LAN comment="office LAN"3forti apply 20261015-142233-a1b2c3    # the plan's id; needs a guarded or autonomous profile

What you get

Catalog

Every FortiOS 7.4.8 resource

360 tables, 127 singletons and 47 typed monitor endpoints, compiled into the binary. forti discover searches them and shows each one's attributes, key, risk tier and supported operations without a device. Other monitor paths are readable untyped.

Read

Narrow reads

FortiOS filters, field selection and paging, checked against the catalog before anything is sent. Device secrets (ENC ... values, passwords, keys) are redacted by default.

Change

Changes as plans

A plan reads the device, validates every operation against the SDK types, and stores the before-state, a field diff, the exact request body and a risk tier. Planning never changes the device. forti apply runs a plan once, checks it for drift first, verifies every change by re-reading it, and writes a rollback plan and an audit record.

Policy

Operating modes

Profiles are read-only by default. guarded profiles apply a plan only after a person approves it; autonomous profiles apply without approval, with every safeguard still on.

Setup

One home, many FortiGates

Profiles, credentials, certificates and plans live in ~/.forti. Copy, rename and edit profiles for a fleet of devices, and share one client certificate across them.

Security

Credentials kept out of sight

The API key is never an argument. It lives in the macOS Keychain or a 0600 file bound to its device, or is referenced as an environment variable or a command. TLS verification is always on.

Integrations

Scripts and AI clients

Every command takes --json for one stable envelope, and the exit status follows the error code. forti mcp install gives Claude Code and Codex the FortiGate tools in the ~/.forti workspace, with the agent skill and rules that keep the stored credentials out of the agent's reach.

Where to go next

Get started

Installation

APT, Homebrew or a source build, and a first check that it works.

Quick start

Configure a FortiGate, add a certificate, check it, and start an AI agent in ~/.forti.

Guides

Profiles and credentials

Several FortiGates: add, copy, rename and edit profiles, credential sources, TLS and forti doctor.

Client certificates

Made or reused by forti configure, the forti CA, the FortiGate commands, renewal and removal.

Discovering and reading

Resources, discover, get, filters, fields, paging and secret redaction.

Making changes

Stored plans, operating modes, approvals, apply, rollback plans, backups and risk tiers.

AI agent integration

The ~/.forti workspace for Claude Code and Codex, its deny rules, status, repair and removal.

Reference

Command reference

Every command and option, the output formats and the JSON envelope.

Configuration files

The forti home and its layout, migrating from 0.1, file modes, config.json keys and environment.

Exit codes

The stable error codes and the exit status each one maps to.

Security notes

What is stored where, redaction, TLS, and what modes do and do not stop.

Development

Building

Build options, the forti-api SDK, the resource catalog and the release profile.

Testing

Unit tests, the mock FortiOS integration suite, and CI.