rr_cancel_purchase_order
Cancel purchase orders to manage inventory and prevent unnecessary stock. This tool helps Shopify and Amazon sellers maintain optimal stock levels by removing pending orders.
Instructions
Cancel a purchase order
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| po_id | Yes |
Implementation Reference
- src/index.ts:52-52 (registration)Tool registration in TOOLS array: defines 'rr_cancel_purchase_order' with description 'Cancel a purchase order' and inputSchema specifying po_id as required parameter
{ name: 'rr_cancel_purchase_order', description: 'Cancel a purchase order', inputSchema: { type: 'object' as const, properties: { po_id: { type: 'string' } }, required: ['po_id'] } }, - src/index.ts:52-52 (schema)Input schema definition: requires po_id (string) parameter to identify which purchase order to cancel
{ name: 'rr_cancel_purchase_order', description: 'Cancel a purchase order', inputSchema: { type: 'object' as const, properties: { po_id: { type: 'string' } }, required: ['po_id'] } }, - src/index.ts:57-74 (handler)Handler function (callApi): executes tool logic by making POST request to https://api.replenishradar.com/api/mcp/call with tool name and input arguments, returns the API result
async function callApi(toolName: string, input: Record<string, unknown>): Promise<unknown> { const resp = await fetch(`${BASE_URL}/api/mcp/call`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}`, }, body: JSON.stringify({ tool: toolName, input }), }); if (!resp.ok) { const errorBody = await resp.text(); throw new Error(`API error ${resp.status}: ${errorBody}`); } const data = await resp.json(); return data.result; } - src/index.ts:86-100 (handler)Request handler: CallToolRequestSchema handler that receives tool invocation requests and routes them to callApi function with the tool name and arguments
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const result = await callApi(name, (args as Record<string, unknown>) || {}); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true, }; } });