getInventory.ts
Language TypeScript1.2 KB29 lines
import { z } from "zod";import type { ToolModule } from "./types.js";import { plinthRequest, type PlinthParams } from "../lib/http.js";/*** get_inventory: stock levels (Plinth method `inventory.fetch`), the read side* only. The parameter and response schemas have not been probed, so the tool* takes a passthrough `params` bag. The write counterpart `inventory.adjust` is* not on the allowlist, and the guard rejects any write-intent key in the bag.*/export const getInventory: ToolModule = {name: "get_inventory",config: {title: "Get inventory (unprobed)",description:"Stock/inventory levels. Read-only. UNPROBED: parameter/response schema not yet verified.",inputSchema: {params: z.record(z.string(), z.union([z.string(), z.number()])).optional().describe("Raw passthrough params until the real schema is probed."),},},async handler(args, ctx) {const { params } = args as { params?: Record<string, string | number> };const body = await plinthRequest(ctx, "inventory.fetch", (params ?? {}) as PlinthParams);return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };},};