Skip to main content
Glama

update-order

Modify Shopify order details including customer information, shipping address, tags, notes, and custom attributes through the Shopify MCP Server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
tagsNo
emailNo
noteNo
customAttributesNo
metafieldsNo
shippingAddressNo

Implementation Reference

  • The execute method contains the main handler logic for updating an order. It performs a GraphQL mutation (orderUpdate) with the provided input, handles errors, and returns the updated order data including id, name, email, note, tags, customAttributes, metafields, and shippingAddress.
    execute: async (input: UpdateOrderInput) => {
      try {
        // Prepare input for GraphQL mutation
        const { id, ...orderFields } = input;
    
        const query = gql`
          mutation orderUpdate($input: OrderInput!) {
            orderUpdate(input: $input) {
              order {
                id
                name
                email
                note
                tags
                customAttributes {
                  key
                  value
                }
                metafields(first: 10) {
                  edges {
                    node {
                      id
                      namespace
                      key
                      value
                    }
                  }
                }
                shippingAddress {
                  address1
                  address2
                  city
                  company
                  country
                  firstName
                  lastName
                  phone
                  province
                  zip
                }
              }
              userErrors {
                field
                message
              }
            }
          }
        `;
    
        const variables = {
          input: {
            id,
            ...orderFields
          }
        };
    
        const data = (await shopifyClient.request(query, variables)) as {
          orderUpdate: {
            order: any;
            userErrors: Array<{
              field: string;
              message: string;
            }>;
          };
        };
    
        // If there are user errors, throw an error
        if (data.orderUpdate.userErrors.length > 0) {
          throw new Error(
            `Failed to update order: ${data.orderUpdate.userErrors
              .map((e) => `${e.field}: ${e.message}`)
              .join(", ")}`
          );
        }
    
        // Format and return the updated order
        const order = data.orderUpdate.order;
    
        // Return the updated order data
        return {
          order: {
            id: order.id,
            name: order.name,
            email: order.email,
            note: order.note,
            tags: order.tags,
            customAttributes: order.customAttributes,
            metafields:
              order.metafields?.edges.map((edge: any) => edge.node) || [],
            shippingAddress: order.shippingAddress
          }
        };
      } catch (error) {
        console.error("Error updating order:", error);
        throw new Error(
          `Failed to update order: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
    }
  • The UpdateOrderInputSchema defines the input validation schema using zod. It specifies required field 'id' (string), and optional fields: tags (string array), email (email string), note (string), customAttributes (array of key-value objects), metafields (array with id, namespace, key, value, type), and shippingAddress (object with address fields).
    const UpdateOrderInputSchema = z.object({
      id: z.string().min(1),
      tags: z.array(z.string()).optional(),
      email: z.string().email().optional(),
      note: z.string().optional(),
      customAttributes: z
        .array(
          z.object({
            key: z.string(),
            value: z.string()
          })
        )
        .optional(),
      metafields: z
        .array(
          z.object({
            id: z.string().optional(),
            namespace: z.string().optional(),
            key: z.string().optional(),
            value: z.string(),
            type: z.string().optional()
          })
        )
        .optional(),
      shippingAddress: z
        .object({
          address1: z.string().optional(),
          address2: z.string().optional(),
          city: z.string().optional(),
          company: z.string().optional(),
          country: z.string().optional(),
          firstName: z.string().optional(),
          lastName: z.string().optional(),
          phone: z.string().optional(),
          province: z.string().optional(),
          zip: z.string().optional()
        })
        .optional()
    });
  • src/index.ts:152-199 (registration)
    Registers the 'update-order' tool with the MCP server. Defines the input schema (duplicate of UpdateOrderInputSchema) and provides an async handler that calls updateOrder.execute(args) and returns the result as JSON string content.
    server.tool(
      "update-order",
      {
        id: z.string().min(1),
        tags: z.array(z.string()).optional(),
        email: z.string().email().optional(),
        note: z.string().optional(),
        customAttributes: z
          .array(
            z.object({
              key: z.string(),
              value: z.string()
            })
          )
          .optional(),
        metafields: z
          .array(
            z.object({
              id: z.string().optional(),
              namespace: z.string().optional(),
              key: z.string().optional(),
              value: z.string(),
              type: z.string().optional()
            })
          )
          .optional(),
        shippingAddress: z
          .object({
            address1: z.string().optional(),
            address2: z.string().optional(),
            city: z.string().optional(),
            company: z.string().optional(),
            country: z.string().optional(),
            firstName: z.string().optional(),
            lastName: z.string().optional(),
            phone: z.string().optional(),
            province: z.string().optional(),
            zip: z.string().optional()
          })
          .optional()
      },
      async (args) => {
        const result = await updateOrder.execute(args);
        return {
          content: [{ type: "text", text: JSON.stringify(result) }]
        };
      }
    );
  • The initialize method sets up the GraphQL client (shopifyClient) that will be used to make requests to the Shopify API.
    initialize(client: GraphQLClient) {
      shopifyClient = client;
    },
  • Initializes the updateOrder tool with the Shopify GraphQL client, enabling it to make API requests.
    updateOrder.initialize(shopifyClient);
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/anass319/shopify-MCP'

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