Skip to main content
Glama
smithery-ai

Shopify Update MCP Server

by smithery-ai

tag-customer

Add tags to Shopify customers to organize and segment them for targeted marketing and personalized experiences.

Instructions

Add tags to a customer

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customerIdYesCustomer ID to tag
tagsYesTags to add to the customer

Implementation Reference

  • src/index.ts:271-301 (registration)
    Registration of the 'tag-customer' MCP tool including schema and inline handler that delegates to ShopifyClient.tagCustomer
    server.tool(
      "tag-customer",
      "Add tags to a customer",
      {
        customerId: z.string().describe("Customer ID to tag"),
        tags: z.array(z.string()).describe("Tags to add to the customer"),
      },
      async ({ customerId, tags }) => {
        const client = new ShopifyClient();
        try {
          const success = await client.tagCustomer(
            SHOPIFY_ACCESS_TOKEN,
            MYSHOPIFY_DOMAIN,
            tags,
            customerId
          );
          return {
            content: [
              {
                type: "text",
                text: success
                  ? "Successfully tagged customer"
                  : "Failed to tag customer",
              },
            ],
          };
        } catch (error) {
          return handleError("Failed to tag customer", error);
        }
      }
    );
  • Core handler implementation for tagging a customer using Shopify GraphQL 'tagsAdd' mutation
    async tagCustomer(
      accessToken: string,
      shop: string,
      tags: string[],
      externalCustomerId: string
    ): Promise<boolean> {
      const myshopifyDomain = await this.getMyShopifyDomain(accessToken, shop);
    
      const graphqlQuery = gql`
        mutation tagsAdd($id: ID!, $tags: [String!]!) {
          tagsAdd(id: $id, tags: $tags) {
            userErrors {
              field
              message
            }
            node {
              id
            }
          }
        }
      `;
    
      const res = await this.shopifyGraphqlRequest<{
        data: {
          tagsAdd: {
            userErrors: Array<{
              field: string[];
              message: string;
            }>;
            node: {
              id: string;
            };
          };
        };
      }>({
        url: `https://${myshopifyDomain}/admin/api/${this.SHOPIFY_API_VERSION}/graphql.json`,
        accessToken,
        query: graphqlQuery,
        variables: {
          id: `gid://shopify/Customer/${externalCustomerId}`,
          tags,
        },
      });
    
      const userErrors = res.data.data.tagsAdd.userErrors;
      if (userErrors.length > 0) {
        const errorMessages = userErrors.map((error) => error.message).join(", ");
        throw new Error(errorMessages);
      }
    
      return true;
    }
  • Input schema using Zod for customerId (string) and tags (array of strings)
    {
      customerId: z.string().describe("Customer ID to tag"),
      tags: z.array(z.string()).describe("Tags to add to the customer"),
    },
  • Interface definition for the tagCustomer method in ShopifyClientPort
    tagCustomer(
      accessToken: string,
      myshopifyDomain: string,
      tags: string[],
      customerId: string
    ): Promise<boolean>;
  • Utility function handleError used in the tool handler for error responses
    function handleError(
      defaultMessage: string,
      error: unknown
    ): {
      content: { type: "text"; text: string }[];
      isError: boolean;
    } {
      let errorMessage = defaultMessage;
      if (error instanceof CustomError) {
        errorMessage = `${defaultMessage}: ${error.message}`;
      }
      return {
        content: [{ type: "text", text: errorMessage }],
        isError: true,
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Add tags to a customer' implies a mutation operation, but it doesn't specify whether this is idempotent, requires specific permissions, has side effects (e.g., triggering notifications), or how errors are handled. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding its 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?

The description is a single, efficient sentence with zero waste—'Add tags to a customer' directly conveys the core action. It's front-loaded and appropriately sized for a simple tool, with no unnecessary elaboration or redundancy.

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

Completeness2/5

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

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens on success (e.g., returns updated customer object) or failure, nor does it cover behavioral aspects like idempotency or permissions. Given the complexity of a write operation, more context is needed to fully understand the tool's use.

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 schema description coverage is 100%, with clear descriptions for both parameters ('Customer ID to tag' and 'Tags to add to the customer'). The description adds no additional parameter semantics beyond what the schema provides, such as tag format constraints or customer ID sourcing. Given the high schema coverage, a baseline score of 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description 'Add tags to a customer' clearly states the action (add) and resource (customer), making the purpose immediately understandable. It distinguishes from siblings like 'get-customers' or 'update-product-price' by focusing on tagging rather than retrieval or price updates. However, it doesn't specify whether this adds new tags or replaces existing ones, which slightly limits specificity.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing customer ID), exclusions (e.g., not for removing tags), or related tools (e.g., if there's a separate tool for tag removal). The agent must infer usage from the name and schema alone.

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/smithery-ai/shopify-mcp-server-main-1'

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