Skip to main content
Glama

Home Assistant MCP Server

components.ts1.45 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { HassClient } from "../../api/client.js"; import { apiLogger } from "../../logger.js"; import { handleToolError, formatErrorMessage } from "../utils.js"; /** * Register the components list tool with the MCP server * @param server The MCP server to register the tool with * @param client The Home Assistant client */ export function registerSystemComponentsTool(server: McpServer, client: HassClient) { server.tool( "tools-system-components", "Get all loaded Home Assistant components", {}, // No parameters needed async () => { try { apiLogger.warn("Executing system components tool"); // Use HassClient to get all components const components = await client.getComponents(); // Return components list return { content: [ { type: "text", text: JSON.stringify({ success: true, components, count: components.length, }, null, 2), }, ], }; } catch (error) { handleToolError("tools-system-components", error); return { isError: true, content: [ { type: "text", text: `Error getting components: ${formatErrorMessage(error)}`, }, ], }; } }, ); }

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