get_order
Retrieve a complete order record by GID or numeric ID, including header fields, line items, and customer email, returned as JSON for downstream tooling. Requires prior use of list_orders to obtain the order identifier.
Instructions
Fetch a single order's full record by GID or numeric ID — includes header fields (email, totals, both status flags, timestamps), full line items (title + quantity), and the customer email if on file. Returned as JSON for downstream tooling. Use list_orders to discover order IDs first. To inspect or act on shipments for this order, follow up with list_fulfillment_orders.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Order GID ('gid://shopify/Order/123') or numeric ID — both forms accepted; numeric IDs are auto-promoted. Get one from list_orders. |
Implementation Reference
- src/tools/orders.ts:354-367 (handler)The handler function for the 'get_order' tool. It executes the GraphQL GET_ORDER_QUERY, converts the input ID using toGid, handles the null case (order not found), and returns the order data as formatted JSON.
async (args) => { const data = await client.graphql<{ order: Order | null }>( GET_ORDER_QUERY, { id: toGid(args.id, "Order") }, ); if (!data.order) { return { content: [{ type: "text" as const, text: `Order not found: ${args.id}` }], }; } return { content: [{ type: "text" as const, text: JSON.stringify(data.order, null, 2) }], }; }, - src/tools/orders.ts:132-138 (schema)Input schema for the 'get_order' tool. Defines a single 'id' parameter that accepts an Order GID or numeric ID, with a description explaining both forms are accepted and numeric IDs are auto-promoted.
const getOrderSchema = { id: z .string() .describe( "Order GID ('gid://shopify/Order/123') or numeric ID — both forms accepted; numeric IDs are auto-promoted. Get one from list_orders.", ), }; - src/tools/orders.ts:350-368 (registration)Registration of 'get_order' with the MCP server via server.tool(), including the tool name, description, schema, and handler. The getOrderSchema and GET_ORDER_QUERY are bound here.
server.tool( "get_order", "Fetch a single order's full record by GID or numeric ID — includes header fields (email, totals, both status flags, timestamps), full line items (title + quantity), and the customer email if on file. Returned as JSON for downstream tooling. Use list_orders to discover order IDs first. To inspect or act on shipments for this order, follow up with list_fulfillment_orders.", getOrderSchema, async (args) => { const data = await client.graphql<{ order: Order | null }>( GET_ORDER_QUERY, { id: toGid(args.id, "Order") }, ); if (!data.order) { return { content: [{ type: "text" as const, text: `Order not found: ${args.id}` }], }; } return { content: [{ type: "text" as const, text: JSON.stringify(data.order, null, 2) }], }; }, ); - src/server.ts:58-58 (registration)Where registerOrderTools is called to register all order tools (including get_order) on the McpServer instance.
registerOrderTools(s, shopify); - src/tools/orders.ts:28-43 (helper)GraphQL query used by the get_order handler to fetch an order's details including id, name, email, status flags, totals, and line items.
const GET_ORDER_QUERY = /* GraphQL */ ` query GetOrder($id: ID!) { order(id: $id) { id name email displayFinancialStatus displayFulfillmentStatus totalPriceSet { shopMoney { amount currencyCode } } createdAt lineItems(first: 50) { edges { node { title quantity } } } } } `;