rhombus-node-mcp
Version:
MCP server for Rhombus API
57 lines (56 loc) • 1.79 kB
JavaScript
import { postApi } from "../network/network.js";
export async function getLocations(requestModifiers, sessionId) {
const res = await postApi({
route: "/location/getLocationsV2",
body: {},
modifiers: requestModifiers,
sessionId,
});
return {
locations: (res.locations || []).map((loc) => ({
uuid: loc.uuid ?? undefined,
name: loc.name ?? undefined,
})),
};
}
export async function createLocation(name, address, requestModifiers, sessionId) {
const res = await postApi({
route: "/location/createLocation",
body: { name, address: address || undefined },
modifiers: requestModifiers,
sessionId,
});
if (res.error)
throw new Error(JSON.stringify(res));
return { uuid: res.locationUuid ?? res.uuid ?? undefined, success: true };
}
export async function updateLocation(locationUuid, name, address, requestModifiers, sessionId) {
const body = { locationUuid };
if (name)
body.name = name;
if (address)
body.address = address;
const res = await postApi({
route: "/location/updateLocation",
body,
modifiers: requestModifiers,
sessionId,
});
if (res.error)
throw new Error(JSON.stringify(res));
return { success: true };
}
export async function getLocationLabels(requestModifiers, sessionId) {
const res = await postApi({
route: "/location/getLocationLabelsForOrg",
body: {},
modifiers: requestModifiers,
sessionId,
});
if (res.error)
throw new Error(JSON.stringify(res));
return (res.locationLabels || []).map((label) => ({
uuid: label.uuid ?? undefined,
name: label.name ?? undefined,
}));
}