fix: attach MCP-created nodes/edges to a design (#225)
create_node/create_edge persisted rows with design_id=null when the client omitted it (the MCP write tools), so they existed in the DB but never rendered on the canvas until a container restart reconciled them. Both routes now fall back to the first design, matching bulk-approve. Also fix MCP resource reads (homelable://canvas, homelable://edges): the framework passes a pydantic AnyUrl, not a str, which raised "'AnyUrl' object has no attribute 'startswith'". Coerce to str. EdgeResponse now exposes design_id for symmetry with NodeResponse. ha-relevant: no
This commit is contained in:
@@ -21,6 +21,10 @@ ROUTES = {
|
||||
|
||||
|
||||
async def read_resource(uri: str) -> list[TextContent]:
|
||||
# The MCP framework hands us a pydantic AnyUrl, not a plain str, so string
|
||||
# ops like .startswith / dict lookups blow up with
|
||||
# "'AnyUrl' object has no attribute 'startswith'". Coerce to str first.
|
||||
uri = str(uri)
|
||||
if uri.startswith("homelable://nodes/") and uri != "homelable://nodes/":
|
||||
node_id = uri.split("/")[-1]
|
||||
data = await backend.get(f"/api/v1/nodes/{node_id}")
|
||||
|
||||
Reference in New Issue
Block a user