domotz-mcp
Version:
MCP server for Domotz API and BMS (Building Management System) integration with IoT device monitoring
41 lines (40 loc) • 1.31 kB
JavaScript
import { z } from "zod";
import axios from "axios";
import { BaseDomotzTool } from "./BaseDomotzTool.js";
export default class GetAgentTool extends BaseDomotzTool {
name = "get_agent";
description = "Get details of a specific Domotz agent";
schema = {
agent_id: {
type: z.number(),
description: "The ID of the agent to retrieve"
}
};
async execute(input) {
const apiKey = process.env.DOMOTZ_API_KEY;
const apiEndpoint = process.env.DOMOTZ_API_ENDPOINT || "https://api-eu-west-1-cell-1.domotz.com/public-api/v1/";
if (!apiKey) {
throw new Error("DOMOTZ_API_KEY environment variable is not set");
}
try {
const response = await axios.get(`${apiEndpoint}agent/${input.agent_id}`, {
headers: {
"X-Api-Key": apiKey,
"Content-Type": "application/json"
}
});
return {
success: true,
agent: response.data
};
}
catch (error) {
return {
success: false,
error: error.message,
status: error.response?.status,
data: error.response?.data
};
}
}
}