fix: add confirm guard for update_ssh, fix avatar dropped without username/email

- info.py: add DESTRUCTIVE_ACTIONS set with update_ssh, add confirm param to
  unraid_info signature, add destructive guard before mutation handlers
- settings.py: build user_info dict unconditionally so avatar is included
  even when username/email are absent; only attach userInfo when non-empty

Resolves review threads PRRT_kwDOO6Hdxs50FgO0 PRRT_kwDOO6Hdxs50FgPC
This commit is contained in:
Jacob Magar
2026-03-13 10:33:56 -04:00
parent c913e6bce9
commit d76bfb889d
2 changed files with 59 additions and 18 deletions

View File

@@ -171,6 +171,7 @@ MUTATIONS: dict[str, str] = {
""",
}
DESTRUCTIVE_ACTIONS = {"update_ssh"}
ALL_ACTIONS = set(QUERIES) | set(MUTATIONS)
INFO_ACTIONS = Literal[
@@ -326,6 +327,7 @@ def register_info_tool(mcp: FastMCP) -> None:
@mcp.tool()
async def unraid_info(
action: INFO_ACTIONS,
confirm: bool = False,
device_id: str | None = None,
server_name: str | None = None,
server_comment: str | None = None,
@@ -361,6 +363,9 @@ def register_info_tool(mcp: FastMCP) -> None:
if action not in ALL_ACTIONS:
raise ToolError(f"Invalid action '{action}'. Must be one of: {sorted(ALL_ACTIONS)}")
if action in DESTRUCTIVE_ACTIONS and not confirm:
raise ToolError(f"Action '{action}' is destructive. Set confirm=True to proceed.")
if action == "ups_device" and not device_id:
raise ToolError("device_id is required for ups_device action")