Skip to main content
Glama
homebridge-events-mcp

homebridge-events-mcp

homebridge-events-mcp

kalt2212/mcpeventshkhb MCP server

Your home wakes your AI agent. An MCP server that turns what happens in a Homebridge home into events, and delivers them to an agent that was doing nothing, at no token cost, until that moment.

Full guide in Spanish: README.es.md. This English README covers the same core setup, the architecture, and the commands you need.

How it works

  Sensors and devices          Wake-up engine                    Your agent
  (doors, leak, smoke,  ──▶   homebridge-events-mcp   ──▶   Claude Code, OpenClaw,
   locks, garage, ...)        reads Homebridge, decides         Hermes, or any webhook
         │                    which changes matter                     │
         ▼                            ▲                                ▼
  Homebridge (web UI)  ───────────────┘                    wakes only when a watch fires:
                                                           "[home event: sensor.triggered]
                                                            Front Door: contact opened
                                                            note: Tell the user the front door opened."

  While nothing happens: the agent sleeps and uses 0 tokens.

In short: Homebridge reports what changes at home. This server keeps the watches you set and, only when one matches, wakes your agent with a one-line description and the note you wrote for it. The agent does not poll the house, so an idle home costs nothing in model calls.

Controlling a smart home from an agent is a solved problem. The other direction was not: the agent finding out by itself that the garage has been open for ten minutes, and doing something about it.

Related MCP server: Phoenix MCP

What it is for

You run Homebridge on a Raspberry Pi, a NAS or in Docker, and an always-on agent (OpenClaw, Hermes) that you talk to on WhatsApp or Telegram. You tell it once what matters:

  • "Wake up and tell me if the garage door stays open for 10 minutes."

  • "Between 23:00 and 07:00, tell me if the front door opens."

  • "If there is a leak, smoke or CO, tell me at once." (already set up for you)

From then on the agent sleeps until exactly that happens. It is then woken with one line saying what happened plus the note it wrote for itself, tells you on your own channel, and can act: turn a light on, or ask before it closes something.

Other ways to get this

Why they fall short

A HomeKit automation

It cannot reason, ask you, or tell you in a conversation

An agent that checks the home every 5 minutes

288 model calls a day to find out late

A script per rule

You write and maintain each one; the agent cannot make its own

Is it for you? It is for homes that run Homebridge. If you run Home Assistant, its own MCP server is the better fit. If your devices exist only in Apple's Home app and you have a Mac that stays on, HomeClaw talks to HomeKit natively. This project needs neither: it runs wherever Homebridge runs and works with any device that has a Homebridge plugin.

What you need before you start

  1. Node.js 22 or newer on the machine that will run this server (usually the same machine as Homebridge). Check with node --version.

  2. Homebridge with its web interface (homebridge-config-ui-x) and a user account for that interface.

  3. Homebridge in insecure mode. The Homebridge web interface needs this to read and control accessories. Start Homebridge with the -I flag, or turn on "Insecure Mode" in the Homebridge settings and restart. This project does not switch it on for you. If you use hb-service (the default), insecure mode is already on.

  4. An always-on agent that supports MCP (for example Claude Code, OpenClaw or Hermes Agent). Any MCP client works, but only some can be woken up by an event (see the compatibility table below).

This does not work with HomeKit alone, without Homebridge. An accessory paired with Apple Home does not accept a second controller.

Quickstart (about 60 seconds)

Run these commands on the machine where Homebridge runs. Replace openclaw with hermes, claude-code or webhook if that is your agent.

# 1. Install (needs Node.js 22+)
npm install -g homebridge-events-mcp

# 2. Create a working configuration in ~/.homebridge-events-mcp/
homebridge-events-mcp init --for openclaw

# 3. Check everything (Homebridge reachable, insecure mode, sensors found)
homebridge-events-mcp doctor --http --env-file ~/.homebridge-events-mcp/server.env \
  --config ~/.homebridge-events-mcp/agents.json --state ~/.homebridge-events-mcp/state.json

# 4. Start the server
homebridge-events-mcp --http --env-file ~/.homebridge-events-mcp/server.env \
  --config ~/.homebridge-events-mcp/agents.json --state ~/.homebridge-events-mcp/state.json

Before step 2, put your Homebridge password in HOMEBRIDGE_PASSWORD or fill it in ~/.homebridge-events-mcp/server.env after init runs. init never prints the password or the tokens.

