Skip to main content
Glama
FortiManager MCP Server

FortiManager MCP Server

by rstierli

policy_lookup

Simulate a firewall policy lookup for a traffic 5-tuple against a managed FortiGate device through FortiManager to determine which currently installed policy would match the traffic.

Instructions

Simulate a firewall policy lookup for a traffic 5-tuple against a managed device.

Proxies FortiGate's policy-lookup monitor API through FortiManager to ask "which policy would match this traffic right now" -- the same operation the FortiManager UI's Policy Lookup dialog performs. This queries the device's currently installed/active policy; it does not take a policy-package argument (the documented endpoint has none -- see module docstring).

Args: adom: ADOM name device: Managed device name (e.g. "FGT-HQ"). Accepts the "device[vdom]" bracket suffix used elsewhere in this codebase to target a specific VDOM. dest: Destination IPv4 address to test (e.g. "8.8.8.8") protocol: IP protocol number to test -- 6=TCP, 17=UDP, 1=ICMP, 47=GRE, 50=ESP, 51=AH, 58=ICMPv6, 132=SCTP. Sent to the device as both the protocol and protocol_number query fields, mirroring the one documented request/response pair in the How-To Guide where both fields carried the same value; the guide does not show a case where they differ. srcintf: Ingress interface name the traffic would arrive on (e.g. "internal"). Pass it: the How-To Guide example sends it, and FortiOS 7.6.7 answers a lookup without it with HTTP 424 and one with any (not an interface) with HTTP 400, both returned as device_proxy_error. Omitted from the query when not given. sourceip: Source IPv4 address to test (optional; omitted from the query when not given -- the How-To Guide's own example queried with this field empty) sourceport: Source port to test (optional; omitted when not given) destport: Destination port to test (optional; 0 -- "any port", per the How-To Guide example -- when not given) package: Informational only, NOT sent to the device. The FortiGate policy-lookup endpoint has no package selector; it always reflects whatever package is currently installed. Pass this if you want it echoed back (as package_hint) in the result to cross-check against what you expect to be installed.

Returns: dict: Lookup result with keys: - status: "success" or "error" - adom, device - package_hint: the caller-supplied package argument, echoed back unverified -- NOT confirmation that this package is what actually matched (named package_hint, not package, so it can't be misread as verified match data) - query: the traffic-tuple fields actually sent to the device - matched: bool from the device's results.success field when present, else None (the How-To Guide only documents the no-match case: {"success": false}; a positive match's full field set is not documented here, so it is not reshaped -- see result) - result: the raw results payload returned by the device, passed through unchanged - message: Error message if failed

Example: >>> result = await policy_lookup( ... adom="root", ... device="branch1_fgt", ... srcintf="vl_lan", ... protocol=6, ... dest="8.8.8.8", ... ) >>> result["matched"] False

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "adom": "<adom>",
      "device": "<device>",
      "dest": "<dest>",
      "protocol": "<protocol>"
    },
    "name": "policy_lookup"
  }
}

Input Schema

NameRequiredDescriptionDefault
adomYes
destYes
deviceYes
packageNo
srcintfNo
destportNo
protocolYes
sourceipNo
sourceportNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.12.0

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations supplied, the description carries the full behavioral burden and does so well: it discloses that srcintf is effectively mandatory on FortiOS 7.6.7 (HTTP 424 when omitted, HTTP 400 for 'any', both surfaced as device_proxy_error), that the query reflects only the installed package, that package is never sent to the device, and that matched may be None because only the no-match response is documented.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Structure is clear and front-loaded with the purpose, then Args, Returns and an Example. Some passages are longer than necessary -- the justification for sending protocol twice, the 'see module docstring' cross-reference, and the extended rationale for naming package_hint could be trimmed without losing meaning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 9-parameter tool with zero schema descriptions and no annotations, the description covers everything an agent needs: required vs optional inputs, error conditions, what is and is not sent to the device, and return semantics (including that package_hint is an unverified echo and result is raw passthrough) even though an output schema exists.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, and it does: it documents every parameter, including the IP protocol number mapping (6=TCP, 17=UDP, 1=ICMP, etc.), the device[vdom] bracket suffix convention, the srcintf requirement, and the omission/default behavior for sourceip, sourceport, destport and package.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Simulate a firewall policy lookup for a traffic 5-tuple against a managed device.' It further pins the operation down as proxying FortiGate's policy-lookup monitor API via FortiManager and identifies it with the UI's Policy Lookup dialog, which cleanly separates it from the CRUD siblings like get_firewall_policy or update_firewall_policy.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives clear context for when to use the tool -- answering 'which policy would match this traffic right now' against the currently installed package -- and explicitly rules out a policy-package argument. What is missing is an explicit pointer to alternatives, e.g. use get_firewall_policy to inspect configuration rather than simulate traffic.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools