get_fulfillment_order
Fetch a fulfillment order by GID with complete line-item details and remaining quantities. Use this when you have the FulfillmentOrder ID directly, such as from a webhook, to obtain detailed information without querying the parent order.
Instructions
Fetch a single fulfillment order by GID with its full line-item set and remaining quantities. Use this when you have the FulfillmentOrder ID directly (e.g. from a webhook payload) and want detail without having to look up its parent order first. Returns the same shape as list_fulfillment_orders for one record.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | FulfillmentOrder GID. |
Implementation Reference
- src/tools/fulfillment.ts:308-331 (handler)The 'get_fulfillment_order' tool handler. It executes a GraphQL query (GET_FULFILLMENT_ORDER_QUERY) using the provided fulfillment order GID, and formats the response using summarizeFulfillmentOrder(). Registered via server.tool() with the name 'get_fulfillment_order'.
server.tool( "get_fulfillment_order", "Fetch a single fulfillment order by GID with its full line-item set and remaining quantities. Use this when you have the FulfillmentOrder ID directly (e.g. from a webhook payload) and want detail without having to look up its parent order first. Returns the same shape as list_fulfillment_orders for one record.", getFulfillmentOrderSchema, async (args) => { const data = await client.graphql<{ fulfillmentOrder: FulfillmentOrderNode | null; }>(GET_FULFILLMENT_ORDER_QUERY, { id: args.id }); if (!data.fulfillmentOrder) { return { content: [ { type: "text" as const, text: `Fulfillment order not found: ${args.id}` }, ], }; } return { content: [ { type: "text" as const, text: summarizeFulfillmentOrder(data.fulfillmentOrder).join("\n"), }, ], }; }, - src/tools/fulfillment.ts:204-206 (schema)The input schema for get_fulfillment_order. It defines a single required parameter 'id' of type string (a FulfillmentOrder GID).
const getFulfillmentOrderSchema = { id: z.string().describe("FulfillmentOrder GID."), }; - src/tools/fulfillment.ts:84-106 (helper)The GraphQL query used by get_fulfillment_order. It fetches a fulfillment order by ID including status, requestStatus, assignedLocation, destination, lineItems (up to 100), and createdAt.
const GET_FULFILLMENT_ORDER_QUERY = /* GraphQL */ ` query GetFulfillmentOrder($id: ID!) { fulfillmentOrder(id: $id) { id status requestStatus assignedLocation { name location { id } } destination { address1 city countryCode zip } lineItems(first: 100) { edges { node { id totalQuantity remainingQuantity lineItem { id title sku } } } pageInfo { hasNextPage } } createdAt } } `; - src/tools/fulfillment.ts:236-256 (helper)The summarizeFulfillmentOrder helper function used by the handler to format the fulfillment order data into human-readable text.
function summarizeFulfillmentOrder(fo: FulfillmentOrderNode): string[] { const lines: string[] = [ ` ${fo.id} [${fo.status}/${fo.requestStatus}] at ${fo.assignedLocation.name}`, ]; if (fo.destination) { const d = fo.destination; lines.push( ` ship to: ${[d.address1, d.city, d.zip, d.countryCode].filter(Boolean).join(", ") || "(no address)"}`, ); } for (const edge of fo.lineItems.edges) { const li = edge.node; lines.push( ` - ${li.lineItem.title}${li.lineItem.sku ? ` (SKU ${li.lineItem.sku})` : ""} — ${li.remainingQuantity}/${li.totalQuantity} remaining — ${li.id}`, ); } if (fo.lineItems.pageInfo.hasNextPage) { lines.push(" (more line items available)"); } return lines; } - src/server.ts:65-70 (registration)Registration of the fulfillment tools (including get_fulfillment_order) via registerFulfillmentTools(s, shopify) in the server's buildServer function.
registerFulfillmentTools(s, shopify); registerWebhookTools(s, shopify); registerMetaobjectTools(s, shopify); registerAnalyticsTools(s, shopify); registerBridgeTools(s, shopify, comfyui, config.comfyUIDefaultCkpt); return s;