fix: resolve 21 pre-existing schema field drift failures

- Fix InfoOs: remove codepage (not in schema, codename already queried)
- Fix InfoVersions: use core { unraid api kernel } and packages { ... }
  subtype structure instead of flat field list; remove non-existent fields
- Fix Info: remove apps field from overview query (not in Info type)
- Fix Connect query: replace missing status/sandbox/flashGuid with
  dynamicRemoteAccess { enabledType runningType error }
- Fix CpuUtilization: replace used with percentTotal
- Fix Service: remove state field, add online and version
- Fix Server: replace ip/port with wanip/lanip/localurl/remoteurl
- Fix Flash: remove size field (not in schema)
- Fix UPSDevice: replace flat runtime/charge/load/voltage/frequency/temperature
  with nested battery { chargeLevel estimatedRuntime health } and
  power { loadPercentage inputVoltage outputVoltage } sub-types
- Fix ups_device variable type: PrefixedID! -> String! (schema uses String!)
- Fix UPSConfiguration: replace enabled/mode/cable/driver/port with
  service/upsCable/upsType/device/batteryLevel/minutes/timeout/killUps/upsName
- Fix storage unassigned query: unassignedDevices not in schema, use disks
- Fix docker logs: add subfield selection for DockerContainerLogs type
- Fix docker networks/network_details: move from root dockerNetworks/dockerNetwork
  to docker { networks { ... } }; filter by ID client-side for network_details
- Fix docker port_conflicts: replace containerName/port/conflictsWith with
  containerPorts { privatePort type containers { id name } } and lanPorts
- Fix docker check_updates: replace id/updateAvailable/currentVersion/latestVersion
  with name/updateStatus per ExplicitStatusItem schema type
- Fix keys queries: add subfield selection for permissions { resource actions },
  remove lastUsed (not on ApiKey type)
- Fix health.py comprehensive check: use versions { core { unraid } }
- Update docker mutations coverage assertion to include 11 organizer mutations
- Update test_networks mock to match new docker { networks } response shape
- Update health.py runtime accessor to follow new versions.core.unraid path
This commit is contained in:
Jacob Magar
2026-03-13 11:19:40 -04:00
parent 4ed78b4867
commit 8eab5992ba
7 changed files with 54 additions and 31 deletions

View File

