rhombus-node-mcp
Version:
MCP server for Rhombus API
34 lines (33 loc) • 1.1 kB
JavaScript
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) }],
};
});
}