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:
@@ -15,6 +15,7 @@ from fastmcp import FastMCP
|
||||
from ..config.logging import logger
|
||||
from .manager import subscription_manager
|
||||
from .queries import SNAPSHOT_ACTIONS
|
||||
from .snapshot import subscribe_once
|
||||
|
||||
|
||||
# Global flag to track subscription startup
|
||||
@@ -94,7 +95,7 @@ def register_subscription_resources(mcp: FastMCP) -> None:
|
||||
"""Real-time log stream data from subscription."""
|
||||
await ensure_subscriptions_started()
|
||||
data = await subscription_manager.get_resource_data("logFileSubscription")
|
||||
if data:
|
||||
if data is not None:
|
||||
return json.dumps(data, indent=2)
|
||||
return json.dumps(
|
||||
{
|
||||
@@ -118,6 +119,16 @@ def register_subscription_resources(mcp: FastMCP) -> None:
|
||||
"message": f"Subscription '{action}' failed: {last_error}",
|
||||
}
|
||||
)
|
||||
# When auto-start is disabled, fall back to a one-shot fetch so the
|
||||
# resource returns real data instead of a perpetual "connecting" placeholder.
|
||||
if not subscription_manager.auto_start_enabled:
|
||||
try:
|
||||
query_info = SNAPSHOT_ACTIONS.get(action)
|
||||
if query_info is not None:
|
||||
fallback_data = await subscribe_once(query_info)
|
||||
return json.dumps(fallback_data, indent=2)
|
||||
except Exception as e:
|
||||
logger.warning("[RESOURCE] On-demand fallback for '%s' failed: %s", action, e)
|
||||
return json.dumps(
|
||||
{
|
||||
"status": "connecting",
|
||||
|
||||
Reference in New Issue
Block a user