Create a product
deonpay_create_productAdd a new product to your DeonPay catalog. Requires name and unit amount (minimum $10 MXN in centavos). Optionally set SKU, stock tracking, and description.
Instructions
Create a new product in the catalog. Use this when the user says 'add a product called X for $Y' or wants to register inventory items they'll later attach to payment links / checkout sessions. unit_amount is in CENTAVOS and must be at least 1000 ($10.00 MXN minimum on creation). SKU must be unique within the merchant. To track stock, set stock_tracking=true AND provide stock_quantity (>= 0).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Product name. | |
| unit_amount | Yes | Unit price in CENTAVOS (minimum 1000 = $10.00 MXN on creation). | |
| description | No | ||
| currency | No | ISO currency code (default 'MXN'). | |
| image_url | No | ||
| sku | No | Unique SKU within the merchant catalog. | |
| is_active | No | Whether the product is sellable (default true). | |
| stock_tracking | No | Enable inventory tracking. | |
| stock_quantity | No | Initial stock count (required when stock_tracking is true). | |
| metadata | No |
Implementation Reference
- src/tools/products.ts:64-95 (handler)The tool registration with async handler that POSTs to /products with the compacted input args.
server.registerTool( "deonpay_create_product", { title: "Create a product", description: "Create a new product in the catalog. Use this when the user says 'add a product called X for $Y' or wants to register inventory items they'll later attach to payment links / checkout sessions. unit_amount is in CENTAVOS and must be at least 1000 ($10.00 MXN minimum on creation). SKU must be unique within the merchant. To track stock, set stock_tracking=true AND provide stock_quantity (>= 0).", inputSchema: { name: z.string().min(1).max(255).describe("Product name."), unit_amount: z .number() .int() .min(1000) .describe("Unit price in CENTAVOS (minimum 1000 = $10.00 MXN on creation)."), description: z.string().max(1000).optional(), currency: z.string().length(3).optional().describe("ISO currency code (default 'MXN')."), image_url: z.string().url().optional(), sku: z.string().max(100).optional().describe("Unique SKU within the merchant catalog."), is_active: z.boolean().optional().describe("Whether the product is sellable (default true)."), stock_tracking: z.boolean().optional().describe("Enable inventory tracking."), stock_quantity: z .number() .int() .min(0) .optional() .describe("Initial stock count (required when stock_tracking is true)."), metadata: z.record(z.unknown()).optional(), }, }, safeHandler(async (args) => { return client.post("/products", compact(args)); }), ); - src/tools/products.ts:70-91 (schema)Zod input schema for deonpay_create_product: name (required), unit_amount in centavos (min 1000), plus optional description, currency, image_url, sku, is_active, stock_tracking, stock_quantity, metadata.
inputSchema: { name: z.string().min(1).max(255).describe("Product name."), unit_amount: z .number() .int() .min(1000) .describe("Unit price in CENTAVOS (minimum 1000 = $10.00 MXN on creation)."), description: z.string().max(1000).optional(), currency: z.string().length(3).optional().describe("ISO currency code (default 'MXN')."), image_url: z.string().url().optional(), sku: z.string().max(100).optional().describe("Unique SKU within the merchant catalog."), is_active: z.boolean().optional().describe("Whether the product is sellable (default true)."), stock_tracking: z.boolean().optional().describe("Enable inventory tracking."), stock_quantity: z .number() .int() .min(0) .optional() .describe("Initial stock count (required when stock_tracking is true)."), metadata: z.record(z.unknown()).optional(), }, }, - src/tools/index.ts:24-24 (registration)Registration call in the central tool registry, invoked via registerProductTools in registerAllTools.
registerProductTools(server, client); - src/tools/_helpers.ts:57-68 (helper)safeHandler wraps the tool handler with try/catch to convert thrown errors into 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); } }; } - src/tools/_helpers.ts:83-91 (helper)compact strips undefined/null/empty-string entries from the input args before sending to the API.
export function compact<T extends Record<string, unknown>>(obj: T): Partial<T> { const out: Record<string, unknown> = {}; for (const [key, value] of Object.entries(obj)) { if (value === undefined || value === null) continue; if (typeof value === "string" && value.trim() === "") continue; out[key] = value; } return out as Partial<T>; }