cancel_order
Cancel an order in ShipBob's fulfillment system by providing the order ID and optional reason, enabling order management adjustments.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orderId | Yes | The ID of the order to cancel | |
| reason | No | Reason for cancellation |
Implementation Reference
- src/tools/order-tools.js:105-121 (handler)The handler function for the 'cancel_order' tool. It destructures orderId and optional reason, prepares cancelData, calls shipbobClient.cancelOrder, and returns a formatted MCP response or error.handler: async ({ orderId, reason }) => { try { const cancelData = { reason }; const result = await shipbobClient.cancelOrder(orderId, cancelData); return { content: [{ type: "text", text: `Order cancelled successfully: ${JSON.stringify(result, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error cancelling order: ${error.message}` }], isError: true }; } }
- src/tools/order-tools.js:101-104 (schema)Zod schema defining the input parameters for the cancel_order tool: orderId (required string) and reason (optional string).schema: { orderId: z.string().describe("The ID of the order to cancel"), reason: z.string().optional().describe("Reason for cancellation") },
- src/server.js:51-51 (registration)Registers the orderTools array (which includes cancel_order) by calling registerTools, which in turn calls server.tool() for each tool.registerTools(orderTools);
- src/api-client.js:84-86 (helper)ShipBobClient helper method that makes the POST request to the ShipBob API to cancel an order using the generic request method.async cancelOrder(id, cancelData) { return this.request('POST', `/orders/${id}/cancel`, cancelData); }