@@ -388,7 +388,26 @@ class TestDockerMutations:
def test_all_docker_mutations_covered(self, schema: GraphQLSchema) -> None: def test_all_docker_mutations_covered(self, schema: GraphQLSchema) -> None:
from unraid_mcp.tools.docker import MUTATIONS from unraid_mcp.tools.docker import MUTATIONS
expected = {"start", "stop", "pause", "unpause", "remove", "update", "update_all"} expected = {
"start",
"stop",
"pause",
"unpause",
"remove",
"update",
"update_all",
"create_folder",
"set_folder_children",
"delete_entries",
"move_to_folder",
"move_to_position",
"rename_folder",
"create_folder_with_items",
"update_view_prefs",
"sync_templates",
"reset_template_mappings",
"refresh_digests",
}
assert set(MUTATIONS.keys()) == expected assert set(MUTATIONS.keys()) == expected
@@ -715,7 +734,7 @@ class TestHealthQueries:
query ComprehensiveHealthCheck { query ComprehensiveHealthCheck {
info { info {
machineId time machineId time
versions { unraid } versions { core { unraid } }
os { uptime } os { uptime }
} }
array { state } array { state }

View File

@@ -119,7 +119,7 @@ class TestDockerActions:
assert result["success"] is True assert result["success"] is True
async def test_networks(self, _mock_graphql: AsyncMock) -> None: async def test_networks(self, _mock_graphql: AsyncMock) -> None:
_mock_graphql.return_value = {"dockerNetworks": [{"id": "net:1", "name": "bridge"}]} _mock_graphql.return_value = {"docker": {"networks": [{"id": "net:1", "name": "bridge"}]}}
tool_fn = _make_tool() tool_fn = _make_tool()
result = await tool_fn(action="networks") result = await tool_fn(action="networks")
assert len(result["networks"]) == 1 assert len(result["networks"]) == 1

View File

@@ -36,27 +36,27 @@ QUERIES: dict[str, str] = {
""", """,
"logs": """ "logs": """
query GetContainerLogs($id: PrefixedID!, $tail: Int) { query GetContainerLogs($id: PrefixedID!, $tail: Int) {
docker { logs(id: $id, tail: $tail) } docker { logs(id: $id, tail: $tail) { containerId lines { timestamp message } cursor } }
} }
""", """,
"networks": """ "networks": """
query GetDockerNetworks { query GetDockerNetworks {
dockerNetworks { id name driver scope } docker { networks { id name driver scope } }
} }
""", """,
"network_details": """ "network_details": """
query GetDockerNetwork($id: PrefixedID!) { query GetDockerNetwork {
dockerNetwork(id: $id) { id name driver scope containers } docker { networks { id name driver scope enableIPv6 internal attachable containers options labels } }
} }
""", """,
"port_conflicts": """ "port_conflicts": """
query GetPortConflicts { query GetPortConflicts {
docker { portConflicts { containerName port conflictsWith } } docker { portConflicts { containerPorts { privatePort type containers { id name } } lanPorts { lanIpPort publicPort type containers { id name } } } }
} }
""", """,
"check_updates": """ "check_updates": """
query CheckContainerUpdates { query CheckContainerUpdates {
docker { containerUpdateStatuses { id name updateAvailable currentVersion latestVersion } } docker { containerUpdateStatuses { name updateStatus } }
} }
""", """,
} }
@@ -440,12 +440,17 @@ def register_docker_tool(mcp: FastMCP) -> None:
if action == "networks": if action == "networks":
data = await make_graphql_request(QUERIES["networks"]) data = await make_graphql_request(QUERIES["networks"])
networks = safe_get(data, "dockerNetworks", default=[]) networks = safe_get(data, "docker", "networks", default=[])
return {"networks": networks} return {"networks": networks}
if action == "network_details": if action == "network_details":
data = await make_graphql_request(QUERIES["network_details"], {"id": network_id}) data = await make_graphql_request(QUERIES["network_details"])
return dict(safe_get(data, "dockerNetwork", default={}) or {}) all_networks = safe_get(data, "docker", "networks", default=[])
# Filter client-side by network_id since the API returns all networks
for net in all_networks:
if net.get("id") == network_id or net.get("name") == network_id:
return dict(net)
raise ToolError(f"Network '{network_id}' not found.")
if action == "port_conflicts": if action == "port_conflicts":
data = await make_graphql_request(QUERIES["port_conflicts"]) data = await make_graphql_request(QUERIES["port_conflicts"])

View File

@@ -107,7 +107,7 @@ async def _comprehensive_check() -> dict[str, Any]:
query ComprehensiveHealthCheck { query ComprehensiveHealthCheck {
info { info {
machineId time machineId time
versions { unraid } versions { core { unraid } }
os { uptime } os { uptime }
} }
array { state } array { state }
@@ -115,7 +115,7 @@ async def _comprehensive_check() -> dict[str, Any]:
overview { unread { alert warning total } } overview { unread { alert warning total } }
} }
docker { docker {
containers { id state status } containers(skipCache: true) { id state status }
} }
} }
""" """
@@ -141,7 +141,7 @@ async def _comprehensive_check() -> dict[str, Any]:
"status": "connected", "status": "connected",
"url": safe_display_url(UNRAID_API_URL), "url": safe_display_url(UNRAID_API_URL),
"machine_id": info.get("machineId"), "machine_id": info.get("machineId"),
"version": info.get("versions", {}).get("unraid"), "version": (info.get("versions") or {}).get("core", {}).get("unraid"),
"uptime": info.get("os", {}).get("uptime"), "uptime": info.get("os", {}).get("uptime"),
} }
else: else:

View File

