diff --git a/tests/test_health.py b/tests/test_health.py index fdf9a67..dc5acfd 100644 --- a/tests/test_health.py +++ b/tests/test_health.py @@ -227,3 +227,20 @@ async def test_health_setup_action_returns_declined_message() -> None: or "declined" in result.lower() or "cancel" in result.lower() ) + + +@pytest.mark.asyncio +async def test_health_setup_declined_message_includes_manual_path() -> None: + """Declined setup message includes the exact credentials file path and variable names.""" + from unittest.mock import AsyncMock, MagicMock, patch + + from unraid_mcp.config.settings import CREDENTIALS_ENV_PATH + + tool_fn = _make_tool() + + with patch("unraid_mcp.tools.health.elicit_and_configure", new=AsyncMock(return_value=False)): + result = await tool_fn(action="setup", ctx=MagicMock()) + + assert str(CREDENTIALS_ENV_PATH) in result + assert "UNRAID_API_URL=" in result # inline variable shown + assert "UNRAID_API_KEY=" in result diff --git a/unraid_mcp/tools/health.py b/unraid_mcp/tools/health.py index 5b03aca..ab8ea68 100644 --- a/unraid_mcp/tools/health.py +++ b/unraid_mcp/tools/health.py @@ -12,6 +12,7 @@ from fastmcp import Context, FastMCP from ..config.logging import logger from ..config.settings import ( + CREDENTIALS_ENV_PATH, UNRAID_API_URL, UNRAID_MCP_HOST, UNRAID_MCP_PORT, @@ -72,14 +73,21 @@ def register_health_tool(mcp: FastMCP) -> None: raise ToolError(f"Invalid action '{action}'. Must be one of: {sorted(ALL_ACTIONS)}") if action == "setup": + configured = await elicit_and_configure(ctx) if configured: return ( "✅ Credentials configured successfully. You can now use all Unraid MCP tools." ) return ( - "⚠️ Credentials not configured. " - "Run `unraid_health action=setup` again to provide credentials." + f"⚠️ Credentials not configured.\n\n" + f"Your MCP client may not support elicitation, or setup was cancelled.\n\n" + f"**Manual setup** — create `{CREDENTIALS_ENV_PATH}` with:\n" + f"```\n" + f"UNRAID_API_URL=https://your-unraid-server:port\n" + f"UNRAID_API_KEY=your-api-key\n" + f"```\n\n" + f"Then run any Unraid tool to connect." ) with tool_error_handler("health", action, logger):