Skip to main content
Glama

Home Assistant MCP Server

state.ts1.24 kB
import { z } from "zod"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { HassClient } from "../../api/client.js"; export function registerEntityStatePrompt(server: McpServer, _client: HassClient) { server.prompt( "entity-state", "Get the current state of a Home Assistant entity", { entity_id: z.string().describe("The entity ID to get the state for (e.g., 'light.living_room')"), }, async (request) => { // Return a prompt message sequence that will help the model // know how to use the tools to get entity state return { messages: [ { role: "user", content: { type: "text", text: `What's the state of the ${request.entity_id} entity?`, }, }, { role: "assistant", content: { type: "text", text: "I'll check the state of that entity for you.", }, }, { role: "user", content: { type: "text", text: "Please use the entity state tool to get the current state.", }, }, ], }; }, ); }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/oleander/home-assistant-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server