UNPKG

rhombus-node-mcp

Version:
31 lines (30 loc) 1.23 kB
import { z } from "zod"; import { logger } from "../logger.js"; export function createTool(server) { server.registerTool("count-tool", { title: "Count Items", description: ` This tool counts the number of items by accepting an array of UUIDs. It can count anything that has UUIDs - users, devices, records, or any other entities. Simply provide an array of UUID strings and it will return the precise count. `, inputSchema: { uuids: z .array(z.string().describe("UUID string of an individual item")) .describe("An array of UUID strings representing the items to count. Each string should be a valid UUID."), }, annotations: { readOnlyHint: true }, }, async ({ uuids }) => { try { logger.info("Counting UUIDs", uuids); return { content: [{ type: "text", text: `Count: ${uuids.length}` }], }; } catch (e) { const errorMessage = e instanceof Error ? e.message : `Unknown error: ${e}`; return { content: [{ type: "text", text: `Error counting UUIDs: ${errorMessage}` }], }; } }); }