pyfsr.cli.appliance.ai

appliance.ai – the per-agent MCP tool allow-list of the FortiAI runtime (fsr-ai).

Binding an MCP server to an agent over REST (AIApi.allow_mcp_server_for_agent) is not enough for the agent to use its tools. At run time each agent’s ToolExecutionAgent loads only the tools named in the agent package’s own /opt/fsr-ai/ai-agents/<agent>_<version>/config/memory.yaml:

allowed_tools:
  "<mcp-server-uuid>": ["tool_a", "tool_b"]   # [] = the server's tools are blocked

A server that is bound over REST but absent from that file is silently never called: the investigation completes without it and nothing in the trace says why. No API exposes the file, so it has to be edited on the box. allow_mcp_tools() does that idempotently (it only ever adds tool names), keeps a one-time .orig backup, and can restart fsr-ai / fsr-ai-celery so the agents reload it.

The new text is passed as a command argument, never on stdin: the transports put the sudo password on stdin, and with passwordless sudo nothing consumes it, so it would land in the file. Live-verified on 8.0.0 and 8.0.1.

Attributes

Classes

Functions

parse(→ dict[str, list[str]])

The allowed_tools mapping (server uuid -> tool names) of a memory.yaml text.

add_tools(→ str)

Return memory.yaml text with tools allowed on mcp_uuid.

agent_dir(→ str)

The newest installed package directory of agent (siem -> .../siem_1_0_0).

memory_path(→ str)

Path of the agent's config/memory.yaml.

allowed_tools(→ dict[str, list[str]])

The agent's allow-list: MCP server uuid -> tool names. Read-only.

allow_mcp_tools(→ AllowChange)

Allow tools of the MCP server mcp_uuid for agent. Gated by yes.

Module Contents

pyfsr.cli.appliance.ai.AGENTS_DIR = '/opt/fsr-ai/ai-agents'[source]
pyfsr.cli.appliance.ai.SERVICES = ('fsr-ai', 'fsr-ai-celery')[source]
class pyfsr.cli.appliance.ai.AllowChange(/, **data: Any)[source]

Bases: pydantic.BaseModel

Outcome of allow_mcp_tools().

agent: str[source]
path: str[source]
mcp_uuid: str[source]
added: list[str] = None[source]
before: list[str] = None[source]
after: list[str] = None[source]
backup: str | None = None[source]
restarted: bool = False[source]
property changed: bool[source]

Whether the file was rewritten (False = every tool was already allowed).

property ok: bool[source]

Every requested tool is on the allow-list as read back from the box.

pyfsr.cli.appliance.ai.parse(text: str) → dict[str, list[str]][source]

The allowed_tools mapping (server uuid -> tool names) of a memory.yaml text.

pyfsr.cli.appliance.ai.add_tools(text: str, mcp_uuid: str, tools: list[str], *, comment: str = '') → str[source]

Return memory.yaml text with tools allowed on mcp_uuid.

An existing entry for the server is rewritten in place with the union of its tools (order kept, trailing comment kept); otherwise a new entry is appended to the allowed_tools block. Nothing is ever removed.

pyfsr.cli.appliance.ai.agent_dir(transport: pyfsr.cli.appliance.transport.Transport, agent: str) → str[source]

The newest installed package directory of agent (siem -> .../siem_1_0_0).

pyfsr.cli.appliance.ai.memory_path(transport: pyfsr.cli.appliance.transport.Transport, agent: str) → str[source]

Path of the agent’s config/memory.yaml.

pyfsr.cli.appliance.ai.allowed_tools(transport: pyfsr.cli.appliance.transport.Transport, agent: str) → dict[str, list[str]][source]

The agent’s allow-list: MCP server uuid -> tool names. Read-only.

pyfsr.cli.appliance.ai.allow_mcp_tools(transport: pyfsr.cli.appliance.transport.Transport, agent: str, mcp_uuid: str, tools: list[str], *, comment: str = '', restart: bool = False, yes: bool = False) → AllowChange[source]

Allow tools of the MCP server mcp_uuid for agent. Gated by yes.

A no-op (nothing written, no yes needed) when every tool is already allowed. Otherwise it keeps a one-time memory.yaml.orig, writes the merged file and reads it back so the result reports what is on disk. With restart=True it restarts fsr-ai and fsr-ai-celery afterwards (agents only load the file at start).