What doctor looks like when everything is fine (sample output, names and counts will be your own):

 ok    Configuration read: a shared server for 1 agent: openclaw (control, woken through openclaw).
 ok    Signed in to Homebridge at http://127.0.0.1:8581 as "admin".
 ok    23 accessories, of which 6 sensors (doors, motion, leak, smoke) and 2 protected (...).

If something is wrong, doctor prints FAIL with the fix, for example:

 FAIL  Homebridge is not running in insecure mode, so its accessories cannot be read.
       -> Turn on "Insecure Mode" in the settings of the Homebridge web interface, and restart Homebridge.

Add --test-wake to doctor to send one real wake-up to each agent.

Then tell your agent what to watch in plain words, for example: "Watch the front door and tell me if it opens between 23:00 and 07:00."

Commands at a glance

Command

What it does

homebridge-events-mcp init --for <agent>

Writes the configuration, tokens and a systemd unit to ~/.homebridge-events-mcp/, and prints the next steps

homebridge-events-mcp doctor ...

Checks the setup and says how to fix problems. Changes nothing in your home

homebridge-events-mcp --http ...

Starts the shared server

homebridge-events-mcp --help

Lists every option

Run it as a service

init writes a systemd unit with the paths already set, which can only write in its own folder:

sudo cp ~/.homebridge-events-mcp/homebridge-events-mcp.service /etc/systemd/system/
sudo systemctl enable --now homebridge-events-mcp
journalctl -u homebridge-events-mcp -f      # also has the audit log

Quick start with Docker

For a Homebridge that runs in a container, there is a Dockerfile and examples/docker-compose.yml; the same init and doctor run as arguments to the image. The configuration and watches live in the /data volume. Set TZ to your time zone, because time windows (during) use the container clock. If your agent's gateway listens on the host's 127.0.0.1, the container needs network_mode: host.

How an agent uses it

Tool

What it does

list_accessories, get_accessory

What is in the home and its state

set_accessory

Change something (locks, garage doors and alarms need the security role)

watch_event

"Wake me when this happens", with a note to its future self; once, expiresInMinutes

wait_for_event

Block until something happens: works with any MCP client and any model

list_event_types, recent_events, list_watches, unwatch_event, claim_event

The rest

Five event types, each with filters (accessory, room, kinds, and during: "23:00-07:00" so nothing is delivered outside a time window):

Event

When

sensor.triggered / sensor.cleared

A door or window opens, motion, occupancy, leak, smoke, CO

security.changed

A lock, garage door or alarm changes state

state.held

Something has stayed in one state for N seconds: the door left open

accessory.changed

Anything else: lights, switches, readings (numeric ones only after a real step)

Watches an agent creates survive a restart of the server (--state). A watch whose accessory is not back yet is retried, and the agent is told if it can no longer be created.

Works with

Agent host

How it is woken

Checked against the real thing

Claude Code

A channel on the stdio connection

A live session woken end to end

OpenClaw

POST /hooks/wake on its gateway

Connects, lists the 10 tools, gateway accepts the wake-up and starts a run

Hermes Agent

A signed webhook route

Connects, gateway accepts the wake-up and starts a run

Anything with an HTTP entry point

A JSON POST, bearer token and/or Standard Webhooks signature

Covered by the integration tests

Clients with MCP Events (SEP-3415)

events/poll, events/stream, webhooks

Mastra's client: poll, push and webhook

Any other MCP client (opencode, OpenManus, ...)

wait_for_event

Connect and tool calls

ChatGPT, Grok (cloud)

Opt-in public mode, read-only by default; for ChatGPT set "webhookId": "event" on its agent, as OpenAI's guide asks

Built to OpenAI's and xAI's connector documentation

Several agents can share one home: each has its own token and role (read, control, security), changes are attributed to whoever made them, agents do not wake each other in loops, and claim_event keeps two of them from acting on the same event.

The Spanish guide (README.es.md) has the full setup for each agent, including opencode, OpenManus, the shared-server mode and the cloud mode.

What it costs in tokens

While nothing happens, nothing is spent: a sleeping agent, a blocked wait_for_event and an MCP Events subscription use no model turns.

Tokens (4 characters per token)

Having the server connected (tools and instructions)

~1,000 without watches, ~1,370 with

One wake-up

~45

An event returned by wait_for_event

~80

list_accessories, per accessory

~12

A test (test/tokenBudget.test.ts) keeps these from creeping up. At most 6 ordinary events a minute are pushed and the rest summarised; smoke, CO, leak and lock, garage or alarm events always get through.

