fsr-agentic-toolkit 0.2.3__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/AGENTS.md +6 -4
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/PKG-INFO +30 -43
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/README.md +26 -39
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/pyproject.toml +4 -4
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/cli.py +16 -1
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/init_cmd.py +5 -6
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/reference/AUTHORING.md +1 -0
- fsr_agentic_toolkit-0.3.2/src/fsr_agentic_toolkit/skills/widget-building/SKILL.md +127 -0
- fsr_agentic_toolkit-0.3.2/src/fsr_agentic_toolkit/verbs/hints.py +24 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/mcp.py +6 -25
- fsr_agentic_toolkit-0.3.2/src/fsr_agentic_toolkit/verbs/mcp_http.py +152 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/tools.py +296 -27
- fsr_agentic_toolkit-0.3.2/src/fsr_agentic_toolkit/widget_kit.py +836 -0
- fsr_agentic_toolkit-0.3.2/src/fsr_agentic_toolkit/widget_tools.py +148 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/connector_setup.py +1 -1
- fsr_agentic_toolkit-0.3.2/tests/fixtures/widget_edit_closes_without_wid.js +103 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_accuracy_guards.py +1 -1
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_agent_safety.py +22 -1
- fsr_agentic_toolkit-0.3.2/tests/test_mcp_http.py +127 -0
- fsr_agentic_toolkit-0.3.2/tests/test_nested_cap.py +97 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_skills_cmd.py +2 -1
- fsr_agentic_toolkit-0.3.2/tests/test_tool_deadline.py +67 -0
- fsr_agentic_toolkit-0.3.2/tests/test_tool_hints.py +105 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_whoami_auth_mode.py +3 -2
- fsr_agentic_toolkit-0.3.2/tests/test_widget_kit.py +196 -0
- fsr_agentic_toolkit-0.3.2/tests/test_widget_tools.py +71 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/uv.lock +1 -1
- fsr_agentic_toolkit-0.2.3/src/fsr_agentic_toolkit/verbs/approval.py +0 -194
- fsr_agentic_toolkit-0.2.3/tests/stub_mcp_server.py +0 -13
- fsr_agentic_toolkit-0.2.3/tests/test_approval.py +0 -319
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/.github/workflows/publish.yml +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/.github/workflows/tests.yml +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/.gitignore +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/Makefile +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/__init__.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/skills/alert-investigation/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/skills/box-onboarding/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/skills/connector-building/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/skills/connector-secrets/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/skills/debug-and-repair/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/skills/playbook-authoring/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/skills/prove-the-work/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/skills/use-case-building/SKILL.md +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/skills_cmd.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/spec.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/__init__.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/archetypes/__init__.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/archetypes/harvest.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/archetypes/record.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/archetypes/router.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/archetypes/seed/.gitkeep +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/archetypes/seed/reconcile-and-report.json +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/archetypes/store.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflow_tools.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/__init__.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/access.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/build.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/connector.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/debug.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/investigate.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/orient.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/provision.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/repair.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/result.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/run.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/workflows/verify.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/conftest.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/fixtures/workflows/heist_intake.yaml +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/silent_noop_scenario.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_archetypes.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_build_connector.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_cli_agent_init.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_compile_is_the_gate.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_connector_verbs.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_debug_doubled_iri.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_debug_reference_fix.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_debug_static_prerun.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_diagnose_run.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_find_and_bulk_update.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_init_codex_snippet.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_mcp.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_mcp_multi_instance.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_paging.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_picklist_dispatch.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_playbook_reference.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_provision_coerces_fields.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_provision_publish_and_probe.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_register_arg_gate.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_registered_mcp_tools.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_related_comments_count.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_run_playbook_yaml.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_run_verify_chain.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_schedules.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_search_fallback.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_setup_connector.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_silent_noop_scenario.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_tool_name_aliases.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_tools.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_workflow_debug_verify.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_workflow_first_surface.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_workflow_result.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_workflow_scenario.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/test_workflow_t2.py +0 -0
- {fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/tests/workflow_scenario.py +0 -0
|
@@ -54,9 +54,11 @@ its own (e.g. re-running `validate_connector` after a single edit).
|
|
|
54
54
|
## Safety knobs (set in the MCP server's `env`)
|
|
55
55
|
|
|
56
56
|
- `FSR_MCP_READONLY=1` - hide and refuse every mutating tool.
|
|
57
|
+
- `FSR_MCP_TOOL_TIMEOUT=<seconds>` - wall-clock ceiling on every tool call (default 120; `0` disables). A tool with its own `timeout` argument gets that plus 30s. A timed-out call returns a `ToolTimeout` error and may still finish on the appliance: read state back before retrying a mutating tool.
|
|
57
58
|
- `FSR_MCP_ALLOW_TOOLS` / `FSR_MCP_DENY_TOOLS` - comma-separated names or globs to
|
|
58
59
|
narrow the surface.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
|
|
61
|
+
Approval is the MCP client's job: the server does not prompt. Every tool is advertised with
|
|
62
|
+
`readOnlyHint` / `destructiveHint`, and the client asks the user from those (Claude Code users can
|
|
63
|
+
generate matching allow/ask rules with `fsr-agentic-toolkit permissions`). If the client reports
|
|
64
|
+
that the user declined a call, do not retry the same call: ask what they want.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: fsr-agentic-toolkit
|
|
3
|
-
Version: 0.2
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: The agent layer for FortiSOAR: workflows and tools behind one safety gate, served as an MCP server, CLI, and Python API, on pyfsr and fsr-playbooks.
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.11
|
|
7
|
-
Requires-Dist: fsr-playbooks>=0.
|
|
8
|
-
Requires-Dist: mcp<3,>=2.
|
|
7
|
+
Requires-Dist: fsr-playbooks>=0.14.0
|
|
8
|
+
Requires-Dist: mcp<3,>=2.3
|
|
9
9
|
Requires-Dist: pydantic>=2
|
|
10
|
-
Requires-Dist: pyfsr>=0.
|
|
10
|
+
Requires-Dist: pyfsr>=0.37.0
|
|
11
11
|
Requires-Dist: pyyaml>=6
|
|
12
12
|
Provides-Extra: dev
|
|
13
13
|
Requires-Dist: pytest>=8; extra == 'dev'
|
|
@@ -67,51 +67,23 @@ Every call goes through one gate. Writes are tier 2. Destructive tools are
|
|
|
67
67
|
tier 3 and need `confirm: true`. Environment policy:
|
|
68
68
|
|
|
69
69
|
- `FSR_MCP_READONLY=1` drops every write.
|
|
70
|
+
- `FSR_MCP_TOOL_TIMEOUT=<seconds>` caps every tool call (default 120; `0` disables); a timed-out call returns a `ToolTimeout` error instead of hanging the session.
|
|
70
71
|
- `FSR_MCP_ALLOW_TOOLS` / `FSR_MCP_DENY_TOOLS` take comma-separated names.
|
|
71
|
-
- `FSR_MCP_APPROVAL=auto|require|off` (default `auto`) puts every write to the **user** before
|
|
72
|
-
it runs.
|
|
73
72
|
|
|
74
|
-
### Approving writes
|
|
73
|
+
### Approving writes
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
Approval is the MCP client's job, so the server does not prompt. Coding agents already ask the
|
|
76
|
+
user before a tool runs, and they decide what to ask about from the standard annotations the
|
|
77
|
+
server advertises:
|
|
78
78
|
|
|
79
|
-
1. **Tool hints.** Every tool is advertised with `readOnlyHint` / `destructiveHint`,
|
|
80
|
-
|
|
81
|
-
2.
|
|
82
|
-
|
|
83
|
-
credential-shaped masked. Anything but an explicit yes does nothing and tells the model
|
|
84
|
-
not to retry. Reads never prompt, and a call the policy would refuse anyway is refused
|
|
85
|
-
without bothering the user.
|
|
86
|
-
|
|
87
|
-
`auto` asks when the client supports elicitation and otherwise runs the write, leaving it
|
|
88
|
-
to the client's own tool prompts. `require` refuses the write when the client cannot be
|
|
89
|
-
asked. `off` never asks.
|
|
79
|
+
1. **Tool hints.** Every tool is advertised with `readOnlyHint` / `destructiveHint`, derived
|
|
80
|
+
from its tier in the registry. A client uses them to decide what may run without asking.
|
|
81
|
+
2. **`confirm: true`.** Destructive tools also refuse to run without it, so a call that was
|
|
82
|
+
never meant to be destructive cannot become one by accident.
|
|
90
83
|
3. **Claude Code rules.** `fsr-agentic-toolkit permissions` prints (or `--write PATH` merges)
|
|
91
84
|
`allow` rules for every read and `ask` rules for every write, generated from the tool
|
|
92
|
-
registry
|
|
93
|
-
|
|
94
|
-
`FSR_MCP_APPROVAL_TIMEOUT` (seconds, default 300) bounds the wait: a client that accepts the
|
|
95
|
-
request but never answers (a headless run) gets a refusal, not a hang.
|
|
96
|
-
|
|
97
|
-
MCP has two protocol eras and the server speaks both. A client on the older one is sent the
|
|
98
|
-
approval request directly. On the 2026-07-28 protocol over stdio a server may not send requests
|
|
99
|
-
at all, so the server answers the call with an input-required result carrying the approval form;
|
|
100
|
-
the client asks the user and retries the same call with the answer, which is honoured only when
|
|
101
|
-
it matches that exact tool and arguments.
|
|
102
|
-
|
|
103
|
-
Measured with the real clients (each driven through its interactive UI with a person's
|
|
104
|
-
keystrokes, and headless), against a stub box:
|
|
105
|
-
|
|
106
|
-
| Client | Declares elicitation | Interactive approve / decline | Headless |
|
|
107
|
-
|---|---|---|---|
|
|
108
|
-
| Claude Code 2.1.312 | yes | prompt appears ("MCP server requests your input"), tick the box and Accept; works | declines, nothing written |
|
|
109
|
-
| Codex 0.165.0 | yes | prompt appears (`1. True / 2. False`); works | cancels, nothing written; also gates the write itself on the tool's hint |
|
|
110
|
-
| OpenCode 2.2.0 | yes | prompt appears (`1. Yes / 2. No`, No by default); works | never answers, so the timeout refuses it |
|
|
111
|
-
|
|
112
|
-
Gemini CLI, Cursor and Copilot were not available to test. A client that does not declare
|
|
113
|
-
elicitation falls back to `auto` (the write runs under that client's own tool prompts) or, with
|
|
114
|
-
`require`, is refused.
|
|
85
|
+
registry, so the client asks on exactly the tools that change the box. A write tool added
|
|
86
|
+
later is on neither list, so it prompts by default.
|
|
115
87
|
|
|
116
88
|
## Install and use
|
|
117
89
|
|
|
@@ -125,6 +97,21 @@ fsr-agentic-toolkit call search_records '{"module": "alerts", "limit": 5}'
|
|
|
125
97
|
fsr-agentic-toolkit mcp # MCP server on stdio
|
|
126
98
|
```
|
|
127
99
|
|
|
100
|
+
### Serve it to another machine (HTTP)
|
|
101
|
+
|
|
102
|
+
`mcp --http` serves the same server over streamable HTTP at `/mcp`, for a client on another machine (for example
|
|
103
|
+
FortiAgent on a laptop, with the server on a lab VM next to FortiSOAR). Every request needs
|
|
104
|
+
`Authorization: Bearer <token>`; the token comes from `$FSR_MCP_TOKEN` or `--token-file`; with neither, it generates
|
|
105
|
+
one at start and saves it, owner-only, to `~/.config/fsr-agentic-toolkit/mcp-token` (never printed). On a specific `--host` it also rejects foreign Host headers (DNS rebinding). With `--certfile`/`--keyfile` it serves HTTPS and prints the certificate's SHA-256
|
|
106
|
+
fingerprint at start.
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
FSR_MCP_TOKEN=<token> fsr-agentic-toolkit mcp --http --host 0.0.0.0 --port 8765 \
|
|
110
|
+
--certfile cert.pem --keyfile key.pem
|
|
111
|
+
fortiagent mcp add "FortiSOAR" --url https://<vm>:8765/mcp --header "Authorization: Bearer <token>" \
|
|
112
|
+
--trust-fingerprint <sha256 printed at start>
|
|
113
|
+
```
|
|
114
|
+
|
|
128
115
|
## Agent skills
|
|
129
116
|
|
|
130
117
|
The toolkit ships skills that teach a coding agent how to use it well: playbook
|
|
@@ -49,51 +49,23 @@ Every call goes through one gate. Writes are tier 2. Destructive tools are
|
|
|
49
49
|
tier 3 and need `confirm: true`. Environment policy:
|
|
50
50
|
|
|
51
51
|
- `FSR_MCP_READONLY=1` drops every write.
|
|
52
|
+
- `FSR_MCP_TOOL_TIMEOUT=<seconds>` caps every tool call (default 120; `0` disables); a timed-out call returns a `ToolTimeout` error instead of hanging the session.
|
|
52
53
|
- `FSR_MCP_ALLOW_TOOLS` / `FSR_MCP_DENY_TOOLS` take comma-separated names.
|
|
53
|
-
- `FSR_MCP_APPROVAL=auto|require|off` (default `auto`) puts every write to the **user** before
|
|
54
|
-
it runs.
|
|
55
54
|
|
|
56
|
-
### Approving writes
|
|
55
|
+
### Approving writes
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
Approval is the MCP client's job, so the server does not prompt. Coding agents already ask the
|
|
58
|
+
user before a tool runs, and they decide what to ask about from the standard annotations the
|
|
59
|
+
server advertises:
|
|
60
60
|
|
|
61
|
-
1. **Tool hints.** Every tool is advertised with `readOnlyHint` / `destructiveHint`,
|
|
62
|
-
|
|
63
|
-
2.
|
|
64
|
-
|
|
65
|
-
credential-shaped masked. Anything but an explicit yes does nothing and tells the model
|
|
66
|
-
not to retry. Reads never prompt, and a call the policy would refuse anyway is refused
|
|
67
|
-
without bothering the user.
|
|
68
|
-
|
|
69
|
-
`auto` asks when the client supports elicitation and otherwise runs the write, leaving it
|
|
70
|
-
to the client's own tool prompts. `require` refuses the write when the client cannot be
|
|
71
|
-
asked. `off` never asks.
|
|
61
|
+
1. **Tool hints.** Every tool is advertised with `readOnlyHint` / `destructiveHint`, derived
|
|
62
|
+
from its tier in the registry. A client uses them to decide what may run without asking.
|
|
63
|
+
2. **`confirm: true`.** Destructive tools also refuse to run without it, so a call that was
|
|
64
|
+
never meant to be destructive cannot become one by accident.
|
|
72
65
|
3. **Claude Code rules.** `fsr-agentic-toolkit permissions` prints (or `--write PATH` merges)
|
|
73
66
|
`allow` rules for every read and `ask` rules for every write, generated from the tool
|
|
74
|
-
registry
|
|
75
|
-
|
|
76
|
-
`FSR_MCP_APPROVAL_TIMEOUT` (seconds, default 300) bounds the wait: a client that accepts the
|
|
77
|
-
request but never answers (a headless run) gets a refusal, not a hang.
|
|
78
|
-
|
|
79
|
-
MCP has two protocol eras and the server speaks both. A client on the older one is sent the
|
|
80
|
-
approval request directly. On the 2026-07-28 protocol over stdio a server may not send requests
|
|
81
|
-
at all, so the server answers the call with an input-required result carrying the approval form;
|
|
82
|
-
the client asks the user and retries the same call with the answer, which is honoured only when
|
|
83
|
-
it matches that exact tool and arguments.
|
|
84
|
-
|
|
85
|
-
Measured with the real clients (each driven through its interactive UI with a person's
|
|
86
|
-
keystrokes, and headless), against a stub box:
|
|
87
|
-
|
|
88
|
-
| Client | Declares elicitation | Interactive approve / decline | Headless |
|
|
89
|
-
|---|---|---|---|
|
|
90
|
-
| Claude Code 2.1.312 | yes | prompt appears ("MCP server requests your input"), tick the box and Accept; works | declines, nothing written |
|
|
91
|
-
| Codex 0.165.0 | yes | prompt appears (`1. True / 2. False`); works | cancels, nothing written; also gates the write itself on the tool's hint |
|
|
92
|
-
| OpenCode 2.2.0 | yes | prompt appears (`1. Yes / 2. No`, No by default); works | never answers, so the timeout refuses it |
|
|
93
|
-
|
|
94
|
-
Gemini CLI, Cursor and Copilot were not available to test. A client that does not declare
|
|
95
|
-
elicitation falls back to `auto` (the write runs under that client's own tool prompts) or, with
|
|
96
|
-
`require`, is refused.
|
|
67
|
+
registry, so the client asks on exactly the tools that change the box. A write tool added
|
|
68
|
+
later is on neither list, so it prompts by default.
|
|
97
69
|
|
|
98
70
|
## Install and use
|
|
99
71
|
|
|
@@ -107,6 +79,21 @@ fsr-agentic-toolkit call search_records '{"module": "alerts", "limit": 5}'
|
|
|
107
79
|
fsr-agentic-toolkit mcp # MCP server on stdio
|
|
108
80
|
```
|
|
109
81
|
|
|
82
|
+
### Serve it to another machine (HTTP)
|
|
83
|
+
|
|
84
|
+
`mcp --http` serves the same server over streamable HTTP at `/mcp`, for a client on another machine (for example
|
|
85
|
+
FortiAgent on a laptop, with the server on a lab VM next to FortiSOAR). Every request needs
|
|
86
|
+
`Authorization: Bearer <token>`; the token comes from `$FSR_MCP_TOKEN` or `--token-file`; with neither, it generates
|
|
87
|
+
one at start and saves it, owner-only, to `~/.config/fsr-agentic-toolkit/mcp-token` (never printed). On a specific `--host` it also rejects foreign Host headers (DNS rebinding). With `--certfile`/`--keyfile` it serves HTTPS and prints the certificate's SHA-256
|
|
88
|
+
fingerprint at start.
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
FSR_MCP_TOKEN=<token> fsr-agentic-toolkit mcp --http --host 0.0.0.0 --port 8765 \
|
|
92
|
+
--certfile cert.pem --keyfile key.pem
|
|
93
|
+
fortiagent mcp add "FortiSOAR" --url https://<vm>:8765/mcp --header "Authorization: Bearer <token>" \
|
|
94
|
+
--trust-fingerprint <sha256 printed at start>
|
|
95
|
+
```
|
|
96
|
+
|
|
110
97
|
## Agent skills
|
|
111
98
|
|
|
112
99
|
The toolkit ships skills that teach a coding agent how to use it well: playbook
|
|
@@ -4,15 +4,15 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fsr-agentic-toolkit"
|
|
7
|
-
version = "0.2
|
|
7
|
+
version = "0.3.2"
|
|
8
8
|
description = "The agent layer for FortiSOAR: workflows and tools behind one safety gate, served as an MCP server, CLI, and Python API, on pyfsr and fsr-playbooks."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
license = { text = "MIT" }
|
|
12
12
|
dependencies = [
|
|
13
|
-
"pyfsr>=0.
|
|
14
|
-
"fsr-playbooks>=0.
|
|
15
|
-
"mcp>=2.
|
|
13
|
+
"pyfsr>=0.37.0",
|
|
14
|
+
"fsr-playbooks>=0.14.0",
|
|
15
|
+
"mcp>=2.3,<3",
|
|
16
16
|
"pydantic>=2",
|
|
17
17
|
"pyyaml>=6",
|
|
18
18
|
]
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
fsr-agentic-toolkit init --url fortisoar.example.com --api-key <key>
|
|
4
4
|
fsr-agentic-toolkit mcp # the MCP server (stdio)
|
|
5
|
+
fsr-agentic-toolkit mcp --http --port 8765 # the same server over HTTP (bearer token)
|
|
5
6
|
fsr-agentic-toolkit tools # what the gate lets through
|
|
6
7
|
fsr-agentic-toolkit debug-playbook-run --playbook-or-id "Close Alert"
|
|
7
8
|
fsr-agentic-toolkit survey-box --modules alerts,heists --json
|
|
@@ -98,6 +99,11 @@ def _tools(args: argparse.Namespace) -> int:
|
|
|
98
99
|
|
|
99
100
|
|
|
100
101
|
def _mcp(args: argparse.Namespace) -> int:
|
|
102
|
+
if args.http:
|
|
103
|
+
from .verbs.mcp_http import serve_http
|
|
104
|
+
|
|
105
|
+
serve_http(args.host, args.port, token_file=args.token_file, certfile=args.certfile, keyfile=args.keyfile)
|
|
106
|
+
return 0
|
|
101
107
|
from .verbs.mcp import main as serve
|
|
102
108
|
|
|
103
109
|
serve()
|
|
@@ -111,7 +117,16 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
111
117
|
sub = parser.add_subparsers(dest="command", required=True)
|
|
112
118
|
init_cmd.build_subparser(sub)
|
|
113
119
|
skills_cmd.build_subparser(sub)
|
|
114
|
-
sub.add_parser("mcp", help="run the MCP server
|
|
120
|
+
p_mcp = sub.add_parser("mcp", help="run the MCP server (stdio; --http to serve it over HTTP)")
|
|
121
|
+
p_mcp.add_argument("--http", action="store_true",
|
|
122
|
+
help="serve over streamable HTTP at /mcp instead of stdio")
|
|
123
|
+
p_mcp.add_argument("--host", default="127.0.0.1", help="--http: address to listen on (default 127.0.0.1)")
|
|
124
|
+
p_mcp.add_argument("--port", type=int, default=8765, help="--http: port (default 8765)")
|
|
125
|
+
p_mcp.add_argument("--token-file", help="--http: file holding the bearer token (else $FSR_MCP_TOKEN); "
|
|
126
|
+
"else one is generated into ~/.config/fsr-agentic-toolkit/mcp-token")
|
|
127
|
+
p_mcp.add_argument("--certfile", help="--http: TLS certificate (PEM); prints its SHA-256 fingerprint")
|
|
128
|
+
p_mcp.add_argument("--keyfile", help="--http: TLS private key (PEM)")
|
|
129
|
+
p_mcp.set_defaults(func=_mcp)
|
|
115
130
|
sub.add_parser("tools", help="list the tools the gate allows, with their tier").set_defaults(func=_tools)
|
|
116
131
|
p_call = sub.add_parser("call", help="call any tool by name with JSON arguments")
|
|
117
132
|
p_call.add_argument("tool")
|
|
@@ -214,10 +214,9 @@ def cmd_init(args: argparse.Namespace) -> int:
|
|
|
214
214
|
print(
|
|
215
215
|
"\nsafety: add FSR_MCP_READONLY=1 to the env block for a read-only surface, "
|
|
216
216
|
"or FSR_MCP_ALLOW_TOOLS/FSR_MCP_DENY_TOOLS to narrow it. Destructive tools "
|
|
217
|
-
"always need confirm=true.
|
|
218
|
-
"
|
|
219
|
-
"
|
|
220
|
-
"`fsr-agentic-toolkit permissions` prints matching allow/ask rules."
|
|
217
|
+
"always need confirm=true. Approval is left to the client: every tool is advertised "
|
|
218
|
+
"with read-only/destructive annotations, and the client asks the user from those. "
|
|
219
|
+
"For Claude Code, `fsr-agentic-toolkit permissions` prints matching allow/ask rules."
|
|
221
220
|
)
|
|
222
221
|
from .verbs.mcp import OPERATING_GUIDE
|
|
223
222
|
|
|
@@ -228,8 +227,8 @@ def cmd_init(args: argparse.Namespace) -> int:
|
|
|
228
227
|
def claude_permissions(server: str = "fortisoar") -> dict:
|
|
229
228
|
"""Claude Code ``permissions`` rules derived from the tool registry: every read is allowed,
|
|
230
229
|
every write asks in the terminal. A write tool added later is on neither list, so it
|
|
231
|
-
prompts by default.
|
|
232
|
-
|
|
230
|
+
prompts by default. Other clients decide from the tool annotations (verbs/hints.py); these
|
|
231
|
+
rules are the deterministic Claude Code layer on top."""
|
|
233
232
|
from .verbs.mcp import LIST_INSTANCES
|
|
234
233
|
from .verbs.tools import enabled_tools
|
|
235
234
|
|
|
@@ -41,6 +41,7 @@ playbooks:
|
|
|
41
41
|
description: optional
|
|
42
42
|
tag: optional
|
|
43
43
|
is_active: true # default true; set false for a disabled playbook
|
|
44
|
+
remote_executable: false # multi-tenancy: true lets a master run the pushed tenant copy (trigger_tenant_playbook)
|
|
44
45
|
owners: [TeamA, TeamB] # restrict who can run it (optional)
|
|
45
46
|
parameters: # names (+ optional types) for the
|
|
46
47
|
hostname: string # compiler's type checks ONLY -- runtime
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: widget-building
|
|
3
|
+
description: >-
|
|
4
|
+
Build, test, and validate a custom FortiSOAR widget (view and edit controllers,
|
|
5
|
+
info.json, a dashboard or view-panel tile). Use when someone needs a visualization
|
|
6
|
+
or tile the built-in dashboard builder cannot give them (for example a count across
|
|
7
|
+
several modules), when creating or changing a widget, or when checking that a widget
|
|
8
|
+
really works on a box before calling it done.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Building a FortiSOAR widget
|
|
12
|
+
|
|
13
|
+
A widget is a folder `widget/` with `info.json`, `view.html` + `view.controller.js`
|
|
14
|
+
(what users see) and `edit.html` + `edit.controller.js` (the config modal). It runs
|
|
15
|
+
inside the platform's AngularJS app and reads data through the same REST API you use,
|
|
16
|
+
mainly `POST /api/query/<module>`.
|
|
17
|
+
|
|
18
|
+
The toolkit does the whole job: `find_widgets`, `scaffold_widget`, `lint_widget`,
|
|
19
|
+
`deploy_widget`, `verify_widget`. Nothing else has to be installed. The widget devkit
|
|
20
|
+
(`github.com/ftnt-dspille/fsr-widget-devkit`) is optional, for browser tests against a mock
|
|
21
|
+
platform and for screenshots.
|
|
22
|
+
|
|
23
|
+
## 1. Is a widget needed?
|
|
24
|
+
|
|
25
|
+
The built-in dashboard widgets (Card Count, Chart, Grid, Card List) each bind to ONE
|
|
26
|
+
module and make one query. A number across modules needs a custom widget, or a scheduled
|
|
27
|
+
playbook that writes the total to a record. Call `find_widgets` first and report what
|
|
28
|
+
exists before building.
|
|
29
|
+
|
|
30
|
+
## 2. Design from the real data
|
|
31
|
+
|
|
32
|
+
`survey_box` for the modules, fields and picklists. Check the query on the box before
|
|
33
|
+
coding. Facts that bite:
|
|
34
|
+
|
|
35
|
+
- A count is an aggregate: `{"logic":"AND","filters":[...],"aggregates":[{"operator":"countdistinct","field":"*","alias":"total"}]}`;
|
|
36
|
+
read `hydra:member[0].total`. Never read rows to count them.
|
|
37
|
+
- Filter a picklist through `<field>.itemValue` with the field's real values, and name
|
|
38
|
+
the status field per module (it may differ).
|
|
39
|
+
- **"Not X" is `nin`, never `neq`.** `neq` silently drops records whose value is empty
|
|
40
|
+
(a field with 19 empty of 44 gave 15, not 34). `nin` keeps them. Use `nin` even for one value.
|
|
41
|
+
- A module the user cannot read, or that does not exist, returns HTTP 403 "Access Denied",
|
|
42
|
+
not 404. Show that module as failed, never as 0.
|
|
43
|
+
- Aggregates silently truncate at 5000 on group-by results.
|
|
44
|
+
- The module list in an edit form comes from `appModulesService.load(true)` (items have
|
|
45
|
+
`.type`, `.name`, `.system`). A module's picklist fields and their values come from
|
|
46
|
+
`GET api/3/model_metadatas?type=<module>` (`attributes[].dataSource.query`, posted to
|
|
47
|
+
`/api/query/picklists`).
|
|
48
|
+
- Pass `$`-params baked into the URL string; the harness drops `$params` objects.
|
|
49
|
+
|
|
50
|
+
## 3. Scaffold
|
|
51
|
+
|
|
52
|
+
`scaffold_widget` with an empty directory, a camelCase name and a title. It writes a working,
|
|
53
|
+
lint-clean widget (a single-module count with the platform's filter builder) that already
|
|
54
|
+
follows the patterns below, plus a pure logic file and a jest test. Change it from there; do
|
|
55
|
+
not start from a blank folder. Each widget is its own git repo; commit on a branch.
|
|
56
|
+
|
|
57
|
+
## 4. The patterns that matter (the scaffold has them; keep them)
|
|
58
|
+
|
|
59
|
+
- **The edit modal returns the config it was given.** The platform opens the modal with a copy
|
|
60
|
+
of the saved config and REPLACES the saved config with what the modal closes with. That copy
|
|
61
|
+
carries the platform's own keys (`wid` ties the save to the right widget on the dashboard). A
|
|
62
|
+
result built from scratch drops them: the save matches nothing, nothing persists, and the view
|
|
63
|
+
asks for configuration again. Start from the injected config
|
|
64
|
+
(`$scope.config = angular.extend({defaults}, config)`) and close with `$scope.config`. This
|
|
65
|
+
passes every unit test and the harness; only `lint_widget` and a real dashboard catch it.
|
|
66
|
+
- `config` and `$uibModalInstance` are `$uibModal` locals: list them in `$inject`, never
|
|
67
|
+
`$injector.get` them.
|
|
68
|
+
- Controller names are `<name><version digits>DevCtrl` and `edit<Name><digits>DevCtrl`. A bump
|
|
69
|
+
rewrites the digits; never edit them or `info.json` `version` by hand.
|
|
70
|
+
- Pure logic in `widget/widgetAssets/js/<name>.js`: a plain global plus `module.exports`, no AMD
|
|
71
|
+
or UMD `define` branch (the platform shell is RequireJS). Asset JS runs in arrival order, so
|
|
72
|
+
the controller waits for the global instead of reading it while it is being defined.
|
|
73
|
+
- Filters come from the platform's filter builder (`data-cs-conditional`, query mode), fed the
|
|
74
|
+
module's fields through `Entity`; broadcast `conditional:fieldListChanged` after the async
|
|
75
|
+
load or its field list stays empty. The saved `{logic, filters}` goes to `/api/query` as is.
|
|
76
|
+
A body with `filters` and no `logic` is silently ignored by the platform.
|
|
77
|
+
- Analyst-facing text: no tool names, ids, enum values, JSON paths or status codes, no emoji,
|
|
78
|
+
hyphens only. Handle failure per source: a failed module is shown as failed and the total
|
|
79
|
+
marked partial; if everything fails show no total, never zero.
|
|
80
|
+
|
|
81
|
+
## 5. Lint, after every change
|
|
82
|
+
|
|
83
|
+
`lint_widget` on the folder. It is offline and fast, and it is the check for bugs that pass
|
|
84
|
+
tests and fail on a box. Fix every error; read every warning. Each finding has a rule, a file,
|
|
85
|
+
a line and the fix. `deploy_widget` runs it and will not upload a widget that has an error.
|
|
86
|
+
Logic tests: `npx jest` in the widget folder (the scaffold includes them). A test for a fix
|
|
87
|
+
must be shown failing without the fix.
|
|
88
|
+
|
|
89
|
+
## 6. Install and read back
|
|
90
|
+
|
|
91
|
+
1. `deploy_widget` with the folder and `confirm: true`. It lints, packs, uploads, publishes and
|
|
92
|
+
waits until the version is live. Experimental boxes only. If the lint fails you get the
|
|
93
|
+
findings and nothing is uploaded.
|
|
94
|
+
2. `verify_widget` with the name and the version just installed. `ok: true` means that version
|
|
95
|
+
is live (installed, not a draft). The box reports no separate active flag.
|
|
96
|
+
3. Open the dashboard or report, add the widget, save its settings, reopen them, and check the
|
|
97
|
+
saved config persisted (the dashboard record's widget entry carries the settings). A widget
|
|
98
|
+
that renders in a harness has not proved its settings save.
|
|
99
|
+
|
|
100
|
+
With the widget devkit you can also run mock browser tests (`make test-e2e-spec`) and live
|
|
101
|
+
specs against a box; `make widget-push` there is a faster install loop.
|
|
102
|
+
|
|
103
|
+
## 7. Prove it
|
|
104
|
+
|
|
105
|
+
A widget that renders proves only that it drew.
|
|
106
|
+
|
|
107
|
+
- Compute the expected number independently with the API (read the records and count in
|
|
108
|
+
Python, not with the same filter the widget uses) and compare it with what the widget
|
|
109
|
+
shows, for each module and for the sum. Report both numbers.
|
|
110
|
+
- With the devkit, a live spec: `E2E_LIVE=1 FSR_ENV_FILE=<env file> make test-e2e-spec
|
|
111
|
+
SPEC="tests/e2e/<n>.live.spec.js"` (the filename must contain `live`; `FSR_ENV_FILE` is
|
|
112
|
+
mandatory). Assert the proxy host is the intended box, pass the expected numbers in as a file,
|
|
113
|
+
keep each test under 40 s, tag and delete any records it creates.
|
|
114
|
+
- Change a setting and check the number moves as expected. Exercise a failing module.
|
|
115
|
+
- Take a screenshot on real data and read it; clipped text and a squeezed layout never
|
|
116
|
+
fail an assertion.
|
|
117
|
+
- Say what you did not prove. A live spec renders the local source through the harness,
|
|
118
|
+
not the installed widget inside the real dashboard; the install is proven by
|
|
119
|
+
`verify_widget`, so say so, or add a check in the real UI.
|
|
120
|
+
|
|
121
|
+
## Rules that bite
|
|
122
|
+
|
|
123
|
+
- **Never install on a stable-role box** (a customer demo). Experimental boxes only,
|
|
124
|
+
unless the owner explicitly authorises a one-off install.
|
|
125
|
+
- No lab IPs, hostnames, credentials or capture dates in files that ship. Credentials come
|
|
126
|
+
from the env loader (`FortiSOAR.from_env_file`), never hand-parsed.
|
|
127
|
+
- Commit as the user, no AI attribution lines.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Tool annotations: how an MCP client learns which tools only read and which change things.
|
|
2
|
+
|
|
3
|
+
Approval is the MCP client's job. Every coding agent already asks the user before a tool runs,
|
|
4
|
+
and it decides what to ask about from the standard annotations a server advertises:
|
|
5
|
+
``readOnlyHint`` and ``destructiveHint``. This server therefore adds no prompt of its own; it
|
|
6
|
+
only makes sure those annotations are accurate, derived from each tool's tier in the registry.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from .tools import REGISTRY
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def tool_hints(name: str) -> dict[str, Any]:
|
|
16
|
+
"""``ToolAnnotations`` fields for a tool: reads are read-only, writes are not, the
|
|
17
|
+
irreversible ones are marked destructive. Every tool talks to an external system."""
|
|
18
|
+
spec = REGISTRY.get(name)
|
|
19
|
+
if spec is None: # the list_instances meta-tool and anything unregistered
|
|
20
|
+
return {"read_only_hint": True, "open_world_hint": False}
|
|
21
|
+
if not spec.mutating:
|
|
22
|
+
return {"read_only_hint": True, "open_world_hint": True}
|
|
23
|
+
return {"read_only_hint": False, "destructive_hint": bool(spec.destructive),
|
|
24
|
+
"idempotent_hint": False, "open_world_hint": True}
|
{fsr_agentic_toolkit-0.2.3 → fsr_agentic_toolkit-0.3.2}/src/fsr_agentic_toolkit/verbs/mcp.py
RENAMED
|
@@ -55,7 +55,7 @@ from pyfsr.client import FortiSOAR
|
|
|
55
55
|
from pyfsr.config import EnvConfig
|
|
56
56
|
from pyfsr.instances import InstanceRegistry
|
|
57
57
|
|
|
58
|
-
from .
|
|
58
|
+
from .hints import tool_hints
|
|
59
59
|
from .tools import dispatch, tool_schemas
|
|
60
60
|
|
|
61
61
|
if TYPE_CHECKING: # pragma: no cover - typing only
|
|
@@ -218,19 +218,6 @@ def _call(client: FortiSOAR, name: str, arguments: dict[str, Any] | None) -> lis
|
|
|
218
218
|
return _text_content(dispatch(client, name, arguments or {}))
|
|
219
219
|
|
|
220
220
|
|
|
221
|
-
def _target_label(registry: Any, instance: str | None) -> str:
|
|
222
|
-
"""'alias (https://host)' for the box a call will hit, shown in the approval prompt."""
|
|
223
|
-
try:
|
|
224
|
-
rows = registry.describe()
|
|
225
|
-
row = next((r for r in rows if r.get("instance") == instance), None) \
|
|
226
|
-
or next((r for r in rows if r.get("default")), None)
|
|
227
|
-
if row:
|
|
228
|
-
return f"{row.get('instance')} ({row['base_url']})" if row.get("base_url") else str(row.get("instance"))
|
|
229
|
-
except Exception: # noqa: BLE001, S110 - a label only; never block the prompt on it
|
|
230
|
-
pass
|
|
231
|
-
return instance or "the configured FortiSOAR box"
|
|
232
|
-
|
|
233
|
-
|
|
234
221
|
_CALL_LOCK = threading.Lock()
|
|
235
222
|
|
|
236
223
|
|
|
@@ -287,6 +274,10 @@ Principles:
|
|
|
287
274
|
from what was assumed.
|
|
288
275
|
- High-impact tools (provision_module, publish_module_changes, deletes) need confirm=true; tell the
|
|
289
276
|
user exactly what will change first.
|
|
277
|
+
- This server never exposes FortiSOAR's INTERNAL agent tool names (McpTaskCheck, McpTaskSubmit,
|
|
278
|
+
...); those belong to the box's own AI agents and are not callable here. For an AI investigation
|
|
279
|
+
task, poll get_investigation_result(task_id=..., wait=true) -- it blocks up to its timeout
|
|
280
|
+
argument and returns the verdict.
|
|
290
281
|
"""
|
|
291
282
|
|
|
292
283
|
|
|
@@ -309,17 +300,7 @@ def build_server(target: Any) -> Server:
|
|
|
309
300
|
return types.ListToolsResult(tools=_mcp_tools(registry))
|
|
310
301
|
|
|
311
302
|
async def on_call_tool(ctx: Any, params: Any) -> Any:
|
|
312
|
-
#
|
|
313
|
-
gate = await require_approval(
|
|
314
|
-
ctx.session, params.name, dict(params.arguments or {}),
|
|
315
|
-
_target_label(registry, (params.arguments or {}).get("instance")),
|
|
316
|
-
request_id=getattr(ctx, "request_id", None),
|
|
317
|
-
input_responses=getattr(params, "input_responses", None),
|
|
318
|
-
request_state=getattr(params, "request_state", None))
|
|
319
|
-
if gate is not None and not isinstance(gate, dict):
|
|
320
|
-
return gate # an InputRequiredResult: the client asks the user, then retries this call
|
|
321
|
-
if gate is not None:
|
|
322
|
-
return types.CallToolResult(content=_text_content(gate))
|
|
303
|
+
# Approval is left to the client, which decides from the tool annotations (verbs/hints.py).
|
|
323
304
|
# Handlers are synchronous and some run their own event loop (pyfsr's MCP client calls
|
|
324
305
|
# asyncio.run), which fails on this server's loop, so they run in a worker thread. The
|
|
325
306
|
# lock keeps them one at a time, as they were on the loop: workflows bind a process-wide
|