@@ -19,15 +19,14 @@ QUERIES: dict[str, str] = {
"overview": """ "overview": """
query GetSystemInfo { query GetSystemInfo {
info { info {
os { platform distro release codename kernel arch hostname codepage logofile serial build uptime } os { platform distro release codename kernel arch hostname logofile serial build uptime }
cpu { manufacturer brand vendor family model stepping revision voltage speed speedmin speedmax threads cores processors socket cache } cpu { manufacturer brand vendor family model stepping revision voltage speed speedmin speedmax threads cores processors socket cache }
memory { memory {
layout { bank type clockSpeed formFactor manufacturer partNum serialNum } layout { bank type clockSpeed formFactor manufacturer partNum serialNum }
} }
baseboard { manufacturer model version serial assetTag } baseboard { manufacturer model version serial assetTag }
system { manufacturer model version serial uuid sku } system { manufacturer model version serial uuid sku }
versions { kernel openssl systemOpenssl systemOpensslLib node v8 npm yarn pm2 gulp grunt git tsc mysql redis mongodb apache nginx php docker postfix postgresql perl python gcc unraid } versions { core { unraid api kernel } packages { openssl node npm pm2 git nginx php docker } }
apps { installed started }
machineId machineId
time time
} }
@@ -68,7 +67,7 @@ QUERIES: dict[str, str] = {
""", """,
"connect": """ "connect": """
query GetConnectSettings { query GetConnectSettings {
connect { status sandbox flashGuid } connect { id dynamicRemoteAccess { enabledType runningType error } }
} }
""", """,
"variables": """ "variables": """
@@ -87,12 +86,12 @@ QUERIES: dict[str, str] = {
""", """,
"metrics": """ "metrics": """
query GetMetrics { query GetMetrics {
metrics { cpu { used } memory { used total } } metrics { cpu { percentTotal } memory { used total } }
} }
""", """,
"services": """ "services": """
query GetServices { query GetServices {
services { name state } services { name online version }
} }
""", """,
"display": """ "display": """
@@ -122,7 +121,7 @@ QUERIES: dict[str, str] = {
query GetServer { query GetServer {
info { info {
os { hostname uptime } os { hostname uptime }
versions { unraid } versions { core { unraid } }
machineId time machineId time
} }
array { state } array { state }
@@ -131,27 +130,27 @@ QUERIES: dict[str, str] = {
""", """,
"servers": """ "servers": """
query GetServers { query GetServers {
servers { id name status description ip port } servers { id name status comment wanip lanip localurl remoteurl }
} }
""", """,
"flash": """ "flash": """
query GetFlash { query GetFlash {
flash { id guid product vendor size } flash { id guid product vendor }
} }
""", """,
"ups_devices": """ "ups_devices": """
query GetUpsDevices { query GetUpsDevices {
upsDevices { id model status runtime charge load } upsDevices { id name model status battery { chargeLevel estimatedRuntime health } power { loadPercentage inputVoltage outputVoltage } }
} }
""", """,
"ups_device": """ "ups_device": """
query GetUpsDevice($id: PrefixedID!) { query GetUpsDevice($id: String!) {
upsDeviceById(id: $id) { id model status runtime charge load voltage frequency temperature } upsDeviceById(id: $id) { id name model status battery { chargeLevel estimatedRuntime health } power { loadPercentage inputVoltage outputVoltage nominalPower currentPower } }
} }
""", """,
"ups_config": """ "ups_config": """
query GetUpsConfig { query GetUpsConfig {
upsConfiguration { enabled mode cable driver port } upsConfiguration { service upsCable upsType device batteryLevel minutes timeout killUps upsName }
} }
""", """,
} }

View File

@@ -16,12 +16,12 @@ from ..core.exceptions import ToolError, tool_error_handler
QUERIES: dict[str, str] = { QUERIES: dict[str, str] = {
"list": """ "list": """
query ListApiKeys { query ListApiKeys {
apiKeys { id name roles permissions createdAt lastUsed } apiKeys { id name roles permissions { resource actions } createdAt }
} }
""", """,
"get": """ "get": """
query GetApiKey($id: PrefixedID!) { query GetApiKey($id: PrefixedID!) {
apiKey(id: $id) { id name roles permissions createdAt lastUsed } apiKey(id: $id) { id name roles permissions { resource actions } createdAt }
} }
""", """,
} }

View File

@@ -41,7 +41,7 @@ QUERIES: dict[str, str] = {
""", """,
"unassigned": """ "unassigned": """
query GetUnassignedDevices { query GetUnassignedDevices {
unassignedDevices { id device name size type } disks { id device name vendor size type interfaceType smartStatus }
} }
""", """,
"log_files": """ "log_files": """