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

getProduct.ts

Language TypeScript1.2 KB30 lines

mcp-server/src/tools/getProduct.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_product: product specs and turnaround times (Plinth method
  6. * `products.fetch`). The parameter and response schemas have not been probed,
  7. * so the tool takes a passthrough `params` bag; tighten the inputSchema once a
  8. * live probe shows the real params. The guard in plinthRequest rejects any
  9. * reserved or write-intent key in the bag.
  10. */
  11. export const getProduct: ToolModule = {
  12. name: "get_product",
  13. config: {
  14. title: "Get product info (unprobed)",
  15. description:
  16. "Product specs and turnaround times. Read-only. UNPROBED: parameter/response schema not yet verified.",
  17. inputSchema: {
  18. params: z
  19. .record(z.string(), z.union([z.string(), z.number()]))
  20. .optional()
  21. .describe("Raw passthrough params until the real schema is probed."),
  22. },
  23. },
  24. async handler(args, ctx) {
  25. const { params } = args as { params?: Record<string, string | number> };
  26. const body = await plinthRequest(ctx, "products.fetch", (params ?? {}) as PlinthParams);
  27. return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
  28. },
  29. };