ai.smithery/slhad-aha-mcp

平台与服务

by slhad

基于 TypeScript 的 Home Assistant MCP server,支持以编程方式管理实体、自动化与设备状态。

什么是 ai.smithery/slhad-aha-mcp

基于 TypeScript 的 Home Assistant MCP server,支持以编程方式管理实体、自动化与设备状态。

README

AHA Model Context Protocol (MCP) Server

Quick install links

STDIO

Install in VS Code

Install MCP Server

Others
smithery badge

Pretty useful to test it without IDE

AHA stands for Another Home Assistant MCP Server

This repository implements a Model Context Protocol (MCP) server for Home Assistant, providing a bridge between Home Assistant and MCP clients.

With this server, you can:

  • List and query Home Assistant entities (lights, sensors, switches, etc.)
  • Retrieve and update the state of entities
  • Call Home Assistant services (e.g., turn on/off devices)
  • Manage automations: list, create, update, and validate automations
  • Access and update the entity registry
  • Integrate and update Lovelace dashboards
  • Validate Home Assistant configuration
  • Search for entities by prefix or regex
  • Access entity sources and registry information

The server supports multiple transport methods:

  • STDIO: Traditional MCP client communication (default)
  • Server-Sent Events (SSE): Web-based real-time communication
  • Streamable HTTP: HTTP-based MCP communication for web integration

Table of Contents

Motivation

While exploring existing MCP server implementations for Home Assistant, I found that:

  • Many repositories did not provide a buildable or working Docker image, making deployment difficult or impossible.
  • Several projects did not actually implement the features or protocol described in their own README files.
  • Some solutions were outdated, unmaintained, or lacked clear documentation and test coverage.

This project aims to address these gaps by providing a reliable and fully functional MCP server with straightforward Docker support and a focus on real-world usability.

Special Mention: Most of the documentation in this project is generated or assisted by AI. As this is a side project (even though I work as a developer), I focus on building fun and working features, and prefer to review and accept generated documentation if it's good enough, rather than writing everything by hand.

Features

  • Home Assistant client integration
  • Entity registry and management
  • Automation and configuration MCP endpoints
  • Lovelace dashboard support
  • Multiple transport options: stdio, Server-Sent Events (SSE), and Streamable HTTP
  • TypeScript codebase with Vitest for testing
  • Docker support for easy deployment

Available Tools

This MCP server provides comprehensive tools for interacting with Home Assistant, including:

  • Automation Management: Create, update, delete, and trace automations
  • Entity Operations: Query and manipulate Home Assistant entities
  • Service Calls: Execute Home Assistant services
  • Configuration: Validate and manage Home Assistant configuration
  • Registry Access: Access entity and device registries
  • Config Entry Flow Helpers: Create and manage Home Assistant integration flows

⚠️ TOKEN COST WARNING

Important: Each tool definition consumes tokens in your LLM context, even if unused! Some tools (like update-lovelace-config) can cost 4,000+ tokens alone. Consider excluding unnecessary tools to minimize token consumption and maximize conversation efficiency.

For a complete list of all available tools with detailed descriptions and parameters, see the Tools Documentation.

Generating Tools Documentation

The tools documentation is automatically generated from the MCP server:

sh
npm run generate-docs

This command will:

  1. Extract all available tools from the MCP server using the inspector
  2. Generate a comprehensive markdown documentation file (tools.md)
  3. Clean up temporary files

Note: The tools documentation shows the server currently provides 39 tools for comprehensive Home Assistant integration.

Project Structure

  • src/ - Main source code
    • hass/ - Home Assistant client and helpers
    • server/ - MCP server implementations
    • mcpTransports.ts - Transport layer implementations (HTTP, SSE)
  • tests/ - Test files and Home Assistant config examples
  • scripts/ - Build and documentation generation scripts
  • Dockerfile - Containerization support
  • package.json - Project dependencies and scripts
  • tsconfig.json - TypeScript configuration
  • vitest.config.ts - Vitest test runner configuration

Example: Running the MCP Server

The MCP server supports multiple transport methods. You can run it using the same command and argument structure as in your mcp_settings.json.

1. Run with STDIO Transport (Default)

For traditional MCP client integration via stdio (server is launched by MCP client):

jsonc
{
  "type": "stdio",
  "command": "tsx",
  "args": [
    "c:/dev/git/aha-mcp/src/index.ts"
  ],
  "env": {
    "LIMIT_RESOURCES": "-1",
    "RESOURCES_TO_TOOLS": "true",
    "DEBUG": "true",
    "HASS_URL": "https://your-home-assistant.local:8123",
    "HASS_ACCESS_TOKEN": "<your_token_here>"
  }
}

2. Run with Server-Sent Events (SSE) Transport

For SSE-based MCP communication, you need to run the server separately and then configure the MCP client to connect via URL.

Step 1: Start the SSE server

bash
# Start the server with SSE transport using npm script
HASS_URL=https://your-home-assistant.local:8123 HASS_ACCESS_TOKEN=<your_token_here> npm run start:local:sse

# Or with additional configuration
RESOURCES_TO_TOOLS=true DEBUG=true HASS_URL=https://your-home-assistant.local:8123 HASS_ACCESS_TOKEN=<your_token_here> npm run start:local:sse

Step 2: Configure MCP client to connect via URL

jsonc
{
  "url": "http://localhost:8081/sse",
  "alwaysAllow": [
    // your allowed tools here
  ]
}

