purchase_product
Purchase digital products on the402.ai marketplace using pre-funded USDC balance. Complete transactions for AI services and access purchased items via download.
Instructions
Purchase a digital product on the402.ai. Payment is deducted from your pre-funded balance. After purchase, use list_purchases to find the product and download it. Requires API key.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | The product ID to purchase |
Implementation Reference
- src/tools/purchases.ts:36-45 (handler)The handler function for the "purchase_product" tool, which triggers a POST request to purchase a digital product.
async ({ product_id }) => { const result = await client.balancePost( `/v1/products/${product_id}/purchase` ); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } - src/tools/purchases.ts:30-46 (registration)Registration of the "purchase_product" tool within the MCP server.
server.tool( "purchase_product", "Purchase a digital product on the402.ai. Payment is deducted from your pre-funded balance. After purchase, use list_purchases to find the product and download it. Requires API key.", { product_id: z.string().describe("The product ID to purchase"), }, async ({ product_id }) => { const result = await client.balancePost( `/v1/products/${product_id}/purchase` ); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } );