Skip to main content
Glama

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

NameRequiredDescriptionDefault
orderIdYesThe ID of the order to cancel
reasonNoReason 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

  • 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 }; } }
  • 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 } ); }); };
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mattcoatsworth/shipbob-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server