UNPKG

rhombus-node-mcp

Version:
40 lines (39 loc) 1.51 kB
import { isConfirmed, requireConfirmation } from "../utils/confirmation.js"; import { rebootCameras } from "../api/reboot-cameras-tool-api.js"; import { TOOL_ARGS } from "../types/reboot-cameras-tool-types.js"; const TOOL_NAME = "reboot-cameras"; const TOOL_DESCRIPTION = "this tool is for rebooting one or more cameras causing them to reconnect to the server, this is a helpful option when a camera is experiencing connectivity issues or is in need of troubleshooting. THIS TOOL PERFORMS AN ACTION."; const TOOL_HANDLER = async (args, extra) => { const { cameraUuids, confirmationId } = args; const confirmation = requireConfirmation(confirmationId); if (!isConfirmed(confirmation)) { return confirmation; } const cameraRebootData = await rebootCameras(cameraUuids, extra._meta?.requestModifiers, extra.sessionId); if (!cameraRebootData) { return { content: [ { type: "text", text: "Failed to reboot cameras", }, ], }; } return { content: [ { type: "text", text: JSON.stringify(cameraRebootData), }, ], }; }; export function createTool(server) { server.registerTool(TOOL_NAME, { title: "Reboot Cameras", description: TOOL_DESCRIPTION, inputSchema: TOOL_ARGS, annotations: { readOnlyHint: false, destructiveHint: true }, }, TOOL_HANDLER); }