From 2bfd9df180cc4c9dcf18c96a4e8f9d34c7abcbc9 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 30 Jul 2026 21:12:56 +0200 Subject: [PATCH] fix(homeassistant): probe the MCP endpoint the hub actually serves The guest spec requested /mcp_server/sse, a path Home Assistant does not route. The hub answers 401 on any unknown path, so the assertion passed without ever reaching the MCP surface. Upstream serves it at /api/mcp. Co-Authored-By: Claude Opus 5 (1M context) --- roles/web-app-homeassistant/README.md | 4 ++-- roles/web-app-homeassistant/files/playwright/test-guest.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/web-app-homeassistant/README.md b/roles/web-app-homeassistant/README.md index aa7a871273..5b1462c051 100644 --- a/roles/web-app-homeassistant/README.md +++ b/roles/web-app-homeassistant/README.md @@ -6,7 +6,7 @@ ## Overview -This role deploys Home Assistant as a container on its own canonical domain behind the reverse proxy, with the configuration directory kept in a persistent volume. It renders a `configuration.yaml` that trusts the proxy through `use_x_forwarded_for` and the project-wide trusted-proxy CIDRs, and it attaches the hub to a shared overlay network. With Hermes Agent deployed alongside it, the role declares the hub as the MCP server of the deployment: an internal `/mcp_server/sse` endpoint plus the long-lived access token that MCP clients present. +This role deploys Home Assistant as a container on its own canonical domain behind the reverse proxy, with the configuration directory kept in a persistent volume. It renders a `configuration.yaml` that trusts the proxy through `use_x_forwarded_for` and the project-wide trusted-proxy CIDRs, and it attaches the hub to a shared overlay network. With Hermes Agent deployed alongside it, the role declares the hub as the MCP server of the deployment: an internal `/api/mcp` endpoint plus the long-lived access token that MCP clients present. ## Cosmos @@ -52,7 +52,7 @@ Solid `1:1` edges are fixed relationships; dashed `0..1` edges are conditional ( - **Containerized hub:** Runs the official Home Assistant image on both the Docker Compose and Swarm stacks behind the reverse proxy. - **Reverse-proxy trust:** Renders a `configuration.yaml` with `default_config`, `use_x_forwarded_for`, and the project-wide trusted-proxy CIDRs listed in `trusted_proxies`. In swarm the hub joins the proxy's own overlay, so the forwarded request arrives from that network rather than from the hub's, and trusting only the hub's subnet makes Home Assistant answer every proxied request with HTTP 400. - **Persistent configuration:** Mounts `/config` as a named volume and hands it to the container backup service when volume backups are part of the deployment. -- **MCP server contract:** Declares the built-in MCP server at `/mcp_server/sse` over streamable HTTP as an internal, bearer-token-authenticated endpoint, and generates the token that MCP clients present. Adding the MCP Server integration itself stays a Home Assistant onboarding step. +- **MCP server contract:** Declares the built-in MCP server at `/api/mcp` over streamable HTTP as an internal, bearer-token-authenticated endpoint, and generates the token that MCP clients present. Adding the MCP Server integration itself stays a Home Assistant onboarding step. - **Read-only tool policy:** Declares the MCP tool surface read-only, with mutating tools disabled. - **Guest MCP probe:** A Playwright spec asserts that an unauthenticated request to the MCP endpoint is never answered with a 2xx. - **Monitoring and dashboard entries:** Registers the hub with the metrics and dashboard services when those are part of the deployment. diff --git a/roles/web-app-homeassistant/files/playwright/test-guest.js b/roles/web-app-homeassistant/files/playwright/test-guest.js index c4f9096a5c..445937e4a6 100644 --- a/roles/web-app-homeassistant/files/playwright/test-guest.js +++ b/roles/web-app-homeassistant/files/playwright/test-guest.js @@ -14,7 +14,7 @@ exports.register = function (shared) { test("guest: the MCP endpoint rejects unauthenticated access", async ({ page }) => { test.skip(!shared.env.mcpEnabled, "MCP server integration is disabled in this variant"); - const response = await page.request.get(`${shared.env.baseUrl}/mcp_server/sse`, { + const response = await page.request.get(`${shared.env.baseUrl}/api/mcp`, { failOnStatusCode: false, }); expect(