Self-hosted homelab infrastructure visualizer — interactive network diagram with live status monitoring
TypeScript diagramhomelabhomelab-infrastructure-observabilitynetworkproxmox-veself-hostedzigbeezwavezwave-js
fix(mcp): key node properties on `key`, not `name`
Pouzor87081ac926fc
diff --git a/mcp/app/tools.py b/mcp/app/tools.pyindex e376df5..3faefe4 100644--- a/mcp/app/tools.py+++ b/mcp/app/tools.py@@ -35,7 +35,12 @@ _NODE_FIELDS = {"hostname": {"type": "string"},"mac": {"type": "string", "description": "MAC address."},"os": {"type": "string", "description": "Operating system / distribution."},- "status": {"type": "string", "enum": ["online", "offline", "unknown", "pending"]},+ # Live observation, not a user setting: the inventory row keeps the freshest+ # one rather than the last writer, so an update only lands while the device's+ # status is still unknown (see link_facts in inventory_sync.py). Set it on+ # create; to change it later, point check_method/check_target at the device+ # and let the status checker observe it.+ "status": {"type": "string", "enum": ["online", "offline", "unknown", "pending"], "description": "Live status. Honoured on create; on update it is ignored unless the device's status is still unknown — the status checker owns it."},"check_method": {"type": "string", "description": "Status check method (ping, http, https, ssh, prometheus, tcp)."},"check_target": {"type": "string", "description": "Target host/URL used by the status check."},"services": {"type": "array", "items": {"type": "object"}, "description": "Running services detected or documented on the node."},@@ -52,15 +57,22 @@ _NODE_FIELDS = {"ram_gb": {"type": "number", "description": "RAM in gigabytes."},"disk_gb": {"type": "number", "description": "Disk capacity in gigabytes."},"show_hardware": {"type": "boolean", "description": "Display hardware specs on the node card."},+ # The field is `key`, not `name`: the backend keys properties on it, both to+ # merge them into the inventory row and to order them in the node's view+ # (`merge_properties` / `apply_view` in backend/app/services/inventory_sync.py).+ # A property with no `key` collapses with every other keyless one — send two+ # and the node draws one."properties": {"type": "array",- "description": "Arbitrary key/value metadata shown on the node.",+ "description": "Key/value metadata shown on the node. `key` is the identity: two properties sharing one are the same property.","items": {"type": "object",- "required": ["name", "value"],+ "required": ["key", "value"],"properties": {- "name": {"type": "string"},- "value": {"type": "string"},+ "key": {"type": "string"},+ "value": {"type": "string"},+ "icon": {"type": "string", "description": "Lucide icon name shown beside the value."},+ "visible": {"type": "boolean", "description": "Draw it on the node card. Default true."},},},},diff --git a/mcp/tests/test_tools.py b/mcp/tests/test_tools.pyindex 3e24758..c071fb4 100644--- a/mcp/tests/test_tools.py+++ b/mcp/tests/test_tools.py@@ -659,3 +659,32 @@ async def test_remove_from_zone_restores_absolute_positions(mock_backend):def test_zone_tools_are_registered():names = {t.name for t in TOOLS}assert {"create_zone", "list_zones", "add_to_zone", "remove_from_zone"} <= names+++def _property_item_schema(tool_name: str) -> dict:+ tool = next(t for t in TOOLS if t.name == tool_name)+ return tool.inputSchema["properties"]["properties"]["items"]+++def test_node_properties_are_keyed_on_key_not_name():+ """The backend keys a property on `key` (merge_properties / apply_view in+ backend/app/services/inventory_sync.py). The schema advertised `name`, so an+ AI client sent keyless properties: they all collapsed onto the empty key and+ a node given three of them drew one.+ """+ for tool_name in ("create_node", "update_node"):+ item = _property_item_schema(tool_name)+ assert item["required"] == ["key", "value"], (+ f"{tool_name} must require key/value — `name` is not a property field"+ )+ assert "name" not in item["properties"], f"{tool_name} still advertises `name`"+ assert {"key", "value", "icon", "visible"} == set(item["properties"])+++def test_update_node_documents_that_status_is_observed_not_set():+ """`status` on an update is dropped unless the device's status is unknown —+ the inventory row keeps the freshest observation, not the last writer. Left+ undocumented, the tool silently no-ops."""+ tool = next(t for t in TOOLS if t.name == "update_node")+ description = tool.inputSchema["properties"]["status"]["description"]+ assert "status checker" in description and "unknown" in description