PostOrdersIdTransferCancel
Cancel a previously requested order transfer using the Medusa MCP Server. Ideal for reversing order transfer requests initiated by the logged-in customer via the API.
Instructions
Cancel an order transfer that the logged-in customer previously requested using the Request Order Transfer API route.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | ||
| id | No |
Implementation Reference
- src/services/medusa-store.ts:83-127 (handler)The core handler logic for the PostOrdersIdTransferCancel tool (and all store tools). It constructs query parameters and body from input, then performs an HTTP fetch to the Medusa store API endpoint using the SDK.handler: async ( input: InferToolHandlerInput<any, ZodTypeAny> ): Promise<any> => { const query = new URLSearchParams(input); const body = Object.entries(input).reduce( (acc, [key, value]) => { if ( parameters.find( (p) => p.name === key && p.in === "body" ) ) { acc[key] = value; } return acc; }, {} as Record<string, any> ); if (method === "get") { console.error( `Fetching ${refPath} with GET ${query.toString()}` ); const response = await this.sdk.client.fetch(refPath, { method: method, headers: { "Content-Type": "application/json", "Accept": "application/json", "Authorization": `Bearer ${process.env.PUBLISHABLE_KEY}` }, query: query }); return response; } else { const response = await this.sdk.client.fetch(refPath, { method: method, headers: { "Content-Type": "application/json", "Accept": "application/json", "Authorization": `Bearer ${process.env.PUBLISHABLE_KEY}` }, body: JSON.stringify(body) }); return response; } } };
- src/services/medusa-store.ts:54-82 (schema)Dynamic Zod input schema generation for PostOrdersIdTransferCancel tool based on OpenAPI parameters from store.json, filtering headers and mapping types to Zod validators.inputSchema: { ...parameters .filter((p) => p.in != "header") .reduce((acc, param) => { switch (param.schema.type) { case "string": acc[param.name] = z.string().optional(); break; case "number": acc[param.name] = z.number().optional(); break; case "boolean": acc[param.name] = z.boolean().optional(); break; case "array": acc[param.name] = z .array(z.string()) .optional(); break; case "object": acc[param.name] = z.object({}).optional(); break; default: acc[param.name] = z.string().optional(); } return acc; }, {} as any) },
- src/services/medusa-store.ts:131-137 (registration)The defineTools method registers the PostOrdersIdTransferCancel tool by mapping over all paths in the store OpenAPI spec (store.json) and wrapping each into a tool definition.defineTools(store = storeJson): any[] { const paths = Object.entries(store.paths) as [string, SdkRequestType][]; const tools = paths.map(([path, refFunction]) => this.wrapPath(path, refFunction) ); return tools; }
- src/index.ts:35-42 (registration)Final registration of all tools, including PostOrdersIdTransferCancel, to the MCP server by calling server.tool for each.tools.forEach((tool) => { server.tool( tool.name, tool.description, tool.inputSchema, tool.handler ); });