
Homebridge
io.github.mp-consulting由 GitHub 帳號 mp-consulting 發布v3.1.3更新於 Oct 26, 2026
Control Homebridge accessories and scenes, manage plugins and config.json, and read logs
概覽
給 Homebridge 用的 MCP 伺服器:讓助理列出並控制智慧家庭配件、執行情境、管理外掛與設定,並讀取日誌。
- 可以做什麼
- 列出、檢視並控制配件,支援帶 dryRun 的批次操作與感測器歷史
- 執行與儲存情境,並傳送測試通知
- 讀取、局部修改、備份與還原 config.json,以及整機備份
- 管理外掛:搜尋、版本、設定結構、更新日誌、安裝、更新、解除安裝
- 查看伺服器狀態、配對資訊、快取配件與子橋接,並重新啟動或停止它們
- 讀取最近日誌,並依時間、等級與外掛搜尋日誌
- 適用情境
- 適合讓助理操作既有的 Homebridge 環境:開關裝置、建立情境、依日誌排查裝置問題,或在不逐一點選介面的情況下檢視與修改設定和外掛。
- 執行需求
- 以 stdio 在本機執行(npm 套件、mcpb 擴充、Homebrew 或 npx)。需要 HOMEBRIDGE_URL 指向 Homebridge UI,並提供 HOMEBRIDGE_TOKEN,或 HOMEBRIDGE_USERNAME 與 HOMEBRIDGE_PASSWORD。情境、通知、外掛工作與配件歷史等工具需要 Homebridge Glass UI;日誌工具需要由 hb-service 管理的安裝。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Homebridge,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
@mp-consulting/homebridge-ai-kit
AI toolkit for Homebridge, in one package:
- An MCP server that lets AI assistants (Claude Desktop, Claude Code, Cursor) control accessories, manage plugins, edit configuration and read logs, over stdio or Streamable HTTP.
- The Assistant: provider adapters (Claude, OpenAI, Gemini, any OpenAI-compatible server), an agent loop wired to the MCP tools, and ready-made features (log doctor, config copilot, device-error explainer, update-risk briefing, organiser, daily digest). Homebridge Glass UI and the MP Consulting plugins use these.
- A Homebridge plugin (
HomebridgeAiKitplatform) with a settings page to pick the provider and model, test the connection, serve MCP over HTTP and generate client configs.
The AI building blocks that don't need MCP also ship on their own as @mp-consulting/homebridge-ai-core — see Packages.
Renamed from
@mp-consulting/homebridge-mcp-server. The oldhomebridge-mcp-servercommand still works, so existing MCP client configs don't need to change. See Migrating from homebridge-mcp-server.
Contents
- Packages
- Features
- Providers
- Homebridge plugin · MCP tokens
- MCP server
- Library API
- Security
- Migrating from homebridge-mcp-server
- Development
Packages
This repository is an npm workspace that publishes two packages, both at version 2.0.0:
Plugins should depend on ai-core, so installing them doesn't pull in the MCP SDK, socket.io or zod. ai-kit stays backward compatible: its . and ./plugin exports re-export everything ai-core has under the same names, so code that imports from ai-kit keeps working.
Features
MCP tools (43): accessories (list, get, control with value checks, bulk control with dryRun, locks / garage doors / alarms behind confirmation, room layout, sensor history), scenes (list, run, save), server (status, restart, pairing, cached accessories), child bridges (list, health, restart, stop, start), config (read with secrets redacted, full write, partial patch_config, dryRun diffs, backups and restore), instance backups, test notifications, plugins (list, search, versions, schema, changelog, install, update, uninstall), system info and logs (recent lines, filtered regex search).
MCP resources you can subscribe to: homebridge://accessories, homebridge://logs/recent, homebridge://status. Changes arrive over the Homebridge UI's socket.io namespaces, or by polling when the socket can't be used.
MCP resource templates (listed in resources/list, with completion): homebridge://accessory/{uniqueId} (one accessory with every characteristic), homebridge://plugin/{name} (one installed plugin and its child bridges; URL-encode scoped names), homebridge://child-bridge/{id} (one child bridge by username, with its health on Glass UI).
MCP prompts: diagnose-logs, plan-upgrade, audit-config, troubleshoot-device (device, symptom?), nightly-health-check (hours?), scene-builder (description, room?).
Assistant features (library): diagnoseLogs, generatePluginConfig, explainDeviceError, assessPluginUpdate, suggestOrganization, dailyDigest, ask, and runAgent for anything that needs the tools. Every input is redacted before it reaches a provider and trimmed to fit its context window; JSON outputs are checked against a schema with one automatic repair attempt; token usage and Claude costs are tracked.
Providers
All providers use plain fetch (no SDKs). Each declares what it can do, and features without tool calling fall back to prompt-only answers.
- Claude models:
claude-sonnet-5-5(default),claude-haiku-4-5-20251001(cheapest),claude-opus-5-5(most capable). - OpenAI models:
gpt-6.1-sol(default),gpt-6-luna(cheapest),gpt-6-astra(most capable). Requests use the Responses API withstore: false(nothing is kept on OpenAI's side); newer models only call tools through it. Set"openaiApi": "chat"to use Chat Completions instead, e.g. for a proxy that only speaks it. openai-compatibleworks with Ollama (http://127.0.0.1:11434/v1, the default), LM Studio (http://127.0.0.1:1234/v1), vLLM and similar. SetcontextTokensto your model's context window so inputs are trimmed correctly.- An on-device Apple Foundation Models provider is planned.
Homebridge plugin
Install it like any plugin (Homebridge 1.8+ or 2.x):
Then open its settings in the Homebridge UI. The settings page edits the HomebridgeAiKit platform block, tests the connection with the values in the form, and shows ready-to-paste configs for Claude Desktop, Claude Code and Cursor.
With mcp.http.enabled, the plugin serves MCP at http://<host>:<port>/mcp while Homebridge runs. It needs a client token (mcp.http.token, HOMEBRIDGE_AI_MCP_TOKEN, or at least one scoped token in mcp.http.clients) and Homebridge credentials: a Glass UI API token in homebridgeToken, or the HOMEBRIDGE_* environment variables. A read-only API token gives clients read-only access.
MCP tokens
The MCP server uses two different tokens:
Where to set or generate them:
- Homebridge Glass UI 2.0.0-beta.6 or later: Settings → Assistant → MCP server generates the client token, creates the Homebridge API token in one click (read-only or admin, revoked again when you replace or remove it), and shows the client configs. Each secret is shown once; after that the page only says whether one is set.
- This plugin's settings page: Generate creates a client token. Paste a Homebridge API token created in Glass UI under Users → API Tokens.
- The CLI: set
HOMEBRIDGE_AI_MCP_TOKENandHOMEBRIDGE_TOKEN(see MCP server), e.g.HOMEBRIDGE_AI_MCP_TOKEN=$(openssl rand -base64 24).
Client token scopes (each includes the ones before it):
The main client token is admin (as before), or read when readOnly is on; readOnly caps the scoped tokens too. A session belongs to the token that opened it. The client token decides which tools a client sees; the Homebridge API token still limits what the server itself can do, so a read API token keeps everything read-only.
Every write tool call is appended to an audit log (<Homebridge storage>/homebridge-ai-kit-audit.jsonl by default; mcp.http.auditLog / auditLogPath, or HOMEBRIDGE_AI_AUDIT_LOG for the CLI): one JSON object per line with ts, tool, args (secrets redacted), ok, error, session, client, principal (the token's name: default for the main token, agent for runAgent) and scope; notConfirmed: true marks a destructive call the user declined (MCP elicitation, or runAgent's confirm), which did not run. Dry runs are logged too, with dryRun: true in args. runAgent takes the same audit option. It rotates at 5 MB and keeps three old files.
Glass UI also stores homebridgeTokenId, the id of the API token it created, so it can revoke the token when you replace or remove it. The settings page keeps it (and any other field it doesn't show) when it saves.
Homebridge UI over HTTPS with a self-signed certificate
Node refuses a self-signed certificate, so the MCP server can't reach a Homebridge UI served that way until you tell it which certificate to trust. Verification is never turned off: the setting only applies to the server's requests to the Homebridge UI.
Get the fingerprint on the Homebridge machine with openssl x509 -noout -fingerprint -sha256 -in <certificate.pem> (Glass UI's self-signed certificate is <storage>/ssl-certs/certificate.pem); colons and case don't matter. Setting both requires the chain to validate against the PEM and the certificate to match the fingerprint. Update the fingerprint when the certificate is renewed. Both only apply to an https URL. Resource subscriptions then follow changes by polling, since the socket.io connection keeps Node's default verification.
Changes to mcp.http apply after a Homebridge restart, since the plugin starts the HTTP server when Homebridge loads it. Treat both tokens like passwords: anyone with the client token can use every tool the Homebridge API token allows.
Assistant routes for other plugins
A plugin's custom UI server can offer the Assistant with one call. Import the routes from @mp-consulting/homebridge-ai-core/plugin (ai-kit's ./plugin re-exports them, but plugins should depend on the slimmer ai-core). The browser side is MpKit.ai from @mp-consulting/homebridge-ui-kit:
With a requestId, the server streams ai:chunk { requestId, delta } events, then ai:done { requestId } or ai:error { requestId, message }. The routes read the HomebridgeAiKit block from config.json on every request, so settings changes apply at once.
MCP server
Install
The server is also listed in the MCP registry as io.github.mp-consulting/homebridge-ai-kit.
Environment
stdio (Claude Desktop, Claude Code, Cursor)
Streamable HTTP
The endpoint is http://127.0.0.1:8582/mcp. Every request needs Authorization: Bearer <HOMEBRIDGE_AI_MCP_TOKEN>. It binds to 127.0.0.1 by default; only use --host 0.0.0.0 on a trusted network, ideally behind HTTPS.
- Origin check. As the MCP spec requires, a request with an
Originheader (i.e. from a web page) is refused with403unless the origin is a loopback one (http://localhost:…,127.0.0.1,[::1]), the server's own IP address, or listed inHOMEBRIDGE_AI_MCP_ALLOWED_ORIGINS(plugin:mcp.http.allowedOrigins). This stops a malicious page from reaching the server through DNS rebinding. Desktop clients send noOriginand are unaffected. - Sessions close after 30 idle minutes, and at most 32 stay open. Sessions with an open stream are never idle. All sessions share one Homebridge change feed for
resources/subscribe. - Bad tokens. After 5 wrong tokens from one address, it must wait before trying again (
429withRetry-After, doubling up to 5 minutes); a correct token resets the count.
Tools
* Needs Homebridge Glass UI; with another Homebridge UI these tools answer with an error saying so.
- The list/get tools (
list_accessories,get_accessory,list_plugins,list_child_bridges,get_child_bridge_health,get_homebridge_status,get_server_status,search_logs,list_scenes) also returnstructuredContentmatching theiroutputSchema. set_accessorychecks the value against the characteristic first (format, min/max, step, valid values, write permission), coerces"50"to50or1totrue, and explains what is wrong instead of sending a bad value.- Locks, garage doors and security systems (
LockTargetState,TargetDoorState,SecuritySystemTargetState, or any characteristic of aLockMechanism,GarageDoorOpenerorSecuritySystemservice) are refused byset_accessory; they go throughset_security_accessory, which is annotateddestructiveHint: trueso MCP clients andrunAgentask the user before unlocking, opening or disarming anything. Lights and switches still change without a prompt. get_accessory_historyreturns an accessory's recorded sensor values (temperature, humidity, light level, battery, air quality, power, energy) over the lasthours(default 24, up to 8760), optionally for one characteristictype. Per series it givescount,min/max(value and when), the time-weightedavg,last, and thepointsaveraged down tomaxPoints(default 48, 2–500), with times in UTC to the minute. It needs Homebridge Glass UI (GET /api/accessories/:uniqueId/history), which records these values while Homebridge runs in insecure mode.patch_configchanges one platform or accessory block (found byplatform/accessoryplusname); objects merge,nullremoves a key, and__REDACTED__keeps the current secret.install_plugin,update_pluginanduninstall_pluginstart a job on the Homebridge UI and wait up to two minutes for it;get_plugin_jobfollows a longer one. They need Homebridge Glass UI (POST /api/plugins/install|update|uninstall,GET /api/plugins/jobs/:id).- The log tools need a Homebridge install managed by hb-service.
Library API
Everything in this table except runAgent comes from @mp-consulting/homebridge-ai-core and is re-exported here unchanged.
./mcp exports createServer, HomebridgeClient, runStdioServer, runHttpServer, createLiveSource, shareLiveSource, createAuditLog, the token SCOPES, and the TLS pinning helpers createTrustedFetch, normalizeFingerprint, pemFingerprints; ./plugin exports registerAiRoutes and testAiConnection (from ai-core's ./plugin), mcpClientSnippets and AiKitPlatform.
Security
- Secrets stay out of the model's context.
get_config,patch_configand the Assistant features replace passwords, tokens, API keys (including the AI KitapiKeyand MCP tokens) and the bridge pin with__REDACTED__. Writes swap the placeholders back for the real values.get_config'sincludeSecretsonly exists when the server opts in withHOMEBRIDGE_ALLOW_SECRETS=true(allowSecretsforcreateServer/runHttpServer), and never in read-only mode. Free text sent to a provider (logs, errors) has credential-shaped values masked too. - Destructive actions need consent. Every tool declares MCP
readOnlyHint/destructiveHint;runAgentrefuses destructive tools unless aconfirmcallback allows them. When the MCP client supports elicitation, the server itself asks the user to confirm each destructive tool call (arguments shown with secrets redacted; dry runs skip it; a declined or failed confirmation does not run the tool);HOMEBRIDGE_ELICITATION=falseturns that off. Unlocking a door, opening a garage door or disarming an alarm only works through the destructiveset_security_accessory, so it is confirmed too;set_accessoriesand scenes refuse those targets. Config writes can be previewed withdryRunand rolled back withrestore_config.HOMEBRIDGE_READ_ONLY=trueremoves write tools entirely. - Tool output is treated as data. Logs (tools and the
homebridge://logs/recentresource), changelogs and other Homebridge-sourced free text come back wrapped in<untrusted-data source="…">tags (runAgentwraps every tool result it sends to the model), with any tag inside the data defused (JSON results andstructuredContentstay plain data so they parse), and the base system prompt tells the model never to follow instructions found in tool output and to change things only when the user asked. Combined with confirmation for destructive tools, a log line saying "unlock the front door" can't open it. - HTTP is locked down. The HTTP transport requires a bearer token, compares it in constant time and binds to
127.0.0.1by default. It checksOrigin, expires idle sessions and slows down repeated bad tokens. - Least privilege and an audit trail. Extra client tokens can be limited to
readorcontrol, and every write tool call is logged with redacted arguments (see MCP tokens). update_configrejects incomplete configs, and regex log searches run in a worker thread that is killed after 5 seconds.- The server warns if
HOMEBRIDGE_URLsends credentials over plainhttpto a non-local host. - TLS verification stays on. A self-signed Homebridge UI certificate is trusted only through
HOMEBRIDGE_CERT_FINGERPRINT/HOMEBRIDGE_CERT_PATH(or the matchingmcp.httpsettings), and only for the requests to the Homebridge UI; a certificate that doesn't match is refused.
Migrating from homebridge-mcp-server
The package installs both homebridge-ai-kit and a homebridge-mcp-server alias, and the environment variables are unchanged, so existing configs keep working. New configs should use homebridge-ai-kit mcp. The MCP server now reports its name as homebridge-ai-kit, and library users import createServer and HomebridgeClient from @mp-consulting/homebridge-ai-kit/mcp.
Development
The repository is an npm workspace: the root is ai-kit and packages/ai-core is ai-core. The root scripts run both packages (ai-core first); npm run <script> -w packages/ai-core runs one script for ai-core alone. ai-kit's tests resolve @mp-consulting/homebridge-ai-core to its sources, while typecheck and build use ai-core's dist, so they build it first.
Publishing. The release workflow publishes @mp-consulting/homebridge-ai-core first (skipped if that version is already on npm), then @mp-consulting/homebridge-ai-kit, which depends on it. Both use npm trusted publishing (OIDC): before the first release, configure a trusted publisher on npmjs.com for the new @mp-consulting/homebridge-ai-core package name too (repository mp-consulting/homebridge-ai-kit, workflow publish.yml); if npm only lets you add one to an existing package, publish ai-core 2.0.0 once by hand from packages/ai-core. The first ai-core release has to go out before ai-kit 2.0.0 can be installed from npm.
After npm, the same workflow builds the Claude extension with scripts/make-mcpb.sh (the manifest template is mcpb/manifest.json; its tool list comes from scripts/mcpb-tools.mjs), signs it with mcpb sign when the DEVELOPER_ID_CERTIFICATE and DEVELOPER_ID_CERTIFICATE_PASSWORD secrets are set, attaches it to the release, and publishes server.json to the MCP registry (GitHub OIDC). The Homebrew formula in mp-consulting/homebrew-tap picks up each npm version on its own (every 6 hours).
License
MIT
來源:README.md,提交 e3be275
工具
0版本歷史
4- v3.1.3最新Oct 22, 2026
- v3.1.2Oct 22, 2026
- v3.1.1Oct 21, 2026
- v3.1.0Oct 18, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分