mirror of
https://github.com/jmagar/unraid-mcp.git
synced 2026-03-23 12:39:24 -07:00
fix: address 14 PR review comments from coderabbitai/chatgpt-codex
- guards.py: split confirm bypass into explicit check; use .get() for dict description to prevent KeyError on missing action keys - resources.py: use `is not None` for logs stream cache check; add on-demand subscribe_once fallback when auto_start is disabled so resources return real data instead of a perpetual "connecting" placeholder - setup.py: always prompt before overwriting credentials even on failed probe (transient outage ≠ bad credentials); update elicitation message - unraid.py: always elicit_reset_confirmation before overwriting creds; use asyncio.to_thread() for os.path.realpath() to avoid blocking async - test_health.py: update test for new always-prompt-on-overwrite behavior; add test for declined-reset on failed probe - test_resources.py: add tests for logs-stream None check, auto_start disabled fallback (success and failure), and fallback error recovery - test-tools.sh: add suite_live() covering cpu/memory/cpu_telemetry/ notifications_overview/log_tail; include in sequential and parallel runners - CLAUDE.md: correct unraid_live → live action reference; document that setup always prompts before overwriting; note subscribe_once fallback
This commit is contained in:
@@ -21,6 +21,7 @@ Actions:
|
||||
live - Real-time WebSocket subscription snapshots (11 subactions)
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
@@ -312,10 +313,20 @@ async def _handle_health(subaction: str, ctx: Context | None) -> dict[str, Any]
|
||||
connection_ok = True
|
||||
except Exception:
|
||||
connection_ok = False
|
||||
if connection_ok:
|
||||
reset = await elicit_reset_confirmation(ctx, safe_display_url(UNRAID_API_URL) or "")
|
||||
if not reset:
|
||||
return f"✅ Credentials already configured and working.\nURL: `{safe_display_url(UNRAID_API_URL)}`\n\nNo changes made."
|
||||
status_note = (
|
||||
"and working"
|
||||
if connection_ok
|
||||
else "but the connection test failed — may be a transient outage"
|
||||
)
|
||||
reset = await elicit_reset_confirmation(
|
||||
ctx,
|
||||
f"{safe_display_url(UNRAID_API_URL) or ''} ({status_note})",
|
||||
)
|
||||
if not reset:
|
||||
return (
|
||||
f"✅ Credentials already configured ({status_note}).\n"
|
||||
f"URL: `{safe_display_url(UNRAID_API_URL)}`\n\nNo changes made."
|
||||
)
|
||||
configured = await elicit_and_configure(ctx)
|
||||
if configured:
|
||||
return "✅ Credentials configured successfully. You can now use all Unraid MCP tools."
|
||||
@@ -641,7 +652,7 @@ async def _handle_disk(
|
||||
raise ToolError(f"tail_lines must be between 1 and {_MAX_TAIL_LINES}, got {tail_lines}")
|
||||
if not log_path:
|
||||
raise ToolError("log_path is required for disk/logs")
|
||||
normalized = os.path.realpath(log_path) # noqa: ASYNC240
|
||||
normalized = await asyncio.to_thread(os.path.realpath, log_path)
|
||||
if not any(normalized.startswith(p) for p in _ALLOWED_LOG_PREFIXES):
|
||||
raise ToolError(f"log_path must start with one of: {', '.join(_ALLOWED_LOG_PREFIXES)}")
|
||||
log_path = normalized
|
||||
|
||||
Reference in New Issue
Block a user