Skip to main content
Glama

cancel_fulfillment

Cancel a fulfillment for items that won't ship, restoring inventory for re-fulfillment. Does not issue a refund.

Instructions

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).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesFulfillment GID to cancel.

Implementation Reference

  • The handler function for the cancel_fulfillment tool. Calls the Shopify FulfillmentCancel mutation with the given fulfillment GID and returns the cancellation result.
    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}.`,
            },
          ],
        };
      },
  • The Zod schema for cancel_fulfillment input, requiring a single 'id' field (the fulfillment GID to cancel).
    const cancelFulfillmentSchema = {
      id: z.string().describe("Fulfillment GID to cancel."),
    };
  • Registration of cancel_fulfillment via server.tool() within registerFulfillmentTools, providing the tool name, description, schema, and handler.
    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}.`,
            },
          ],
        };
      },
    );
  • The GraphQL mutation string (FULFILLMENT_CANCEL_MUTATION) used by the cancel_fulfillment handler to call Shopify's fulfillmentCancel endpoint.
    const FULFILLMENT_CANCEL_MUTATION = /* GraphQL */ `
      mutation FulfillmentCancel($id: ID!) {
        fulfillmentCancel(id: $id) {
          fulfillment {
            id
            status
          }
          userErrors { field message }
        }
      }
    `;
Behavior5/5

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

With no annotations, the description fully discloses behavioral traits: it restores remaining quantity on the underlying fulfillment order, does not issue a refund, and returns the new status. No contradictions.

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?

Two sentences, zero waste. Front-loaded with the core action, followed by usage guidance, side effects, limitations, and return value. Every sentence adds value.

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

Completeness5/5

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

Given the tool's simplicity (one required parameter, no output schema), the description fully covers purpose, when to use, behavioral effects, and return value. No missing context.

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

Parameters3/5

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

The description adds no extra semantic meaning beyond the input schema, which already fully describes the single parameter 'id' as 'Fulfillment GID to cancel.' Schema coverage is 100%, so baseline 3 is appropriate.

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?

The description starts with a clear verb and resource ('Cancel an existing fulfillment') and immediately distinguishes its use case from siblings like cancel_order by specifying when to use (lost in warehouse, address bounced, customer cancelled).

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

Usage Guidelines5/5

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

Explicitly states when to use (item won't ship) and when not (does not issue refund), and provides direction to combine with order-level refund tools. Also describes the effect on the fulfillment order.

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