Purpose
-------
Phase 5A + 5B tool manifest — 20 MCP tools (9 read-only + 11 write)
registered with the FastMCP server. Each tool function wires the
validated input through the six-layer pipeline: validator → policy →
executor → redactor → audit logger. Write tools add a HITL safety
gate step between policy and execution.
Responsibilities
----------------
- Define :func:`register_tools` which attaches all 9 Phase 5A tools.
- Define :func:`register_write_tools` which attaches all 11 Phase 5B
write tools.
- Each read tool function follows the six-layer pipeline.
- Each write tool function follows the same pipeline but calls
:func:`_run_tool_write` which inserts the safety gate (Layer 2.5)
between policy and execution.
Write tool pipeline (HITL gate)
--------------------------------
rate-limiter → policy → validator → **safety gate** → executor →
redactor → audit
Diagnostics
-----------
Domain: MCP
Levels:
L2 — lifecycle: tool called, tool returned
L3 — request details
L4 — deep trace
Contracts
---------
- Tool functions never raise for expected error conditions — they return
a structured error string that the MCP client sees as tool output.
- The :func:`register_tools` function is idempotent for a given
FastMCP instance.
- Tool functions always write one audit record per invocation, even on
policy denial or validation failure.
| str oct.mcp.tools._run_tool_write |
( |
str | tool_name, |
|
|
dict | raw_args ) |
|
protected |
Execute one write tool through the HITL-extended pipeline.
Pipeline: rate-limiter → policy → validator → safety gate →
executor → redactor → audit.
When the safety gate requires confirmation (``confirm=False`` in
args), returns a structured ``[oct-mcp requires_confirmation] …``
string without executing anything. The AI host must re-submit with
``confirm=True`` after the user approves.
Parameters
----------
tool_name
One of the 11 Phase 5B write tool names.
raw_args
Unvalidated dict from the MCP client.
Returns
-------
Redacted tool output string, a confirmation-required string, or a
structured error message.
Definition at line 221 of file tools.py.