ha_call_service
Call any Home Assistant service by providing domain, service, and optional data payload to trigger automations or control devices.
Instructions
Call a Home Assistant service (domain/service) with data payload.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | ||
| service | Yes | ||
| data | No |
Implementation Reference
- src/index.ts:205-214 (handler)MCP tool registration and handler for 'ha_call_service'. Calls ha.callService with domain, service, and data, returning JSON acknowledgment.
server.tool( 'ha_call_service', 'Call a Home Assistant service (domain/service) with data payload.', CallServiceInput.shape, async (input) => { const res = await ha.callService(input.domain, input.service, input.data) return { content: [{ type: 'text', text: JSON.stringify(res, null, 2) }], } }, - src/tools.ts:7-11 (schema)Zod schema definition for CallServiceInput: domain (string), service (string), data (optional record).
export const CallServiceInput = z.object({ domain: z.string().min(1), service: z.string().min(1), data: z.record(z.unknown()).default({}), }) - src/ha.ts:98-104 (helper)HomeAssistantClient.callService method that delegates to home-assistant-js-websocket's callService and returns { ok: true }.
async callService(domain: string, service: string, data: Record<string, unknown>) { const connection = await this.ensureConnected() // callService returns void in the library; we return a small acknowledgement await callService(connection, domain, service, data) return { ok: true } } - src/index.ts:205-214 (registration)Registration of 'ha_call_service' tool on the MCP server via server.tool().
server.tool( 'ha_call_service', 'Call a Home Assistant service (domain/service) with data payload.', CallServiceInput.shape, async (input) => { const res = await ha.callService(input.domain, input.service, input.data) return { content: [{ type: 'text', text: JSON.stringify(res, null, 2) }], } },