UNPKG

rhombus-node-mcp

Version:
34 lines (33 loc) 1.1 kB
import { z } from "zod"; import { postApi } from "../network.js"; async function getLocations(requestModifiers) { return await postApi("/location/getLocationsV2", {}, requestModifiers); } export function createTool(server) { server.tool("location-tool", `This tool performs operations on locations. - 'get': Retrieves all locations.`, { action: z.enum(["get", "update"]), locationUpdate: z .object({ uuid: z.string(), name: z.string(), }) .optional(), }, async ({ action }, extra) => { let ret; switch (action) { case "get": ret = await getLocations(extra._meta?.requestModifiers); break; case "update": ret = { error: true, status: "not implemented" }; break; default: ret = { error: true, status: `unsupported location tool call: ${action}` }; break; } return { content: [{ type: "text", text: JSON.stringify(ret) }], }; }); }