Skip to main content
Glama

create_fulfillment

Mark items as shipped by creating a fulfillment record. Supports partial fulfillment, tracking info, and customer notification.

Instructions

Mark items as shipped — creates a fulfillment record covering one or more fulfillment orders. For each fulfillment order in the request, you can either fulfill everything still remaining (omit fulfillmentOrderLineItems) or specify per-line {id, quantity} pairs for partial shipments. Optionally attach tracking info (carrier + number; URL is auto-derived for major carriers like USPS/UPS/FedEx/DHL) and set notifyCustomer=true to send the shipment-confirmation email. The fulfillmentOrderLineItem IDs come from list_fulfillment_orders. Side effects: customer-facing email if notifyCustomer is true; webhook fires; remaining quantities decrement.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lineItemsByFulfillmentOrderYesOne entry per fulfillment order being fulfilled in this shipment.
trackingInfoNoTracking info. Company+number is enough; Shopify auto-derives URL for known carriers.
notifyCustomerNoSend the customer a shipment notification email.

Implementation Reference

  • The handler for the create_fulfillment tool. It constructs the fulfillment input, calls the FulfillmentCreate GraphQL mutation, checks for user errors, and returns the created fulfillment details (name, status, id, order, tracking).
    server.tool(
    "create_fulfillment",
    "Mark items as shipped — creates a fulfillment record covering one or more fulfillment orders. For each fulfillment order in the request, you can either fulfill everything still remaining (omit `fulfillmentOrderLineItems`) or specify per-line {id, quantity} pairs for partial shipments. Optionally attach tracking info (carrier + number; URL is auto-derived for major carriers like USPS/UPS/FedEx/DHL) and set notifyCustomer=true to send the shipment-confirmation email. The fulfillmentOrderLineItem IDs come from list_fulfillment_orders. Side effects: customer-facing email if notifyCustomer is true; webhook fires; remaining quantities decrement.",
    createFulfillmentSchema,
    async (args) => {
      const fulfillment: Record<string, unknown> = {
        lineItemsByFulfillmentOrder: args.lineItemsByFulfillmentOrder,
      };
      if (args.trackingInfo) fulfillment.trackingInfo = args.trackingInfo;
      if (args.notifyCustomer !== undefined) {
        fulfillment.notifyCustomer = args.notifyCustomer;
      }
    
      const data = await client.graphql<{
        fulfillmentCreate: {
          fulfillment: FulfillmentNode | null;
          userErrors: ShopifyUserError[];
        };
      }>(FULFILLMENT_CREATE_MUTATION, { fulfillment });
      throwIfUserErrors(data.fulfillmentCreate.userErrors, "fulfillmentCreate");
      const f = data.fulfillmentCreate.fulfillment;
      if (!f) {
        return {
          content: [
            { type: "text" as const, text: "fulfillmentCreate returned no fulfillment." },
          ],
        };
      }
      const tracking = f.trackingInfo
        .map((t) => [t.company, t.number, t.url].filter(Boolean).join(" | "))
        .filter(Boolean)
        .join("; ");
      return {
        content: [
          {
            type: "text" as const,
            text: [
              `Created fulfillment ${f.name} [${f.status}] — ${f.id}`,
              f.order ? `  Order: ${f.order.name} (${f.order.id})` : "",
              tracking ? `  Tracking: ${tracking}` : "",
            ]
              .filter(Boolean)
              .join("\n"),
          },
        ],
      };
    },
  • Schema definition for create_fulfillment tool inputs: lineItemsByFulfillmentOrder (array of fulfillment order + line item selections), optional trackingInfo, optional notifyCustomer.
    const createFulfillmentSchema = {
      lineItemsByFulfillmentOrder: z
        .array(lineItemByFulfillmentOrderSchema)
        .min(1)
        .describe("One entry per fulfillment order being fulfilled in this shipment."),
      trackingInfo: trackingInfoSchema.optional(),
      notifyCustomer: z
        .boolean()
        .optional()
        .describe("Send the customer a shipment notification email."),
    };
  • The registerFulfillmentTools function registers all fulfillment tools (including create_fulfillment) on the MCP server using server.tool().
    export function registerFulfillmentTools(
      server: McpServer,
      client: ShopifyClient,
    ): void {
      server.tool(
        "list_fulfillment_orders",
        "List the fulfillment orders attached to a Shopify order. A fulfillment order groups line items by the location that will ship them — a single order can have multiple fulfillment orders if items split across warehouses. Each one tracks per-line remaining quantity (totalQuantity minus what's already shipped/cancelled). Returns the assigned location, destination address, and line-item progress for each. This is the primary read tool you'll call before create_fulfillment to figure out which fulfillmentOrderLineItem IDs and quantities to mark as shipped.",
        listFulfillmentOrdersSchema,
        async (args) => {
          const data = await client.graphql<{
            order:
              | {
                  id: string;
                  name: string;
                  fulfillmentOrders: {
                    edges: Array<{ node: FulfillmentOrderNode }>;
                  };
                }
              | null;
          }>(LIST_FULFILLMENT_ORDERS_QUERY, { orderId: args.orderId });
          if (!data.order) {
            return {
              content: [
                { type: "text" as const, text: `Order not found: ${args.orderId}` },
              ],
            };
          }
          const fos = data.order.fulfillmentOrders.edges;
          if (fos.length === 0) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Order ${data.order.name} has no fulfillment orders.`,
                },
              ],
            };
          }
          const lines: string[] = [
            `Order ${data.order.name} has ${fos.length} fulfillment order(s):`,
          ];
          for (const { node } of fos) {
            lines.push(...summarizeFulfillmentOrder(node));
          }
          return {
            content: [{ type: "text" as const, text: lines.join("\n") }],
          };
        },
      );
    
      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"),
              },
            ],
          };
        },
      );
    
      server.tool(
        "get_fulfillment",
        "Fetch a single fulfillment (a shipment record produced by create_fulfillment) by GID. Returns its status (SUCCESS/CANCELLED/etc.), tracking entries (carrier, number, URL), the parent order, and timestamps. Use after create_fulfillment to confirm the shipment took, or when a webhook delivers a fulfillment GID and you need the details.",
        getFulfillmentSchema,
        async (args) => {
          const data = await client.graphql<{ fulfillment: FulfillmentNode | null }>(
            GET_FULFILLMENT_QUERY,
            { id: args.id },
          );
          if (!data.fulfillment) {
            return {
              content: [
                { type: "text" as const, text: `Fulfillment not found: ${args.id}` },
              ],
            };
          }
          const f = data.fulfillment;
          const tracking = f.trackingInfo
            .map((t) => {
              const parts = [t.company, t.number, t.url].filter(Boolean);
              return parts.length > 0 ? `    - ${parts.join(" | ")}` : "    - (empty)";
            })
            .join("\n");
          return {
            content: [
              {
                type: "text" as const,
                text: [
                  `${f.name} [${f.status}]`,
                  `  ID: ${f.id}`,
                  f.order ? `  Order: ${f.order.name} (${f.order.id})` : "",
                  f.totalQuantity !== null && f.totalQuantity !== undefined
                    ? `  Total quantity: ${f.totalQuantity}`
                    : "",
                  "  Tracking:",
                  tracking || "    (none)",
                  `  Created: ${f.createdAt}`,
                  `  Updated: ${f.updatedAt}`,
                ]
                  .filter(Boolean)
                  .join("\n"),
              },
            ],
          };
        },
      );
    
        server.tool(
        "create_fulfillment",
        "Mark items as shipped — creates a fulfillment record covering one or more fulfillment orders. For each fulfillment order in the request, you can either fulfill everything still remaining (omit `fulfillmentOrderLineItems`) or specify per-line {id, quantity} pairs for partial shipments. Optionally attach tracking info (carrier + number; URL is auto-derived for major carriers like USPS/UPS/FedEx/DHL) and set notifyCustomer=true to send the shipment-confirmation email. The fulfillmentOrderLineItem IDs come from list_fulfillment_orders. Side effects: customer-facing email if notifyCustomer is true; webhook fires; remaining quantities decrement.",
        createFulfillmentSchema,
        async (args) => {
          const fulfillment: Record<string, unknown> = {
            lineItemsByFulfillmentOrder: args.lineItemsByFulfillmentOrder,
          };
          if (args.trackingInfo) fulfillment.trackingInfo = args.trackingInfo;
          if (args.notifyCustomer !== undefined) {
            fulfillment.notifyCustomer = args.notifyCustomer;
          }
    
          const data = await client.graphql<{
            fulfillmentCreate: {
              fulfillment: FulfillmentNode | null;
              userErrors: ShopifyUserError[];
            };
          }>(FULFILLMENT_CREATE_MUTATION, { fulfillment });
          throwIfUserErrors(data.fulfillmentCreate.userErrors, "fulfillmentCreate");
          const f = data.fulfillmentCreate.fulfillment;
          if (!f) {
            return {
              content: [
                { type: "text" as const, text: "fulfillmentCreate returned no fulfillment." },
              ],
            };
          }
          const tracking = f.trackingInfo
            .map((t) => [t.company, t.number, t.url].filter(Boolean).join(" | "))
            .filter(Boolean)
            .join("; ");
          return {
            content: [
              {
                type: "text" as const,
                text: [
                  `Created fulfillment ${f.name} [${f.status}] — ${f.id}`,
                  f.order ? `  Order: ${f.order.name} (${f.order.id})` : "",
                  tracking ? `  Tracking: ${tracking}` : "",
                ]
                  .filter(Boolean)
                  .join("\n"),
              },
            ],
          };
        },
      );
    
      server.tool(
        "update_fulfillment_tracking",
        "Update or add tracking info on an existing fulfillment after the fact. Use this when you've already called create_fulfillment but didn't have the carrier/tracking number yet, or when a tracking number was wrong and needs fixing. company+number is enough; Shopify auto-derives the URL for known carriers (USPS, UPS, FedEx, DHL, etc.). Set notifyCustomer=true to re-send the shipping email with the updated tracking. Omitted fields are left unchanged.",
        updateTrackingSchema,
        async (args) => {
          const trackingInfoInput: Record<string, unknown> = {};
          if (args.company !== undefined) trackingInfoInput.company = args.company;
          if (args.number !== undefined) trackingInfoInput.number = args.number;
          if (args.url !== undefined) trackingInfoInput.url = args.url;
    
          const data = await client.graphql<{
            fulfillmentTrackingInfoUpdate: {
              fulfillment: FulfillmentNode | null;
              userErrors: ShopifyUserError[];
            };
          }>(FULFILLMENT_TRACKING_UPDATE_MUTATION, {
            fulfillmentId: args.fulfillmentId,
            trackingInfoInput,
            notifyCustomer: args.notifyCustomer,
          });
          throwIfUserErrors(
            data.fulfillmentTrackingInfoUpdate.userErrors,
            "fulfillmentTrackingInfoUpdate",
          );
          const f = data.fulfillmentTrackingInfoUpdate.fulfillment;
          if (!f) {
            return {
              content: [
                { type: "text" as const, text: "fulfillmentTrackingInfoUpdate returned no fulfillment." },
              ],
            };
          }
          const tracking = f.trackingInfo
            .map((t) => [t.company, t.number, t.url].filter(Boolean).join(" | "))
            .filter(Boolean)
            .join("; ");
          return {
            content: [
              {
                type: "text" as const,
                text: `Updated tracking on ${f.id} [${f.status}]${tracking ? `: ${tracking}` : ""}.`,
              },
            ],
          };
        },
      );
    
      server.tool(
        "cancel_fulfillment",
        "Cancel an existing fulfillment — use when an item that was marked shipped won't actually ship (lost in warehouse, address bounced, customer cancelled). Restores remaining quantity on the underlying fulfillment order so the items can be re-fulfilled later. Does NOT issue a refund — combine with order-level refund tools if money needs to come back to the customer. Returns the new fulfillment status (typically CANCELLED).",
        cancelFulfillmentSchema,
        async (args) => {
          const data = await client.graphql<{
            fulfillmentCancel: {
              fulfillment: FulfillmentNode | null;
              userErrors: ShopifyUserError[];
            };
          }>(FULFILLMENT_CANCEL_MUTATION, { id: args.id });
          throwIfUserErrors(data.fulfillmentCancel.userErrors, "fulfillmentCancel");
          const f = data.fulfillmentCancel.fulfillment;
          return {
            content: [
              {
                type: "text" as const,
                text: f
                  ? `Cancelled fulfillment ${f.id} — new status: ${f.status}`
                  : `Cancelled fulfillment ${args.id}.`,
              },
            ],
          };
        },
      );
    }
  • src/server.ts:21-65 (registration)
    Import and invocation of registerFulfillmentTools to register all fulfillment tools on the MCP server during initialization.
    import { registerFulfillmentTools } from "./tools/fulfillment.js";
    import { registerWebhookTools } from "./tools/webhooks.js";
    import { registerMetaobjectTools } from "./tools/metaobjects.js";
    import { registerAnalyticsTools } from "./tools/analytics.js";
    import { registerBridgeTools } from "./tools/bridge.js";
    
    export interface ServerConfig {
      host: string;
      port: number;
      shopifyStore: string;
      shopifyAccessToken: string;
      shopifyApiVersion?: string;
      comfyUIUrl?: string;
      comfyUIPublicUrl?: string;
      comfyUIDefaultCkpt: string;
    }
    
    interface Session {
      server: McpServer;
      transport: StreamableHTTPServerTransport;
    }
    
    function buildContext(config: ServerConfig) {
      const shopify = new ShopifyClient({
        store: config.shopifyStore,
        accessToken: config.shopifyAccessToken,
        apiVersion: config.shopifyApiVersion,
      });
      const comfyui = config.comfyUIUrl
        ? new ComfyUIClient({
            baseUrl: config.comfyUIUrl,
            publicUrl: config.comfyUIPublicUrl ?? config.comfyUIUrl,
          })
        : null;
      const buildServer = () => {
        const s = new McpServer({ name: "shopify-mcp", version: "0.1.0" });
        registerProductTools(s, shopify);
        registerOrderTools(s, shopify);
        registerInventoryTools(s, shopify);
        registerCustomerTools(s, shopify);
        registerMetafieldTools(s, shopify);
        registerDraftOrderTools(s, shopify);
        registerCollectionTools(s, shopify);
        registerVariantTools(s, shopify);
        registerFulfillmentTools(s, shopify);
  • throwIfUserErrors helper used by the handler to check and throw on Shopify API user errors.
    export function throwIfUserErrors(
      errors: ShopifyUserError[] | undefined,
      operation: string,
    ): void {
      if (!errors || errors.length === 0) return;
      const messages = errors
        .map((e) => (e.field ? `${e.field.join(".")}: ${e.message}` : e.message))
        .join("; ");
      throw new Error(`Shopify ${operation} userErrors: ${messages}`);
    }
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description fully discloses side effects: 'customer-facing email if notifyCustomer is true; webhook fires; remaining quantities decrement.' This goes beyond basic behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, front-loaded with the core action, each sentence adding value. No unnecessary words. Structure supports quick comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (nested objects, side effects), the description covers main points well. However, no output schema exists, and the description does not explain the return value (likely the fulfillment record). Minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Although schema coverage is 100%, the description adds critical context: omitting fulfillmentOrderLineItems fulfills everything, tracking URL auto-derives for major carriers, and line item IDs come from list_fulfillment_orders.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description explicitly states 'Mark items as shipped — creates a fulfillment record', clearly identifying the verb (create) and resource (fulfillment record). It distinguishes from siblings like cancel_fulfillment and update_fulfillment_tracking.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description explains when to use (marking items as shipped) and mentions optional tracking and notification. It also references list_fulfillment_orders for IDs. However, it does not explicitly state when not to use this tool or provide alternatives like cancel_fulfillment.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/miller-joe/shopify-mcp'

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