mirror of
https://github.com/jmagar/unraid-mcp.git
synced 2026-03-23 12:39:24 -07:00
fix: keys create mutation field, ToolError on failed ops, create_unique validation
- keys.py: fix create mutation to use correct ApiKey/ApiKeyWithSecret fields - keys.py: raise ToolError when create/update response contains no key data - notifications.py: add length validation to create_unique matching create action Resolves review threads PRRT_kwDOO6Hdxs50E50f PRRT_kwDOO6Hdxs50E50h PRRT_kwDOO6Hdxs50E50i PRRT_kwDOO6Hdxs50E2iB
This commit is contained in:
@@ -116,11 +116,7 @@ def register_keys_tool(mcp: FastMCP) -> None:
|
||||
data = await make_graphql_request(MUTATIONS["create"], {"input": input_data})
|
||||
created_key = (data.get("apiKey") or {}).get("create")
|
||||
if not created_key:
|
||||
return {
|
||||
"success": False,
|
||||
"key": {},
|
||||
"message": "API key creation failed: no data returned from server",
|
||||
}
|
||||
raise ToolError("Failed to create API key: no data returned from server")
|
||||
return {"success": True, "key": created_key}
|
||||
|
||||
if action == "update":
|
||||
@@ -134,11 +130,7 @@ def register_keys_tool(mcp: FastMCP) -> None:
|
||||
data = await make_graphql_request(MUTATIONS["update"], {"input": input_data})
|
||||
updated_key = (data.get("apiKey") or {}).get("update")
|
||||
if not updated_key:
|
||||
return {
|
||||
"success": False,
|
||||
"key": {},
|
||||
"message": "API key update failed: no data returned from server",
|
||||
}
|
||||
raise ToolError("Failed to update API key: no data returned from server")
|
||||
return {"success": True, "key": updated_key}
|
||||
|
||||
if action == "delete":
|
||||
|
||||
@@ -307,6 +307,14 @@ def register_notifications_tool(mcp: FastMCP) -> None:
|
||||
f"importance must be one of: {', '.join(sorted(_VALID_IMPORTANCE))}. "
|
||||
f"Got: '{importance}'"
|
||||
)
|
||||
if len(title) > 200:
|
||||
raise ToolError(f"title must be at most 200 characters (got {len(title)})")
|
||||
if len(subject) > 500:
|
||||
raise ToolError(f"subject must be at most 500 characters (got {len(subject)})")
|
||||
if len(description) > 2000:
|
||||
raise ToolError(
|
||||
f"description must be at most 2000 characters (got {len(description)})"
|
||||
)
|
||||
input_data = {
|
||||
"title": title,
|
||||
"subject": subject,
|
||||
|
||||
Reference in New Issue
Block a user