mattrguerra/meridian-orders-mcpmainPrivate on GitHub, published here in full

getInventory.ts

Language TypeScript1.2 KB29 lines

mcp-server/src/tools/getInventory.ts

  1. import { z } from "zod";
  2. import type { ToolModule } from "./types.js";
  3. import { plinthRequest, type PlinthParams } from "../lib/http.js";
  4. /**
  5. * get_inventory: stock levels (Plinth method `inventory.fetch`), the read side
  6. * only. The parameter and response schemas have not been probed, so the tool
  7. * takes a passthrough `params` bag. The write counterpart `inventory.adjust` is
  8. * not on the allowlist, and the guard rejects any write-intent key in the bag.
  9. */
  10. export const getInventory: ToolModule = {
  11. name: "get_inventory",
  12. config: {
  13. title: "Get inventory (unprobed)",
  14. description:
  15. "Stock/inventory levels. Read-only. UNPROBED: parameter/response schema not yet verified.",
  16. inputSchema: {
  17. params: z
  18. .record(z.string(), z.union([z.string(), z.number()]))
  19. .optional()
  20. .describe("Raw passthrough params until the real schema is probed."),
  21. },
  22. },
  23. async handler(args, ctx) {
  24. const { params } = args as { params?: Record<string, string | number> };
  25. const body = await plinthRequest(ctx, "inventory.fetch", (params ?? {}) as PlinthParams);
  26. return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
  27. },
  28. };