fix: update GraphQL queries for Unraid API v4.21.0+#3
fix: update GraphQL queries for Unraid API v4.21.0+#3abra5umente wants to merge 1 commit intojmagar:mainfrom
Conversation
Update queries to match modern Unraid API schema (v4.21.0+, Unraid 7.1.4+):
**get_system_info:**
- Remove deprecated fields: codepage (use codename), apps (removed)
- Fix case sensitivity: speedmin/speedmax, vendorname/productname
- Update versions structure: core.{unraid,api,kernel}, packages.*
- Remove memory stats (moved to metrics query)
**get_metrics (new tool):**
- Add new tool for real-time CPU and memory utilization
- Query metrics.cpu for overall and per-core usage (CpuLoad objects)
- Query metrics.memory for RAM and swap stats
**health_check:**
- Remove deprecated versions.unraid field
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe changes remove deprecated Unraid version field from health.py and restructure system information retrieval in system.py to align with Unraid API v4.21.0+. A new get_metrics() tool is added to expose real-time system metrics for CPU, memory, and swap data. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
unraid_mcp/tools/health.py (1)
150-155: Pre-existing bug: Latency threshold conditions are in wrong order.The
elifbranch for> 10000is unreachable because any value exceeding 10000 also exceeds 5000, triggering the first branch. A 12-second latency would be marked "warning" instead of "degraded".This isn't introduced by this PR, but consider fixing while you're updating this file:
- if api_latency > 5000: # > 5 seconds - health_status = "warning" - issues.append(f"High API latency: {api_latency}ms") - elif api_latency > 10000: # > 10 seconds - health_status = "degraded" - issues.append(f"Very high API latency: {api_latency}ms") + if api_latency > 10000: # > 10 seconds + health_status = "degraded" + issues.append(f"Very high API latency: {api_latency}ms") + elif api_latency > 5000: # > 5 seconds + health_status = "warning" + issues.append(f"High API latency: {api_latency}ms")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
unraid_mcp/tools/health.py(1 hunks)unraid_mcp/tools/system.py(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
unraid_mcp/tools/system.py (3)
unraid_mcp/core/client.py (1)
make_graphql_request(51-133)unraid_mcp/core/exceptions.py (1)
ToolError(10-18)unraid_mcp/tools/storage.py (1)
format_bytes(241-249)
🪛 Ruff (0.14.7)
unraid_mcp/tools/system.py
252-252: Abstract raise to an inner function
(TRY301)
252-252: Avoid specifying long messages outside the exception class
(TRY003)
255-255: Dynamically typed expressions (typing.Any) are disallowed in b
(ANN401)
304-304: Consider moving this statement to an else block
(TRY300)
308-308: Avoid specifying long messages outside the exception class
(TRY003)
308-308: Use explicit conversion flag
Replace with conversion flag
(RUF010)
🔇 Additional comments (6)
unraid_mcp/tools/health.py (1)
35-36: LGTM on the API compatibility update.The comments correctly document the removal of the deprecated
versions.unraidfield for Unraid API v4.21.0+ compatibility.unraid_mcp/tools/system.py (5)
20-24: Good documentation of API schema changes.These comments provide helpful context for future maintainers about the Unraid API v4.21.0+ migration.
30-32: Verify the memoryidfield is sufficient.The query now only fetches
memory { id }. Per the comment at line 24, memory stats moved to the metrics query, but confirm this minimal query still returns a valid response (some GraphQL schemas require at least one scalar field).
69-80: LGTM on versions processing.The code correctly handles the new nested
versions.coreandversions.packagesstructure with proper null-safe access patterns.
272-283: LGTM on CPU metrics processing.Good defensive checks with
isinstance(cpus, list)andisinstance(c, dict). The fallback to"N/A"handles edge cases appropriately.
328-331: LGTM on the newget_metricstool registration.Follows the established pattern and the docstring clearly describes the tool's capabilities.
Summary
Updates GraphQL queries to work with modern Unraid API schema (v4.21.0+, Unraid 7.1.4+).
get_system_infoquery validation errors by removing deprecated fields and updating schema structureget_metricstool for real-time CPU and memory utilizationhealth_checkquery to remove deprecated version fieldChanges
get_system_infoquery fixes:codepagefield (replaced bycodename)appsfield (removed from schema)speedMin/speedMax→speedmin/speedmax,vendorName/productName→vendorname/productnameversionsstructure: nowcore { unraid api kernel }+packages { ... }New
get_metricstool:metricsendpoint for real-time utilization datahealth_checkfix:versions { unraid }fieldTest plan
get_system_inforeturns valid data without GraphQL errorsget_metricstool returns CPU and memory utilizationhealth_checkcompletes without errors🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Updates
✏️ Tip: You can customize this high-level summary in your review settings.