skip to content

Home Assistant

An agent for the home, for requests such as “turn off the garden lights”.

MCP server built into Home Assistant: the mcp_server integration, at /api/mcp
Transport Streamable HTTP
Authentication bearer: a long-lived access token of Home Assistant

Home Assistant serves the MCP server itself, once its mcp_server integration is set up: no separate server runs.

Home Assistant answers at /api/mcp on the port of its web interface, 8123 by default, at the address of the host that runs it, which only the installer knows: write that host in mcp.url below. When Home Assistant runs on the network of the same host as Ambrogio, as it does to discover the devices of the home, the server of Ambrogio reaches it as host.docker.internal, with extra_hosts: ["host.docker.internal:host-gateway"] in the server service of compose.yaml.

  1. In Home Assistant, add the integration “Model Context Protocol Server” (mcp_server) and expose to Assist the entities that Ambrogio may use.

  2. Create the token in your profile of Home Assistant, under Security, Long-lived access tokens, write it in .env as HOME_ASSISTANT_TOKEN, and pass the variable to the server of Ambrogio in compose.yaml:

    services:
    server:
    environment:
    HOME_ASSISTANT_TOKEN: ${HOME_ASSISTANT_TOKEN:?}
  3. Add the agent file agents/home-assistant.json, with the address of the Streamable HTTP endpoint of the MCP server in mcp.url:

    {
    "description": "Answers the household's requests about the home, with the tools of Home Assistant.",
    "instructions": "You handle the household's requests about the home with the tools of Home Assistant. Requests may come from speech recognition and contain misheard words; interpret them in context. Answer briefly.",
    "llm": {
    "provider": "mistral",
    "model": "mistral-medium-latest",
    "apiKeyEnv": "MISTRAL_API_KEY"
    },
    "maxToolCalls": 4,
    "mcp": {
    "url": "http://<home-assistant-host>:8123/api/mcp",
    "auth": {
    "type": "bearer",
    "tokenEnv": "HOME_ASSISTANT_TOKEN"
    }
    }
    }
  4. Restart with docker compose up -d.

Authentication: a bearer token: a long-lived access token of Home Assistant, which the agent file names through the variable HOME_ASSISTANT_TOKEN. The description, the instructions, the language model and maxToolCalls are an example: adapt them to the household. See Agents for every field of the file.