cancel_order
Cancel an order in the ShipBob API by providing the order ID and optional reason, enabling efficient management of e-commerce fulfillment processes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orderId | Yes | The ID of the order to cancel | |
| reason | No | Reason for cancellation |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"orderId": {
"description": "The ID of the order to cancel",
"type": "string"
},
"reason": {
"description": "Reason for cancellation",
"type": "string"
}
},
"required": [
"orderId"
],
"type": "object"
}
Implementation Reference
- src/tools/order-tools.js:105-121 (handler)The main handler function for the 'cancel_order' MCP tool. It takes orderId and optional reason, constructs cancelData, calls shipbobClient.cancelOrder, and returns a formatted success message or error response.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 (string, required), reason (string, optional).schema: { orderId: z.string().describe("The ID of the order to cancel"), reason: z.string().optional().describe("Reason for cancellation") },
- src/server.js:23-32 (registration)The registerTools function used to register the cancel_order tool (as part of orderTools array) with the MCP server by calling server.tool() for each tool.const registerTools = (toolsArray) => { toolsArray.forEach(tool => { server.tool( tool.name, tool.schema, tool.handler, { description: tool.description } ); }); };
- src/api-client.js:84-86 (helper)ShipBobClient method that performs the actual API request to cancel an order via POST to /orders/{id}/cancel.async cancelOrder(id, cancelData) { return this.request('POST', `/orders/${id}/cancel`, cancelData); }
- src/server.js:51-51 (registration)Specific call to register the orderTools array, which includes the cancel_order tool.registerTools(orderTools);