Skip to main content

Agent for interacting with Home Assistant REST API

Project description

Home Assistant Agent - A2A | AG-UI | MCP

PyPI - Version MCP Server PyPI - Downloads GitHub Repo stars GitHub forks GitHub contributors PyPI - License GitHub

GitHub last commit (by committer) GitHub pull requests GitHub closed pull requests GitHub issues

GitHub top language GitHub language count GitHub repo size GitHub repo file count (file type) PyPI - Wheel PyPI - Implementation

Version: 0.12.1

Overview

Home Assistant Agent MCP Server + A2A Agent

Agent for interacting with Home Assistant REST API

This repository is actively maintained - Contributions are welcome!

MCP

Using as an MCP Server

The MCP Server can be run in two modes: stdio (for local testing) or http (for networked access).

Environment Variables

  • HOME_ASSISTANT_URL: The URL of the target service.
  • HOME_ASSISTANT_TOKEN: The API token or access token.

Run in stdio mode (default):

export HOME_ASSISTANT_URL="http://localhost:8080"
export HOME_ASSISTANT_TOKEN="your_token"
home-assistant-mcp --transport "stdio"

Run in HTTP mode:

export HOME_ASSISTANT_URL="http://localhost:8080"
export HOME_ASSISTANT_TOKEN="your_token"
home-assistant-mcp --transport "http" --host "0.0.0.0" --port "8000"

A2A Agent

Run A2A Server

export HOME_ASSISTANT_URL="http://localhost:8080"
export HOME_ASSISTANT_TOKEN="your_token"
home-assistant-agent --provider openai --model-id gpt-4o --api-key sk-...

Security & Governance

This project is built on agent-utilities, inheriting enterprise-grade security and governance features.

Authentication & Authorization

Feature Description
OIDC Token Delegation RFC 8693 token exchange for user-context propagation from A2A → MCP
Eunomia Policies Fine-grained, policy-driven tool authorization (none, embedded, remote)
Scoped Credentials Tools execute with the caller's scoped identity where possible
3LO / OAuth / API Token Multiple auth strategies with graceful fallback

Eunomia Policy Enforcement

Eunomia provides a policy enforcement point for all tool calls:

  • Embedded mode: Load local mcp_policies.json for role-based access, sensitivity gating, and audit logging
  • Remote mode: Forward authorization decisions to a central Eunomia policy server for multi-agent governance
  • Enable via CLI: --eunomia-type embedded --eunomia-policy-file mcp_policies.json

Runtime Protections

Protection Description
Tool Guard Sensitivity detection with human-in-the-loop approval gating
Prompt Injection Defense Input scanning and repetition/loop guards
Content Filtering Output schema enforcement and cost budget controls
Stuck Loop Detection Automatic detection and recovery from agent loops
Context Limit Warnings Proactive alerts before context window exhaustion

Graph Agent Architecture

The A2A agent uses pydantic-graph orchestration with:

  • RouterNode: Lightweight classifier that routes queries to specialized domains
  • DomainNode: Focused executor with only relevant tools loaded, preventing tool hallucination
  • Approval Gates: Policy-driven approval workflows before sensitive operations
  • Usage Guards: Budget and rate limiting enforcement

Production Recommendation: Enable --eunomia-type embedded (or remote) + OIDC delegation + containerized deployment. See agent-utilities documentation for full policy configuration.

Docker

Build

docker build -t home-assistant-agent .

Run MCP Server

docker run -d \
  --name home-assistant-agent \
  -p 8000:8000 \
  -e TRANSPORT=http \
  -e HOME_ASSISTANT_URL="http://your-service:8080" \
  -e HOME_ASSISTANT_TOKEN="your_token" \
  knucklessg1/home-assistant-agent:latest

Deploy with Docker Compose

services:
  home-assistant-agent:
    image: knucklessg1/home-assistant-agent:latest
    environment:
      - HOST=0.0.0.0
      - PORT=8000
      - TRANSPORT=http
      - HOME_ASSISTANT_URL=http://your-service:8080
      - HOME_ASSISTANT_TOKEN=your_token
    ports:
      - 8000:8000

Configure mcp.json for AI Integration (e.g. Claude Desktop)

{
  "mcpServers": {
    "home-assistant": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "home-assistant-agent",
        "home-assistant-mcp"
      ],
      "env": {
        "HOME_ASSISTANT_URL": "http://your-service:8080",
        "HOME_ASSISTANT_TOKEN": "your_token"
      }
    }
  }
}

Install Python Package

python -m pip install home-assistant-agent
uv pip install home-assistant-agent

Repository Owners

GitHub followers GitHub User's stars

MCP Configuration Examples

stdio (recommended for local development)

{
  "mcpServers": {
    "home-assistant": {
      "command": ".venv/bin/home-assistant-mcp",
      "args": [],
      "env": {
        "HOME_ASSISTANT_URL": "",
        "HOME_ASSISTANT_TOKEN": ""
}
    }
  }
}

Streamable HTTP (recommended for production)

{
  "mcpServers": {
    "home-assistant": {
      "url": "http://localhost:8080/home-assistant-mcp/mcp"
    }
  }
}

Available MCP Tools

This server utilizes dynamic Action-Routed tools to optimize token overhead and maximize IDE compatibility.

Tool Name Description
ha_calendar Consolidated Action-Routed tool for calendar. Methods: list_calendars, get_calendar_events
ha_config Consolidated Action-Routed tool for config. Methods: status, config, components, check_config
ha_entities Consolidated Action-Routed tool for entities. Methods: get_entity_registry_display, extract_from_target, get_triggers_for_target, get_conditions_for_target, get_services_for_target
ha_events Consolidated Action-Routed tool for events. Methods: list_events, fire_event, subscribe_events
ha_history Consolidated Action-Routed tool for history. Methods: get_history
ha_logbook Consolidated Action-Routed tool for logbook. Methods: get_logbook, get_error_log
ha_panels Consolidated Action-Routed tool for panels. Methods: get_panels
ha_services Consolidated Action-Routed tool for services. Methods: list_services, call_service
ha_states Consolidated Action-Routed tool for states. Methods: list_states, get_state, update_state, delete_state
ha_system Consolidated Action-Routed tool for system. Methods: render_template, ping, handle_intent, validate_config
ha_voice Consolidated Action-Routed tool for voice. Methods: list_exposed_entities, expose_entities

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

home_assistant_agent-0.12.1.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

home_assistant_agent-0.12.1-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file home_assistant_agent-0.12.1.tar.gz.

File metadata

  • Download URL: home_assistant_agent-0.12.1.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for home_assistant_agent-0.12.1.tar.gz
Algorithm Hash digest
SHA256 9f73fccbd1f45a7accc58e727f2c8eff415707622cf1a7196ea82e419e53811b
MD5 43285a8a3c6b6d1018a3d700b114cf74
BLAKE2b-256 58d7d06cffec5110e46f97b25f81e4af9696ab3c65d60aaaee994605d470ccbe

See more details on using hashes here.

File details

Details for the file home_assistant_agent-0.12.1-py3-none-any.whl.

File metadata

File hashes

Hashes for home_assistant_agent-0.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a4039c75c0f4467b5e5d645cb425f73d2406d57ada17f48ff5d72ab57875d61
MD5 1fda9393976d12e6da548f0ab183c21e
BLAKE2b-256 a27c8cc025785980923c8d1bdcb3d34754373415e419a6569dcc70142080555e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page