Safety

  • Locks, garage doors and alarms cannot be operated unless an agent has the security role. Add devices a plugin exposes as plain switches to protected.

  • A password or token is never sent unencrypted to another machine unless you say so: an http:// address for Homebridge, a wake-up target or a shared server that is not this machine is refused until you add --allow-plain-http (or HOMEBRIDGE_EVENTS_ALLOW_PLAIN_HTTP=1, which init writes for you when you give it such an address). Normal on a home network, never across the internet.

  • Everything stays on your network by default. Opening it to cloud agents is a separate option, read-only unless you say otherwise per agent.

  • Names and values from the home are sanitised and always delivered as data inside a fixed format, never as instructions.

  • Secrets live in environment variables or an env file only you can read; the configuration file only names them. Every change an agent makes, and every refusal, is written to the server log (audit: agent "x" set "Desk Lamp" On=true).

Reference

homebridge-events-mcp --help, init --help and doctor --help list every option. The configuration file (--config):

{
  "protected": ["Garage Relay"],
  "numericSteps": { "CurrentTemperature": 0.5 },
  "agents": [
    {
      "name": "openclaw", "tokenEnv": "HB_TOKEN_OPENCLAW", "role": "control",
      "wake": {
        "type": "openclaw", "url": "http://127.0.0.1:18789/hooks/wake", "tokenEnv": "OPENCLAW_HOOK_TOKEN",
        "watches": [
          { "event": "sensor.triggered", "arguments": { "kinds": ["leak", "smoke", "co"] }, "note": "Emergency: tell the user." },
          { "event": "state.held", "arguments": { "accessory": "Garage Door", "characteristic": "CurrentDoorState", "equals": 0, "forSeconds": 600 }, "note": "The garage has been open for 10 minutes." }
        ]
      }
    }
  ]
}

watches in the file are yours: an agent cannot remove them. wake.type is openclaw, hermes or webhook. With a single agent over stdio (Claude Code) the file has a top-level watches list instead of agents.

Everything else (several agents, the bridge for Claude Code into a shared server, cloud mode, MCP Events details, every limit) is in the full guide, currently in Spanish.

Troubleshooting

  • doctor says insecure mode is off. Start Homebridge with -I, or turn on "Insecure Mode" in its settings, then restart it.

  • doctor says a watch will never fire because an accessory was not found. The name in the configuration must match the Homebridge name exactly. doctor suggests the closest match.

  • The agent is not woken, but the server runs. Run doctor --test-wake, then check the wake-up URL and token for that agent. For Claude Code, the channel only works when the server is loaded as a development channel (see the Spanish guide).

  • Watches disappear after a restart. Make sure you pass --state with a path that the server can write.

Status

Version 0.1, experimental. It builds on two things that can still change: MCP Events (SEP-3415, beta) and Claude Code channels (research preview).

Tested end to end against a real Homebridge 2.5 with simulated accessories: 349 unit tests and 39 integration tests, including a Homebridge restart, three agents with different roles, the packed package installed without development dependencies, and the path a new user follows (init, doctor, a watch, a server restart, the watch still waking the agent).

Homebridge must run in insecure mode (the default with hb-service), which is what its own interface needs to show accessories. Native HomeKit without Homebridge is not supported: an accessory paired with Apple Home does not accept a second controller.

Development

git clone https://github.com/kalt2212/mcpeventshkhb.git && cd mcpeventshkhb
npm ci                    # installs and builds
npm install -g .          # optional: run this checkout as homebridge-events-mcp

npm test                  # unit tests
npm run test:integration  # starts a real Homebridge with simulated accessories
npm run typecheck

Releases: run the Release workflow from the Actions tab, or push a tag vX.Y.Z matching version in package.json. It publishes a GitHub release with the tarball, and that same tarball on npm. npm accepts the workflow through trusted publishing (set up once in the package's settings on npmjs.com for this repository and release.yml, with nothing stored in GitHub) or through an NPM_TOKEN secret. A version is released once: running the workflow again on the same commit (or on its tag) only does what is missing, for example the npm publication.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Gives AI agents scoped, least-privilege access to Home Assistant, with per-token permissions, auditing, and 131 tools for managing smart home devices.
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to read Home Assistant entity states, call any service, and optionally apply named scene presets from a catalog using plain-English descriptions.
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to interact with Home Assistant through tiered, human-gated access: free reads and reversible comfort controls, while sensitive actions like locks, alarm, covers, and climate changes require per-operation human approval via Matrix.
      GPL 3.0