Skip to main content
Glama
amir-bengherbi

Shopify MCP Server

tag-customer

Add tags to Shopify customers to organize and segment them for targeted marketing and customer management.

Instructions

Add tags to a customer

Input Schema

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

Implementation Reference

  • Core handler implementation for tagging a Shopify customer using 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;
    }
  • src/index.ts:243-273 (registration)
    MCP server.tool registration for 'tag-customer', including inline handler and Zod input schema.
    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);
        }
      }
    );
  • TypeScript interface definition (schema) for the tagCustomer method in ShopifyClientPort.
    tagCustomer(
      accessToken: string,
      myshopifyDomain: string,
      tags: string[],
      customerId: string
    ): Promise<boolean>;
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Add tags' implies a mutation operation, it lacks details on permissions required, whether tags are appended or replaced, error handling (e.g., invalid customerId), rate limits, or response format. This is a significant gap for a mutation tool with zero annotation coverage.

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. It's appropriately sized for a simple tool and front-loaded with the core action, making it easy to parse quickly.

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?

Given this is 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 side effects. For a 2-parameter tool with 100% schema coverage but critical gaps in mutation context, a low score is warranted.

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 both parameters (customerId and tags) clearly documented in the schema. The description adds no additional meaning beyond what the schema provides (e.g., no examples, format details, or constraints). Baseline 3 is appropriate when 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 clearly states the action ('Add tags') and target resource ('to a customer'), providing a specific verb+resource combination. However, it doesn't differentiate from potential sibling tools like 'get-customers' or other customer management tools that might exist in the broader ecosystem, though none are directly related to tagging in the provided sibling list.

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., customer must exist), exclusions (e.g., cannot remove tags), or related tools (e.g., if there's a 'remove-tags' or 'update-customer' tool). Usage is implied only by the action itself.

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/amir-bengherbi/shopify-mcp-server'

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