Skip to main content
Glama

PostOrdersIdTransferAccept

Accept an order transfer to a customer's account after a transfer request is made via the Medusa MCP Server. This tool processes approved transfer requests from store or admin API routes.

Instructions

Accept an order to be transfered to a customer's account, which was specified when the transfer request was created. The transfer is requested previously either by the customer using the Request Order Transfer Store API route, or by the admin using the Request Order Transfer Admin API route.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldsNo
idNo

Implementation Reference

  • src/index.ts:35-42 (registration)
    Registration of all tools, including "PostOrdersIdTransferAccept", by calling server.tool for each tool defined in services.
    tools.forEach((tool) => { server.tool( tool.name, tool.description, tool.inputSchema, tool.handler ); });
  • The handler function that executes the logic for the tool 'PostOrdersIdTransferAccept'. It constructs query/body from input and makes an HTTP POST request to the corresponding 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; } } };
  • Dynamic input schema construction based on OpenAPI parameters for the tool, using Zod schemas matching the parameter types.
    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) },
  • wrapPath helper that creates the tool definition for each OpenAPI path, setting name from operationId (e.g., 'PostOrdersIdTransferAccept'), description, schema, and generic handler. Used in defineTools to generate store tools.
    wrapPath(refPath: string, refFunction: SdkRequestType) { return defineTool((z): any => { let name; let description; let parameters: Parameter[] = []; let method = "get"; if ("get" in refFunction) { method = "get"; name = refFunction.get.operationId; description = refFunction.get.description; parameters = refFunction.get.parameters; } else if ("post" in refFunction) { method = "post"; name = refFunction.post.operationId; description = refFunction.post.description; parameters = refFunction.post.parameters ?? []; } if (!name) { throw new Error("No name found for the function"); } return { name: name!, description: description, 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) }, 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/index.ts:14-17 (registration)
    Calls defineTools on MedusaStoreService, which generates and returns the list of tools including 'PostOrdersIdTransferAccept'.
    tools = [ ...medusaStoreService.defineTools(), ...medusaAdminService.defineTools() ];

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/SGFGOV/medusa-mcp'

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