3. Run with Streamable HTTP Transport

For HTTP-based MCP communication, you need to run the server separately and then configure the MCP client to connect via URL.

Step 1: Start the HTTP server

bash
# Start the server with streamable HTTP transport using npm script
HASS_URL=https://your-home-assistant.local:8123 HASS_ACCESS_TOKEN=<your_token_here> npm run start:local:http

Step 2: Configure MCP client to connect via URL

jsonc
{
  "url": "http://localhost:8081/mcp",
  "alwaysAllow": [
    // your allowed tools here
  ]
}

4. Quick SSE Server Startup

Start the SSE server directly with npm scripts:

bash
# Set your Home Assistant credentials first
export HASS_URL=https://your-home-assistant.local:8123
export HASS_ACCESS_TOKEN=<your_token_here>

# Start SSE server with RESOURCES_TO_TOOLS enabled
RESOURCES_TO_TOOLS=true DEBUG=true npm run start:local:sse

Then configure your MCP client with:

jsonc
{
  "url": "http://localhost:3000/sse"
}

5. Run with Podman/Docker - STDIO Transport

For STDIO transport with containers:

jsonc
{
  "type": "stdio",
  "command": "podman",
  "args": [
    "run",
    "-i",
    "--rm",
    "-e",
    "HASS_URL=https://your-home-assistant.local:8123",
    "-e",
    "HASS_ACCESS_TOKEN=<your_token_here>",
    "ghcr.io/slhad/aha-mcp:latest"
  ]
}

6. Run with Podman/Docker - HTTP/SSE Server

For HTTP/SSE transports, run the server separately in a container:

Step 1: Start the server container

bash
# For SSE transport
podman run -p 8081:8081 -e HASS_URL=https://your-home-assistant.local:8123 -e HASS_ACCESS_TOKEN=<your_token_here> ghcr.io/slhad/aha-mcp -- sse

# For HTTP transport  
podman run -p 8081:8081 -e HASS_URL=https://your-home-assistant.local:8123 -e HASS_ACCESS_TOKEN=<your_token_here> ghcr.io/slhad/aha-mcp -- http

Step 2: Configure MCP client

jsonc
{
  "url": "http://localhost:3000/sse",  // for SSE
  // or
  "url": "http://localhost:3000/mcp"   // for HTTP
}

Replace <your_token_here> with your actual Home Assistant access token.

Environment Variables

The following environment variables can be set to configure the MCP server:

  • HASS_URL (required): The URL of your Home Assistant instance. Example: https://your-home-assistant.local:8123 (default in code: http://localhost:8123)
  • HASS_ACCESS_TOKEN (required): Long-lived access token for Home Assistant. The server will not start without this.
  • DEBUG: Set to true to enable debug logging. Default: false.
  • RESOURCES_TO_TOOLS: Set to true to enable mapping resources to tools. Default: false.
    • Detailed explanation: When enabled, this option exposes Home Assistant resources (such as entities, automations, and services) as individual tools for MCP clients. This is especially useful for clients or agents that can only interact with the server via tool-based interfaces, rather than through generic resource queries. It allows such clients to discover and use Home Assistant features as discrete, callable tools, improving compatibility and usability for tool-limited environments.
  • LIMIT_RESOURCES: Set to a number to limit the number of resources returned by the server. Default: unlimited.

Note: The server transport method is now controlled by command line arguments (sse or http) rather than environment variables.

Getting Started

Prerequisites

  • Node.js (v18+ recommended)
  • Docker (optional, for containerized deployment)

Installation

sh
npm install

Running the Server

For STDIO transport (launched by MCP client):

sh
# Set environment variables and run with npm
npm start

For HTTP/SSE transports (run server separately):

sh
# Run SSE server on port 8081
npm run start:local:sse

# Run HTTP server on port 8081:8081
npm run start:local:http

# Quick SSE server startup with environment variables
RESOURCES_TO_TOOLS=true DEBUG=true npm run start:local:sse

Then configure your MCP client to connect via URL:

  • SSE: "url": "http://localhost:3000/sse"
  • HTTP: "url": "http://localhost:8080/mcp"

Running Tests

sh
npm run test:short

Note: The unit tests currently run against a real Home Assistant instance and are not mocked yet. This means tests require a live Home Assistant server and valid credentials to execute successfully.

Docker Usage

Build and run the server in a Docker container:

sh
# Build the container
npm run docker

then follow :

For HTTP/SSE modes, then configure your MCP client with the appropriate URL:

  • SSE: "url": "http://localhost:3000/sse"
  • HTTP: "url": "http://localhost:8081/mcp"

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

License

See LICENSE for details.

常见问题

ai.smithery/slhad-aha-mcp 是什么?

基于 TypeScript 的 Home Assistant MCP server,支持以编程方式管理实体、自动化与设备状态。

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描123.0k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描123.0k

邮件模板

by alirezarezvani

Universal
热门

快速搭建生产可用的事务邮件系统:生成 React Email/MJML 模板,接入 Resend、Postmark、SendGrid 或 AWS SES,并支持本地预览、i18n、暗色模式、反垃圾优化与追踪埋点。

面向营销与服务场景,快速搭建高质量邮件模板,省去反复设计与切图成本,成熟度和社区认可都很高。

平台与服务
未扫描12.5k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
84.2k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
78.5k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
38.1k

评论