Get product details
deonpay_get_productRetrieve product details including name, description, price, and stock information by providing a product UUID or SKU.
Instructions
Fetch a single product by UUID OR by SKU (if you pass a non-UUID string the API resolves it as a SKU). Returns name, description, unit_amount in centavos, currency, image_url, sku, is_active, stock_tracking, stock_quantity and metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Product UUID or SKU. |
Implementation Reference
- src/tools/products.ts:46-59 (registration)Registration of the deonpay_get_product tool with schema (id required) and handler. The tool calls GET /api/v1/products/{id} via the DeonpayClient.
server.registerTool( "deonpay_get_product", { title: "Get product details", description: "Fetch a single product by UUID OR by SKU (if you pass a non-UUID string the API resolves it as a SKU). Returns name, description, unit_amount in centavos, currency, image_url, sku, is_active, stock_tracking, stock_quantity and metadata.", inputSchema: { id: z.string().min(1).describe("Product UUID or SKU."), }, }, safeHandler(async ({ id }) => { return client.get(`/products/${encodeURIComponent(id)}`); }), ); - src/tools/products.ts:56-59 (handler)The handler for deonpay_get_product — it extracts the `id` argument (UUID or SKU), URL-encodes it, and makes a GET request to `/products/{id}` via the HTTP client.
safeHandler(async ({ id }) => { return client.get(`/products/${encodeURIComponent(id)}`); }), ); - src/tools/products.ts:52-54 (schema)Input schema: one required `id` field (string, min length 1) described as a product UUID or SKU.
inputSchema: { id: z.string().min(1).describe("Product UUID or SKU."), }, - src/tools/_helpers.ts:57-68 (helper)safeHandler wraps the handler function with try/catch, converting success to pretty JSON result and errors to MCP error results.
export function safeHandler<TArgs>( fn: (args: TArgs) => Promise<unknown>, ): (args: TArgs) => Promise<CallToolResult> { return async (args: TArgs) => { try { const value = await fn(args); return jsonResult(value); } catch (err) { return errorResult(err); } }; }