@coffeerunhobby/mcp-ha-connect 1.7.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +9 -9
- package/dist/config.js +10 -14
- package/dist/config.js.map +1 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.js +6 -6
- package/dist/resources/index.js.map +1 -1
- package/dist/server/auth.d.ts +1 -1
- package/dist/server/chatFace.d.ts +1 -1
- package/dist/server/chatFace.js +21 -16
- package/dist/server/chatFace.js.map +1 -1
- package/dist/server/common.d.ts +17 -1
- package/dist/server/common.js +48 -1
- package/dist/server/common.js.map +1 -1
- package/dist/server/stdio.js +1 -1
- package/dist/server/stdio.js.map +1 -1
- package/dist/server/stream.d.ts +2 -2
- package/dist/server/stream.js +2 -2
- package/dist/server/stream.js.map +1 -1
- package/dist/tools/ai/analyzeSensors.d.ts +1 -1
- package/dist/tools/ai/analyzeSensors.js +1 -1
- package/dist/tools/ai/analyzeSensors.js.map +1 -1
- package/dist/tools/ai/index.d.ts +1 -1
- package/dist/tools/common.d.ts +113 -328
- package/dist/tools/common.js +6 -6
- package/dist/tools/common.js.map +1 -1
- package/dist/tools/homeassistant/automationControls.d.ts +1 -1
- package/dist/tools/homeassistant/automationControls.js +4 -4
- package/dist/tools/homeassistant/automationControls.js.map +1 -1
- package/dist/tools/homeassistant/calendar.d.ts +1 -1
- package/dist/tools/homeassistant/calendar.js +2 -2
- package/dist/tools/homeassistant/calendar.js.map +1 -1
- package/dist/tools/homeassistant/callService.d.ts +1 -1
- package/dist/tools/homeassistant/callService.js +1 -1
- package/dist/tools/homeassistant/callService.js.map +1 -1
- package/dist/tools/homeassistant/controlClimate.d.ts +1 -1
- package/dist/tools/homeassistant/controlClimate.js +1 -1
- package/dist/tools/homeassistant/controlClimate.js.map +1 -1
- package/dist/tools/homeassistant/controlCover.d.ts +1 -1
- package/dist/tools/homeassistant/controlCover.js +1 -1
- package/dist/tools/homeassistant/controlCover.js.map +1 -1
- package/dist/tools/homeassistant/controlFan.d.ts +1 -1
- package/dist/tools/homeassistant/controlFan.js +1 -1
- package/dist/tools/homeassistant/controlFan.js.map +1 -1
- package/dist/tools/homeassistant/controlLight.d.ts +1 -1
- package/dist/tools/homeassistant/controlLight.js +1 -1
- package/dist/tools/homeassistant/controlLight.js.map +1 -1
- package/dist/tools/homeassistant/controlMediaPlayer.d.ts +1 -1
- package/dist/tools/homeassistant/controlMediaPlayer.js +1 -1
- package/dist/tools/homeassistant/controlMediaPlayer.js.map +1 -1
- package/dist/tools/homeassistant/createAutomation.d.ts +1 -1
- package/dist/tools/homeassistant/createAutomation.js +1 -1
- package/dist/tools/homeassistant/createAutomation.js.map +1 -1
- package/dist/tools/homeassistant/deleteAutomation.d.ts +1 -1
- package/dist/tools/homeassistant/deleteAutomation.js +1 -1
- package/dist/tools/homeassistant/deleteAutomation.js.map +1 -1
- package/dist/tools/homeassistant/entityAction.d.ts +1 -1
- package/dist/tools/homeassistant/entityAction.js +1 -1
- package/dist/tools/homeassistant/entityAction.js.map +1 -1
- package/dist/tools/homeassistant/entityGuard.d.ts +1 -1
- package/dist/tools/homeassistant/getAllSensors.d.ts +1 -1
- package/dist/tools/homeassistant/getAllSensors.js +1 -1
- package/dist/tools/homeassistant/getAllSensors.js.map +1 -1
- package/dist/tools/homeassistant/getAutomationTrace.d.ts +1 -1
- package/dist/tools/homeassistant/getAutomationTrace.js +1 -1
- package/dist/tools/homeassistant/getAutomationTrace.js.map +1 -1
- package/dist/tools/homeassistant/getDomainSummary.d.ts +2 -2
- package/dist/tools/homeassistant/getDomainSummary.js +1 -1
- package/dist/tools/homeassistant/getDomainSummary.js.map +1 -1
- package/dist/tools/homeassistant/getEntitiesByDomain.d.ts +1 -1
- package/dist/tools/homeassistant/getEntitiesByDomain.js +1 -1
- package/dist/tools/homeassistant/getEntitiesByDomain.js.map +1 -1
- package/dist/tools/homeassistant/getHistory.d.ts +1 -1
- package/dist/tools/homeassistant/getHistory.js +1 -1
- package/dist/tools/homeassistant/getHistory.js.map +1 -1
- package/dist/tools/homeassistant/getState.d.ts +1 -1
- package/dist/tools/homeassistant/getState.js +1 -1
- package/dist/tools/homeassistant/getState.js.map +1 -1
- package/dist/tools/homeassistant/getStates.d.ts +1 -1
- package/dist/tools/homeassistant/getStates.js +1 -1
- package/dist/tools/homeassistant/getStates.js.map +1 -1
- package/dist/tools/homeassistant/getVersion.d.ts +1 -1
- package/dist/tools/homeassistant/getVersion.js +1 -1
- package/dist/tools/homeassistant/getVersion.js.map +1 -1
- package/dist/tools/homeassistant/index.d.ts +1 -1
- package/dist/tools/homeassistant/listAutomations.d.ts +2 -2
- package/dist/tools/homeassistant/listAutomations.js +1 -1
- package/dist/tools/homeassistant/listAutomations.js.map +1 -1
- package/dist/tools/homeassistant/listEntities.d.ts +1 -1
- package/dist/tools/homeassistant/listEntities.js +1 -1
- package/dist/tools/homeassistant/listEntities.js.map +1 -1
- package/dist/tools/homeassistant/listPersons.d.ts +1 -1
- package/dist/tools/homeassistant/listPersons.js +1 -1
- package/dist/tools/homeassistant/listPersons.js.map +1 -1
- package/dist/tools/homeassistant/sceneAndScript.d.ts +1 -1
- package/dist/tools/homeassistant/sceneAndScript.js +2 -2
- package/dist/tools/homeassistant/sceneAndScript.js.map +1 -1
- package/dist/tools/homeassistant/searchEntities.d.ts +1 -1
- package/dist/tools/homeassistant/searchEntities.js +1 -1
- package/dist/tools/homeassistant/searchEntities.js.map +1 -1
- package/dist/tools/homeassistant/sendNotification.d.ts +1 -1
- package/dist/tools/homeassistant/sendNotification.js +2 -2
- package/dist/tools/homeassistant/sendNotification.js.map +1 -1
- package/dist/tools/homeassistant/systemTools.d.ts +1 -1
- package/dist/tools/homeassistant/systemTools.js +3 -3
- package/dist/tools/homeassistant/systemTools.js.map +1 -1
- package/dist/tools/homeassistant/triggerAutomation.d.ts +1 -1
- package/dist/tools/homeassistant/triggerAutomation.js +1 -1
- package/dist/tools/homeassistant/triggerAutomation.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/infra/index.d.ts +1 -1
- package/dist/tools/infra/index.js +1 -1
- package/dist/tools/infra/index.js.map +1 -1
- package/dist/tools/omada/blockClient.d.ts +1 -1
- package/dist/tools/omada/blockClient.js +1 -1
- package/dist/tools/omada/blockClient.js.map +1 -1
- package/dist/tools/omada/cyclePoePort.d.ts +1 -1
- package/dist/tools/omada/cyclePoePort.js +1 -1
- package/dist/tools/omada/cyclePoePort.js.map +1 -1
- package/dist/tools/omada/disableClientRateLimit.d.ts +1 -1
- package/dist/tools/omada/disableClientRateLimit.js +1 -1
- package/dist/tools/omada/disableClientRateLimit.js.map +1 -1
- package/dist/tools/omada/getClient.d.ts +1 -1
- package/dist/tools/omada/getClient.js +1 -1
- package/dist/tools/omada/getClient.js.map +1 -1
- package/dist/tools/omada/getDevice.d.ts +1 -1
- package/dist/tools/omada/getDevice.js +1 -1
- package/dist/tools/omada/getDevice.js.map +1 -1
- package/dist/tools/omada/getFirewallSetting.d.ts +1 -1
- package/dist/tools/omada/getFirewallSetting.js +1 -1
- package/dist/tools/omada/getFirewallSetting.js.map +1 -1
- package/dist/tools/omada/getInternetInfo.d.ts +1 -1
- package/dist/tools/omada/getInternetInfo.js +1 -1
- package/dist/tools/omada/getInternetInfo.js.map +1 -1
- package/dist/tools/omada/getLanNetworkList.d.ts +1 -1
- package/dist/tools/omada/getLanNetworkList.js +1 -1
- package/dist/tools/omada/getLanNetworkList.js.map +1 -1
- package/dist/tools/omada/getLanProfileList.d.ts +1 -1
- package/dist/tools/omada/getLanProfileList.js +1 -1
- package/dist/tools/omada/getLanProfileList.js.map +1 -1
- package/dist/tools/omada/getPortForwardingStatus.d.ts +1 -1
- package/dist/tools/omada/getPortForwardingStatus.js +1 -1
- package/dist/tools/omada/getPortForwardingStatus.js.map +1 -1
- package/dist/tools/omada/getRateLimitProfiles.d.ts +1 -1
- package/dist/tools/omada/getRateLimitProfiles.js +1 -1
- package/dist/tools/omada/getRateLimitProfiles.js.map +1 -1
- package/dist/tools/omada/getSsidDetail.d.ts +1 -1
- package/dist/tools/omada/getSsidDetail.js +1 -1
- package/dist/tools/omada/getSsidDetail.js.map +1 -1
- package/dist/tools/omada/getSsidList.d.ts +1 -1
- package/dist/tools/omada/getSsidList.js +1 -1
- package/dist/tools/omada/getSsidList.js.map +1 -1
- package/dist/tools/omada/getSwitchStackDetail.d.ts +1 -1
- package/dist/tools/omada/getSwitchStackDetail.js +1 -1
- package/dist/tools/omada/getSwitchStackDetail.js.map +1 -1
- package/dist/tools/omada/getThreatList.d.ts +1 -1
- package/dist/tools/omada/getThreatList.js +1 -1
- package/dist/tools/omada/getThreatList.js.map +1 -1
- package/dist/tools/omada/getWlanGroupList.d.ts +1 -1
- package/dist/tools/omada/getWlanGroupList.js +1 -1
- package/dist/tools/omada/getWlanGroupList.js.map +1 -1
- package/dist/tools/omada/graph.d.ts +7 -25
- package/dist/tools/omada/graph.js +3 -3
- package/dist/tools/omada/graph.js.map +1 -1
- package/dist/tools/omada/index.d.ts +1 -1
- package/dist/tools/omada/listClients.d.ts +1 -1
- package/dist/tools/omada/listClients.js +1 -1
- package/dist/tools/omada/listClients.js.map +1 -1
- package/dist/tools/omada/listClientsActivity.d.ts +1 -1
- package/dist/tools/omada/listClientsActivity.js +1 -1
- package/dist/tools/omada/listClientsActivity.js.map +1 -1
- package/dist/tools/omada/listClientsPastConnections.d.ts +1 -1
- package/dist/tools/omada/listClientsPastConnections.js +1 -1
- package/dist/tools/omada/listClientsPastConnections.js.map +1 -1
- package/dist/tools/omada/listDevices.d.ts +1 -1
- package/dist/tools/omada/listDevices.js +1 -1
- package/dist/tools/omada/listDevices.js.map +1 -1
- package/dist/tools/omada/listDevicesStats.d.ts +1 -1
- package/dist/tools/omada/listDevicesStats.js +1 -1
- package/dist/tools/omada/listDevicesStats.js.map +1 -1
- package/dist/tools/omada/listMostActiveClients.d.ts +1 -1
- package/dist/tools/omada/listMostActiveClients.js +1 -1
- package/dist/tools/omada/listMostActiveClients.js.map +1 -1
- package/dist/tools/omada/listSites.d.ts +1 -1
- package/dist/tools/omada/listSites.js +1 -1
- package/dist/tools/omada/listSites.js.map +1 -1
- package/dist/tools/omada/searchDevices.d.ts +1 -1
- package/dist/tools/omada/searchDevices.js +1 -1
- package/dist/tools/omada/searchDevices.js.map +1 -1
- package/dist/tools/omada/setClientRateLimit.d.ts +1 -1
- package/dist/tools/omada/setClientRateLimit.js +1 -1
- package/dist/tools/omada/setClientRateLimit.js.map +1 -1
- package/dist/tools/omada/setClientRateLimitProfile.d.ts +1 -1
- package/dist/tools/omada/setClientRateLimitProfile.js +1 -1
- package/dist/tools/omada/setClientRateLimitProfile.js.map +1 -1
- package/dist/tools/omada/setSsidEnabled.d.ts +3 -11
- package/dist/tools/omada/setSsidEnabled.js +1 -1
- package/dist/tools/omada/setSsidEnabled.js.map +1 -1
- package/dist/tools/omada/unblockClient.d.ts +1 -1
- package/dist/tools/omada/unblockClient.js +1 -1
- package/dist/tools/omada/unblockClient.js.map +1 -1
- package/dist/tools/types.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/CHANGELOG.md +8 -0
- package/openapi.json +1 -1
- package/package.json +8 -5
- package/src/config.ts +10 -19
- package/src/resources/index.ts +7 -8
- package/src/server/auth.ts +1 -1
- package/src/server/chatFace.ts +27 -25
- package/src/server/common.ts +56 -1
- package/src/server/stdio.ts +1 -1
- package/src/server/stream.ts +3 -3
- package/src/tools/ai/analyzeSensors.ts +2 -2
- package/src/tools/ai/index.ts +1 -1
- package/src/tools/common.ts +8 -9
- package/src/tools/homeassistant/automationControls.ts +5 -5
- package/src/tools/homeassistant/calendar.ts +3 -3
- package/src/tools/homeassistant/callService.ts +2 -2
- package/src/tools/homeassistant/controlClimate.ts +2 -2
- package/src/tools/homeassistant/controlCover.ts +2 -2
- package/src/tools/homeassistant/controlFan.ts +2 -2
- package/src/tools/homeassistant/controlLight.ts +2 -2
- package/src/tools/homeassistant/controlMediaPlayer.ts +2 -2
- package/src/tools/homeassistant/createAutomation.ts +2 -2
- package/src/tools/homeassistant/deleteAutomation.ts +2 -2
- package/src/tools/homeassistant/entityAction.ts +2 -2
- package/src/tools/homeassistant/entityGuard.ts +1 -1
- package/src/tools/homeassistant/getAllSensors.ts +2 -2
- package/src/tools/homeassistant/getAutomationTrace.ts +2 -2
- package/src/tools/homeassistant/getDomainSummary.ts +2 -2
- package/src/tools/homeassistant/getEntitiesByDomain.ts +2 -2
- package/src/tools/homeassistant/getHistory.ts +2 -2
- package/src/tools/homeassistant/getState.ts +2 -2
- package/src/tools/homeassistant/getStates.ts +2 -2
- package/src/tools/homeassistant/getVersion.ts +2 -2
- package/src/tools/homeassistant/index.ts +1 -1
- package/src/tools/homeassistant/listAutomations.ts +2 -2
- package/src/tools/homeassistant/listEntities.ts +2 -2
- package/src/tools/homeassistant/listPersons.ts +2 -2
- package/src/tools/homeassistant/sceneAndScript.ts +3 -3
- package/src/tools/homeassistant/searchEntities.ts +2 -2
- package/src/tools/homeassistant/sendNotification.ts +3 -3
- package/src/tools/homeassistant/systemTools.ts +4 -4
- package/src/tools/homeassistant/triggerAutomation.ts +2 -2
- package/src/tools/index.ts +1 -1
- package/src/tools/infra/index.ts +2 -2
- package/src/tools/omada/blockClient.ts +2 -2
- package/src/tools/omada/cyclePoePort.ts +2 -2
- package/src/tools/omada/disableClientRateLimit.ts +2 -2
- package/src/tools/omada/getClient.ts +2 -3
- package/src/tools/omada/getDevice.ts +2 -3
- package/src/tools/omada/getFirewallSetting.ts +2 -3
- package/src/tools/omada/getInternetInfo.ts +2 -3
- package/src/tools/omada/getLanNetworkList.ts +2 -3
- package/src/tools/omada/getLanProfileList.ts +2 -3
- package/src/tools/omada/getPortForwardingStatus.ts +2 -2
- package/src/tools/omada/getRateLimitProfiles.ts +2 -3
- package/src/tools/omada/getSsidDetail.ts +2 -2
- package/src/tools/omada/getSsidList.ts +2 -2
- package/src/tools/omada/getSwitchStackDetail.ts +2 -3
- package/src/tools/omada/getThreatList.ts +2 -2
- package/src/tools/omada/getWlanGroupList.ts +2 -3
- package/src/tools/omada/graph.ts +4 -4
- package/src/tools/omada/index.ts +1 -1
- package/src/tools/omada/listClients.ts +2 -3
- package/src/tools/omada/listClientsActivity.ts +2 -2
- package/src/tools/omada/listClientsPastConnections.ts +2 -2
- package/src/tools/omada/listDevices.ts +2 -3
- package/src/tools/omada/listDevicesStats.ts +2 -2
- package/src/tools/omada/listMostActiveClients.ts +2 -3
- package/src/tools/omada/listSites.ts +2 -2
- package/src/tools/omada/searchDevices.ts +2 -2
- package/src/tools/omada/setClientRateLimit.ts +2 -2
- package/src/tools/omada/setClientRateLimitProfile.ts +2 -2
- package/src/tools/omada/setSsidEnabled.ts +2 -2
- package/src/tools/omada/unblockClient.ts +2 -2
- package/src/tools/types.ts +1 -1
- package/src/version.ts +1 -1
- package/tests/bench/hotpaths.bench.ts +68 -0
- package/tests/resources/index.test.ts +3 -3
- package/tests/security/dependencies.test.ts +6 -6
- package/tests/security/insecureDesign.test.ts +5 -6
- package/tests/server/memoizeJsonSchema.test.ts +71 -0
- package/tests/server/stdio.test.ts +2 -2
- package/tests/server/stream.test.ts +0 -1
- package/tests/server/toolVisibility.test.ts +1 -2
- package/tests/tools/ai/analyzeSensors.test.ts +3 -11
- package/tests/tools/common.test.ts +10 -12
- package/tests/tools/homeassistant/handlers.test.ts +1 -5
- package/tests/tools/infra/invokeAction.test.ts +3 -6
- package/tests/tools/omada/graph.test.ts +4 -4
- package/tests/tools/omada/handlers.test.ts +3 -12
- package/tests/tools/registry.test.ts +1 -1
package/src/tools/common.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Shared helpers for all MCP tools
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
7
|
-
import type { CallToolResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
import type { CallToolResult, ServerContext } from '@modelcontextprotocol/server';
|
|
8
7
|
import { z } from 'zod';
|
|
9
8
|
import { logger } from '../utils/logger.js';
|
|
10
9
|
import { Permission, hasPermission, getPermissionNames } from '../permissions/index.js';
|
|
@@ -34,7 +33,7 @@ export function setLocalFullTrust(enabled: boolean): void {
|
|
|
34
33
|
* Extra context passed to tool handlers
|
|
35
34
|
* Permissions are extracted from authInfo.extra.permissions (MCP SDK standard)
|
|
36
35
|
*/
|
|
37
|
-
export type ToolExtra =
|
|
36
|
+
export type ToolExtra = ServerContext;
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* Resolve the caller's permission mask from the MCP SDK auth context.
|
|
@@ -48,7 +47,7 @@ export type ToolExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
|
48
47
|
* semantics as `wrapToolHandler`, instead of re-reading `authInfo` ad hoc.
|
|
49
48
|
*/
|
|
50
49
|
export function getCallerPermissions(extra: ToolExtra): number {
|
|
51
|
-
return (extra.authInfo?.extra?.permissions as number | undefined) ?? (localFullTrust ? 0xFF : 0);
|
|
50
|
+
return (extra.http?.authInfo?.extra?.permissions as number | undefined) ?? (localFullTrust ? 0xFF : 0);
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
/**
|
|
@@ -231,7 +230,7 @@ export const automationIdSchema = z.object({
|
|
|
231
230
|
export const serviceCallSchema = z.object({
|
|
232
231
|
domain: z.string().describe('Service domain (e.g., "light", "switch", "climate", "notify")'),
|
|
233
232
|
service: z.string().describe('Service name (e.g., "turn_on", "turn_off", "set_temperature")'),
|
|
234
|
-
service_data: z.record(z.unknown()).optional().describe('Optional service data'),
|
|
233
|
+
service_data: z.record(z.string(), z.unknown()).optional().describe('Optional service data'),
|
|
235
234
|
target: z.object({
|
|
236
235
|
entity_id: z.union([z.string(), z.array(z.string())]).optional(),
|
|
237
236
|
device_id: z.union([z.string(), z.array(z.string())]).optional(),
|
|
@@ -241,13 +240,13 @@ export const serviceCallSchema = z.object({
|
|
|
241
240
|
|
|
242
241
|
// Analyze sensors schema
|
|
243
242
|
export const analyzeSensorsSchema = z.object({
|
|
244
|
-
sensors: z.record(z.unknown()).describe('Sensor data to analyze. Object with entity_id keys and {state, unit, attributes} values.'),
|
|
243
|
+
sensors: z.record(z.string(), z.unknown()).describe('Sensor data to analyze. Object with entity_id keys and {state, unit, attributes} values.'),
|
|
245
244
|
});
|
|
246
245
|
|
|
247
246
|
// Trigger automation schema
|
|
248
247
|
export const triggerAutomationSchema = z.object({
|
|
249
248
|
entity_id: z.string().describe('The automation entity ID (e.g., "automation.turn_on_lights")'),
|
|
250
|
-
variables: z.record(z.unknown()).optional().describe('Optional variables to pass to the automation'),
|
|
249
|
+
variables: z.record(z.string(), z.unknown()).optional().describe('Optional variables to pass to the automation'),
|
|
251
250
|
});
|
|
252
251
|
|
|
253
252
|
// Create automation schema
|
|
@@ -307,7 +306,7 @@ export const controlFanSchema = z.object({
|
|
|
307
306
|
// Run script schema
|
|
308
307
|
export const runScriptSchema = z.object({
|
|
309
308
|
entity_id: z.string().describe('The script entity ID (e.g., "script.morning_routine")'),
|
|
310
|
-
variables: z.record(z.unknown()).optional().describe('Optional variables to pass to the script'),
|
|
309
|
+
variables: z.record(z.string(), z.unknown()).optional().describe('Optional variables to pass to the script'),
|
|
311
310
|
});
|
|
312
311
|
|
|
313
312
|
// Notification action schema for actionable notifications
|
|
@@ -347,7 +346,7 @@ export const sendNotificationSchema = z.object({
|
|
|
347
346
|
badge: z.number().optional().describe('App badge count (iOS)'),
|
|
348
347
|
interruptionLevel: z.enum(['passive', 'active', 'time-sensitive', 'critical']).optional().describe('iOS interruption level'),
|
|
349
348
|
// Raw data passthrough for advanced use
|
|
350
|
-
data: z.record(z.unknown()).optional().describe('Additional raw data to pass to notification service'),
|
|
349
|
+
data: z.record(z.string(), z.unknown()).optional().describe('Additional raw data to pass to notification service'),
|
|
351
350
|
});
|
|
352
351
|
|
|
353
352
|
// List notification targets schema (empty - no params needed)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Automation control tools - Enable, disable, toggle, reload automations
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { entityIdSchema, emptySchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import type { z } from 'zod';
|
|
@@ -14,7 +14,7 @@ export function registerEnableAutomationTool(server: McpServer, client: HaClient
|
|
|
14
14
|
'enableAutomation',
|
|
15
15
|
{
|
|
16
16
|
description: 'Enable a disabled Home Assistant automation.',
|
|
17
|
-
inputSchema: entityIdSchema
|
|
17
|
+
inputSchema: entityIdSchema,
|
|
18
18
|
},
|
|
19
19
|
wrapToolHandler('enableAutomation', async ({ entity_id }: EntityIdArgs) => {
|
|
20
20
|
const result = await client.enableAutomation(entity_id);
|
|
@@ -28,7 +28,7 @@ export function registerDisableAutomationTool(server: McpServer, client: HaClien
|
|
|
28
28
|
'disableAutomation',
|
|
29
29
|
{
|
|
30
30
|
description: 'Disable a Home Assistant automation.',
|
|
31
|
-
inputSchema: entityIdSchema
|
|
31
|
+
inputSchema: entityIdSchema,
|
|
32
32
|
},
|
|
33
33
|
wrapToolHandler('disableAutomation', async ({ entity_id }: EntityIdArgs) => {
|
|
34
34
|
const result = await client.disableAutomation(entity_id);
|
|
@@ -42,7 +42,7 @@ export function registerToggleAutomationTool(server: McpServer, client: HaClient
|
|
|
42
42
|
'toggleAutomation',
|
|
43
43
|
{
|
|
44
44
|
description: 'Toggle a Home Assistant automation (enable if disabled, disable if enabled).',
|
|
45
|
-
inputSchema: entityIdSchema
|
|
45
|
+
inputSchema: entityIdSchema,
|
|
46
46
|
},
|
|
47
47
|
wrapToolHandler('toggleAutomation', async ({ entity_id }: EntityIdArgs) => {
|
|
48
48
|
const result = await client.toggleAutomation(entity_id);
|
|
@@ -56,7 +56,7 @@ export function registerReloadAutomationsTool(server: McpServer, client: HaClien
|
|
|
56
56
|
'reloadAutomations',
|
|
57
57
|
{
|
|
58
58
|
description: 'Reload all automations from the Home Assistant configuration. Useful after editing automation YAML files.',
|
|
59
|
-
inputSchema: emptySchema
|
|
59
|
+
inputSchema: emptySchema,
|
|
60
60
|
},
|
|
61
61
|
wrapToolHandler('reloadAutomations', async () => {
|
|
62
62
|
await client.reloadAutomations();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Calendar tools - List calendars and get calendar events
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { listCalendarsSchema, getCalendarEventsSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import type { z } from 'zod';
|
|
@@ -14,7 +14,7 @@ export function registerListCalendarsTool(server: McpServer, client: HaClient):
|
|
|
14
14
|
'listCalendars',
|
|
15
15
|
{
|
|
16
16
|
description: 'List all calendar entities in Home Assistant. Returns calendar names and their current state.',
|
|
17
|
-
inputSchema: listCalendarsSchema
|
|
17
|
+
inputSchema: listCalendarsSchema,
|
|
18
18
|
},
|
|
19
19
|
wrapToolHandler('listCalendars', async () => {
|
|
20
20
|
const calendars = await client.getCalendars();
|
|
@@ -38,7 +38,7 @@ Examples:
|
|
|
38
38
|
- Next 7 days: { days: 7 }
|
|
39
39
|
- Date range: { start_date: "2026-01-01", end_date: "2026-01-31" }
|
|
40
40
|
- Specific calendar + date range: { entity_id: "calendar.work", start_date: "2026-02-01", days: 14 }`,
|
|
41
|
-
inputSchema: getCalendarEventsSchema
|
|
41
|
+
inputSchema: getCalendarEventsSchema,
|
|
42
42
|
},
|
|
43
43
|
wrapToolHandler('getCalendarEvents', async (args: GetCalendarEventsArgs) => {
|
|
44
44
|
// Parse dates
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* callService tool - Call a Home Assistant service
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import type { ServiceCallData } from '../../types/index.js';
|
|
8
8
|
import { serviceCallSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
@@ -12,7 +12,7 @@ export function registerCallServiceTool(server: McpServer, client: HaClient): vo
|
|
|
12
12
|
'callService',
|
|
13
13
|
{
|
|
14
14
|
description: 'Call a Home Assistant service (e.g., turn on a light, set temperature).',
|
|
15
|
-
inputSchema: serviceCallSchema
|
|
15
|
+
inputSchema: serviceCallSchema,
|
|
16
16
|
},
|
|
17
17
|
wrapToolHandler('callService', async (args: ServiceCallData) => {
|
|
18
18
|
if (!args.domain || !args.service) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* controlClimate tool - Control climate/thermostat devices
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { controlClimateSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import { entityNotFoundResult } from './entityGuard.js';
|
|
@@ -15,7 +15,7 @@ export function registerControlClimateTool(server: McpServer, client: HaClient):
|
|
|
15
15
|
'controlClimate',
|
|
16
16
|
{
|
|
17
17
|
description: 'Control a climate/thermostat device with temperature and mode settings.',
|
|
18
|
-
inputSchema: controlClimateSchema
|
|
18
|
+
inputSchema: controlClimateSchema,
|
|
19
19
|
},
|
|
20
20
|
wrapToolHandler('controlClimate', async (args: ControlClimateArgs) => {
|
|
21
21
|
const missing = await entityNotFoundResult(client, args.entity_id);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* controlCover tool - Control covers/blinds
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { controlCoverSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import { entityNotFoundResult } from './entityGuard.js';
|
|
@@ -15,7 +15,7 @@ export function registerControlCoverTool(server: McpServer, client: HaClient): v
|
|
|
15
15
|
'controlCover',
|
|
16
16
|
{
|
|
17
17
|
description: 'Control a cover/blind with position and tilt settings.',
|
|
18
|
-
inputSchema: controlCoverSchema
|
|
18
|
+
inputSchema: controlCoverSchema,
|
|
19
19
|
},
|
|
20
20
|
wrapToolHandler('controlCover', async (args: ControlCoverArgs) => {
|
|
21
21
|
const missing = await entityNotFoundResult(client, args.entity_id);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* controlFan tool - Control fans
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { controlFanSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import { entityNotFoundResult } from './entityGuard.js';
|
|
@@ -15,7 +15,7 @@ export function registerControlFanTool(server: McpServer, client: HaClient): voi
|
|
|
15
15
|
'controlFan',
|
|
16
16
|
{
|
|
17
17
|
description: 'Control a fan with speed, oscillation, and direction settings.',
|
|
18
|
-
inputSchema: controlFanSchema
|
|
18
|
+
inputSchema: controlFanSchema,
|
|
19
19
|
},
|
|
20
20
|
wrapToolHandler('controlFan', async (args: ControlFanArgs) => {
|
|
21
21
|
const missing = await entityNotFoundResult(client, args.entity_id);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* controlLight tool - Control lights with advanced options
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { controlLightSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import { entityNotFoundResult } from './entityGuard.js';
|
|
@@ -15,7 +15,7 @@ export function registerControlLightTool(server: McpServer, client: HaClient): v
|
|
|
15
15
|
'controlLight',
|
|
16
16
|
{
|
|
17
17
|
description: 'Control a light with advanced options like brightness, color, and color temperature.',
|
|
18
|
-
inputSchema: controlLightSchema
|
|
18
|
+
inputSchema: controlLightSchema,
|
|
19
19
|
},
|
|
20
20
|
wrapToolHandler('controlLight', async (args: ControlLightArgs) => {
|
|
21
21
|
const missing = await entityNotFoundResult(client, args.entity_id);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* controlMediaPlayer tool - Control media players
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { controlMediaPlayerSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import { entityNotFoundResult } from './entityGuard.js';
|
|
@@ -15,7 +15,7 @@ export function registerControlMediaPlayerTool(server: McpServer, client: HaClie
|
|
|
15
15
|
'controlMediaPlayer',
|
|
16
16
|
{
|
|
17
17
|
description: 'Control a media player with playback, volume, and media selection.',
|
|
18
|
-
inputSchema: controlMediaPlayerSchema
|
|
18
|
+
inputSchema: controlMediaPlayerSchema,
|
|
19
19
|
},
|
|
20
20
|
wrapToolHandler('controlMediaPlayer', async (args: ControlMediaPlayerArgs) => {
|
|
21
21
|
const missing = await entityNotFoundResult(client, args.entity_id);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* createAutomation tool - Create a new automation
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import type { AutomationTrigger, AutomationCondition, AutomationAction } from '../../types/index.js';
|
|
8
8
|
import { createAutomationSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
@@ -15,7 +15,7 @@ export function registerCreateAutomationTool(server: McpServer, client: HaClient
|
|
|
15
15
|
'createAutomation',
|
|
16
16
|
{
|
|
17
17
|
description: 'Create a new Home Assistant automation. Requires specifying triggers, conditions (optional), and actions.',
|
|
18
|
-
inputSchema: createAutomationSchema
|
|
18
|
+
inputSchema: createAutomationSchema,
|
|
19
19
|
},
|
|
20
20
|
wrapToolHandler('createAutomation', async (args: CreateAutomationArgs) => {
|
|
21
21
|
if (!args.alias || !args.trigger || !args.action) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* deleteAutomation tool - Delete an automation
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { automationIdSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import type { z } from 'zod';
|
|
@@ -14,7 +14,7 @@ export function registerDeleteAutomationTool(server: McpServer, client: HaClient
|
|
|
14
14
|
'deleteAutomation',
|
|
15
15
|
{
|
|
16
16
|
description: 'Delete a Home Assistant automation. Only works for automations created via the UI/API.',
|
|
17
|
-
inputSchema: automationIdSchema
|
|
17
|
+
inputSchema: automationIdSchema,
|
|
18
18
|
},
|
|
19
19
|
wrapToolHandler('deleteAutomation', async ({ automation_id }: DeleteAutomationArgs) => {
|
|
20
20
|
await client.deleteAutomation(automation_id);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* entityAction tool - Simple entity actions (turn_on, turn_off, toggle)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { entityActionSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import { entityNotFoundResult } from './entityGuard.js';
|
|
@@ -15,7 +15,7 @@ export function registerEntityActionTool(server: McpServer, client: HaClient): v
|
|
|
15
15
|
'entityAction',
|
|
16
16
|
{
|
|
17
17
|
description: 'Perform a simple action on an entity (turn_on, turn_off, toggle). Automatically detects the domain.',
|
|
18
|
-
inputSchema: entityActionSchema
|
|
18
|
+
inputSchema: entityActionSchema,
|
|
19
19
|
},
|
|
20
20
|
wrapToolHandler('entityAction', async ({ entity_id, action }: EntityActionArgs) => {
|
|
21
21
|
const domain = entity_id.split('.')[0];
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* LLM client would believe a typo'd light was switched on.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { CallToolResult } from '@modelcontextprotocol/
|
|
10
|
+
import type { CallToolResult } from '@modelcontextprotocol/server';
|
|
11
11
|
import type { HaClient } from '../../haClient/index.js';
|
|
12
12
|
import { toToolResult } from '../common.js';
|
|
13
13
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Returns paginated, lightweight entities by default to reduce response size.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
7
7
|
import type { HaClient } from '../../haClient/index.js';
|
|
8
8
|
import { toLightweight } from '../../types/index.js';
|
|
9
9
|
import { haPaginationSchema, toToolResult, wrapToolHandler, Permission, paginateArray } from '../common.js';
|
|
@@ -13,7 +13,7 @@ export function registerGetAllSensorsTool(server: McpServer, client: HaClient):
|
|
|
13
13
|
'getAllSensors',
|
|
14
14
|
{
|
|
15
15
|
description: 'Get all sensor states from Home Assistant (sensor.* and binary_sensor.* entities). Returns paginated lightweight entities by default (50 per page). Use includeAttributes=true for full entity data.',
|
|
16
|
-
inputSchema: haPaginationSchema
|
|
16
|
+
inputSchema: haPaginationSchema,
|
|
17
17
|
},
|
|
18
18
|
wrapToolHandler('getAllSensors', async (args) => {
|
|
19
19
|
const { page, pageSize, includeAttributes } = args;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* getAutomationTrace tool - Get automation execution history
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { entityIdSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import type { z } from 'zod';
|
|
@@ -14,7 +14,7 @@ export function registerGetAutomationTraceTool(server: McpServer, client: HaClie
|
|
|
14
14
|
'getAutomationTrace',
|
|
15
15
|
{
|
|
16
16
|
description: 'Get the execution trace (history) of an automation. Shows when it was triggered and what actions were executed.',
|
|
17
|
-
inputSchema: entityIdSchema
|
|
17
|
+
inputSchema: entityIdSchema,
|
|
18
18
|
},
|
|
19
19
|
wrapToolHandler('getAutomationTrace', async ({ entity_id }: EntityIdArgs) => {
|
|
20
20
|
const trace = await client.getAutomationTrace(entity_id);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* getDomainSummary tool - Get summary of entities in a domain
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { domainSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
|
|
@@ -22,7 +22,7 @@ export function registerGetDomainSummaryTool(server: McpServer, client: HaClient
|
|
|
22
22
|
'getDomainSummary',
|
|
23
23
|
{
|
|
24
24
|
description: 'Get a summary of entities in a domain, including counts and state breakdown.',
|
|
25
|
-
inputSchema: domainSchema
|
|
25
|
+
inputSchema: domainSchema,
|
|
26
26
|
},
|
|
27
27
|
createGetDomainSummaryHandler(client)
|
|
28
28
|
);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
8
8
|
import type { HaClient } from '../../haClient/index.js';
|
|
9
9
|
import { toLightweight } from '../../types/index.js';
|
|
10
10
|
import { toToolResult, wrapToolHandler, Permission, paginateArray } from '../common.js';
|
|
@@ -21,7 +21,7 @@ export function registerGetEntitiesByDomainTool(server: McpServer, client: HaCli
|
|
|
21
21
|
'getEntitiesByDomain',
|
|
22
22
|
{
|
|
23
23
|
description: 'Get all entities for a specific domain (e.g., all lights, all sensors). Returns paginated lightweight entities by default (50 per page). Use includeAttributes=true for full entity data.',
|
|
24
|
-
inputSchema: getEntitiesByDomainSchema
|
|
24
|
+
inputSchema: getEntitiesByDomainSchema,
|
|
25
25
|
},
|
|
26
26
|
wrapToolHandler('getEntitiesByDomain', async (args) => {
|
|
27
27
|
const { domain, page, pageSize, includeAttributes } = args;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* getHistory tool - Get historical data for an entity
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { historySchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import type { z } from 'zod';
|
|
@@ -14,7 +14,7 @@ export function registerGetHistoryTool(server: McpServer, client: HaClient): voi
|
|
|
14
14
|
'getHistory',
|
|
15
15
|
{
|
|
16
16
|
description: 'Get historical data for an entity.',
|
|
17
|
-
inputSchema: historySchema
|
|
17
|
+
inputSchema: historySchema,
|
|
18
18
|
},
|
|
19
19
|
wrapToolHandler('getHistory', async ({ entity_id, hours = 24 }: HistoryArgs) => {
|
|
20
20
|
const history = await client.getHistory(entity_id, hours);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* getState tool - Get state of a specific entity
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { entityIdSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ export function registerGetStateTool(server: McpServer, client: HaClient): void
|
|
|
11
11
|
'getState',
|
|
12
12
|
{
|
|
13
13
|
description: 'Get the state of a specific entity by entity_id.',
|
|
14
|
-
inputSchema: entityIdSchema
|
|
14
|
+
inputSchema: entityIdSchema,
|
|
15
15
|
},
|
|
16
16
|
wrapToolHandler('getState', async ({ entity_id }: { entity_id: string }) => {
|
|
17
17
|
const state = await client.getState(entity_id);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Returns paginated, lightweight entities by default to reduce response size.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
7
7
|
import type { HaClient } from '../../haClient/index.js';
|
|
8
8
|
import { toLightweight } from '../../types/index.js';
|
|
9
9
|
import { haPaginationSchema, toToolResult, wrapToolHandler, Permission, paginateArray } from '../common.js';
|
|
@@ -13,7 +13,7 @@ export function registerGetStatesTool(server: McpServer, client: HaClient): void
|
|
|
13
13
|
'getStates',
|
|
14
14
|
{
|
|
15
15
|
description: 'Get all entity states from Home Assistant. Returns paginated lightweight entities by default (50 per page). Use includeAttributes=true for full entity data.',
|
|
16
|
-
inputSchema: haPaginationSchema
|
|
16
|
+
inputSchema: haPaginationSchema,
|
|
17
17
|
},
|
|
18
18
|
wrapToolHandler('getStates', async (args) => {
|
|
19
19
|
const { page, pageSize, includeAttributes } = args;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* getVersion tool - Get Home Assistant version info
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { emptySchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ export function registerGetVersionTool(server: McpServer, client: HaClient): voi
|
|
|
11
11
|
'getVersion',
|
|
12
12
|
{
|
|
13
13
|
description: 'Get Home Assistant version and configuration information.',
|
|
14
|
-
inputSchema: emptySchema
|
|
14
|
+
inputSchema: emptySchema,
|
|
15
15
|
},
|
|
16
16
|
wrapToolHandler('getVersion', async () => {
|
|
17
17
|
const version = await client.getVersion();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Home Assistant tools index - registers all HA MCP tools
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { logger } from '../../utils/logger.js';
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* listAutomations tool - List all automations
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { automationFilterSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import type { z } from 'zod';
|
|
@@ -28,7 +28,7 @@ export function registerListAutomationsTool(server: McpServer, client: HaClient)
|
|
|
28
28
|
'listAutomations',
|
|
29
29
|
{
|
|
30
30
|
description: 'List all Home Assistant automations with their status and last triggered time.',
|
|
31
|
-
inputSchema: automationFilterSchema
|
|
31
|
+
inputSchema: automationFilterSchema,
|
|
32
32
|
},
|
|
33
33
|
createListAutomationsHandler(client)
|
|
34
34
|
);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
8
8
|
import type { HaClient } from '../../haClient/index.js';
|
|
9
9
|
import { toLightweight } from '../../types/index.js';
|
|
10
10
|
import { toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
@@ -24,7 +24,7 @@ export function registerListEntitiesTool(server: McpServer, client: HaClient): v
|
|
|
24
24
|
'listEntities',
|
|
25
25
|
{
|
|
26
26
|
description: 'List entities with optional filtering by domain, state, or search query. Returns lightweight entities by default (limit 50). Use includeAttributes=true for full entity data.',
|
|
27
|
-
inputSchema: listEntitiesSchema
|
|
27
|
+
inputSchema: listEntitiesSchema,
|
|
28
28
|
},
|
|
29
29
|
wrapToolHandler('listEntities', async (args: ListEntitiesArgs) => {
|
|
30
30
|
const { includeAttributes, ...filterArgs } = args;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* listPersons tool - List all person entities (household members)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { emptySchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
|
|
@@ -20,7 +20,7 @@ Use this tool when the user asks:
|
|
|
20
20
|
- "List family members"
|
|
21
21
|
- "Is anyone home?"
|
|
22
22
|
- "Where is Dad/Mom/etc?"`,
|
|
23
|
-
inputSchema: emptySchema
|
|
23
|
+
inputSchema: emptySchema,
|
|
24
24
|
},
|
|
25
25
|
wrapToolHandler('listPersons', async () => {
|
|
26
26
|
const entities = await client.getEntitiesByDomain('person');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Scene and Script tools - Activate scenes and run scripts
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { HaClient } from '../../haClient/index.js';
|
|
7
7
|
import { entityIdSchema, runScriptSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
8
8
|
import { entityNotFoundResult } from './entityGuard.js';
|
|
@@ -16,7 +16,7 @@ export function registerActivateSceneTool(server: McpServer, client: HaClient):
|
|
|
16
16
|
'activateScene',
|
|
17
17
|
{
|
|
18
18
|
description: 'Activate a Home Assistant scene.',
|
|
19
|
-
inputSchema: entityIdSchema
|
|
19
|
+
inputSchema: entityIdSchema,
|
|
20
20
|
},
|
|
21
21
|
wrapToolHandler('activateScene', async ({ entity_id }: EntityIdArgs) => {
|
|
22
22
|
const missing = await entityNotFoundResult(client, entity_id);
|
|
@@ -36,7 +36,7 @@ export function registerRunScriptTool(server: McpServer, client: HaClient): void
|
|
|
36
36
|
'runScript',
|
|
37
37
|
{
|
|
38
38
|
description: 'Run a Home Assistant script with optional variables.',
|
|
39
|
-
inputSchema: runScriptSchema
|
|
39
|
+
inputSchema: runScriptSchema,
|
|
40
40
|
},
|
|
41
41
|
wrapToolHandler('runScript', async ({ entity_id, variables }: RunScriptArgs) => {
|
|
42
42
|
const missing = await entityNotFoundResult(client, entity_id);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
8
8
|
import type { HaClient } from '../../haClient/index.js';
|
|
9
9
|
import { toLightweight } from '../../types/index.js';
|
|
10
10
|
import { toToolResult, wrapToolHandler, Permission, paginateArray } from '../common.js';
|
|
@@ -23,7 +23,7 @@ export function registerSearchEntitiesTool(server: McpServer, client: HaClient):
|
|
|
23
23
|
description: `Search for entities by name or entity_id. Returns paginated lightweight entities by default (50 per page). Use includeAttributes=true for full entity data.
|
|
24
24
|
|
|
25
25
|
Note: For queries about people, family members, or "who's home?", use the listPersons tool instead.`,
|
|
26
|
-
inputSchema: searchEntitiesSchema
|
|
26
|
+
inputSchema: searchEntitiesSchema,
|
|
27
27
|
},
|
|
28
28
|
wrapToolHandler('searchEntities', async (args) => {
|
|
29
29
|
const { query, page, pageSize, includeAttributes } = args;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Supports HA Mobile App notifications with actions, images, sounds, and more
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { McpServer } from '@modelcontextprotocol/
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
7
7
|
import type { HaClient } from '../../haClient/index.js';
|
|
8
8
|
import { sendNotificationSchema, listNotificationTargetsSchema, toToolResult, wrapToolHandler, Permission } from '../common.js';
|
|
9
9
|
import type { z } from 'zod';
|
|
@@ -83,7 +83,7 @@ Examples:
|
|
|
83
83
|
- Simple: { message: "Hello!", target: "mobile_app_phone" }
|
|
84
84
|
- With actions: { message: "Doorbell", target: "mobile_app_phone", actions: [{ action: "OPEN", title: "Open Door" }] }
|
|
85
85
|
- With image: { message: "Camera alert", target: "mobile_app_phone", image: "/api/camera_proxy/camera.front" }`,
|
|
86
|
-
inputSchema: sendNotificationSchema
|
|
86
|
+
inputSchema: sendNotificationSchema,
|
|
87
87
|
},
|
|
88
88
|
wrapToolHandler('sendNotification', async (args: SendNotificationArgs) => {
|
|
89
89
|
const serviceData: Record<string, unknown> = { message: args.message };
|
|
@@ -121,7 +121,7 @@ export function registerListNotificationTargetsTool(server: McpServer, client: H
|
|
|
121
121
|
'listNotificationTargets',
|
|
122
122
|
{
|
|
123
123
|
description: 'List available notification targets (mobile apps and other notify services). Use this to discover which devices can receive notifications.',
|
|
124
|
-
inputSchema: listNotificationTargetsSchema
|
|
124
|
+
inputSchema: listNotificationTargetsSchema,
|
|
125
125
|
},
|
|
126
126
|
wrapToolHandler('listNotificationTargets', async () => {
|
|
127
127
|
// Get all entities and find mobile_app device trackers to infer notify services
|