Skip to main content
Glama
smithery-ai

Shopify Update MCP Server

by smithery-ai

get-collections

Retrieve Shopify collections with options to filter by name and limit results for inventory management and store organization.

Instructions

Get all collections

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of collections to return
nameNoFilter collections by name

Implementation Reference

  • The handler function for the 'get-collections' tool. It creates a ShopifyClient instance, calls loadCollections with the provided limit and name filters, and returns the collections as JSON or an error response.
    async ({ limit, name }) => {
      const client = new ShopifyClient();
      try {
        const collections = await client.loadCollections(
          SHOPIFY_ACCESS_TOKEN,
          MYSHOPIFY_DOMAIN,
          { limit, name }
        );
        return {
          content: [{ type: "text", text: JSON.stringify(collections, null, 2) }],
        };
      } catch (error) {
        return handleError("Failed to retrieve collections", error);
      }
    }
  • Zod schema defining the input parameters for the 'get-collections' tool: optional limit (default 10) and optional name filter.
      limit: z
        .number()
        .optional()
        .default(10)
        .describe("Maximum number of collections to return"),
      name: z.string().optional().describe("Filter collections by name"),
    },
  • src/index.ts:512-538 (registration)
    The server.tool registration for the 'get-collections' tool, including name, description, input schema, and inline handler function.
    server.tool(
      "get-collections",
      "Get all collections",
      {
        limit: z
          .number()
          .optional()
          .default(10)
          .describe("Maximum number of collections to return"),
        name: z.string().optional().describe("Filter collections by name"),
      },
      async ({ limit, name }) => {
        const client = new ShopifyClient();
        try {
          const collections = await client.loadCollections(
            SHOPIFY_ACCESS_TOKEN,
            MYSHOPIFY_DOMAIN,
            { limit, name }
          );
          return {
            content: [{ type: "text", text: JSON.stringify(collections, null, 2) }],
          };
        } catch (error) {
          return handleError("Failed to retrieve collections", error);
        }
      }
    );
  • The loadCollections method in ShopifyClient, which implements the core logic for fetching both custom and smart collections from Shopify's REST API, supporting limit, name filters, and pagination via 'next'.
    async loadCollections(
      accessToken: string,
      shop: string,
      queryParams: ShopifyCollectionsQueryParams,
      next?: string
    ): Promise<LoadCollectionsResponse> {
      const nextList = next?.split(",");
      const customNext = nextList?.[0];
      const smartNext = nextList?.[1];
      let customCollections: ShopifyCollection[] = [];
      let customCollectionsNextPage;
      let smartCollections: ShopifyCollection[] = [];
      let smartCollectionsNextPage;
    
      if (customNext !== "undefined") {
        const customRes =
          await this.shopifyHTTPRequest<ShopifyCustomCollectionsResponse>({
            method: "GET",
            url: `https://${shop}/admin/api/${this.SHOPIFY_API_VERSION}/custom_collections.json`,
            accessToken,
            params: {
              limit: queryParams.limit,
              page_info: customNext,
              title: customNext ? undefined : queryParams.name,
              since_id: customNext ? undefined : queryParams.sinceId,
            },
          });
    
        customCollections = customRes.data?.custom_collections || [];
    
        customCollectionsNextPage = ShopifyClient.getShopifyOrdersNextPage(
          customRes.headers?.get("link")
        );
      }
      if (smartNext !== "undefined") {
        const smartRes =
          await this.shopifyHTTPRequest<ShopifySmartCollectionsResponse>({
            method: "GET",
            url: `https://${shop}/admin/api/${this.SHOPIFY_API_VERSION}/smart_collections.json`,
            accessToken,
            params: {
              limit: queryParams.limit,
              page_info: smartNext,
              title: smartNext ? undefined : queryParams.name,
              since_id: smartNext ? undefined : queryParams.sinceId,
            },
          });
    
        smartCollections = smartRes.data?.smart_collections || [];
    
        smartCollectionsNextPage = ShopifyClient.getShopifyOrdersNextPage(
          smartRes.headers?.get("link")
        );
      }
      const collections = [...customCollections, ...smartCollections];
    
      if (customCollectionsNextPage || smartCollectionsNextPage) {
        next = `${customCollectionsNextPage},${smartCollectionsNextPage}`;
      } else {
        next = undefined;
      }
      return { collections, next };
    }
  • Type definition for the output of loadCollections, used by the tool handler.
      collections: ShopifyCollection[];
      next?: string;
    };
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. 'Get all collections' implies a read operation, but it doesn't specify authentication needs, rate limits, pagination behavior, or what 'all' means in practice. The description lacks critical behavioral details for a tool with no 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 extremely concise with just three words, front-loaded with the core action. There's no wasted language or redundancy, making it efficient for quick scanning.

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 the lack of annotations and output schema, the description is incomplete. It doesn't explain what a 'collection' is in this context, what data is returned, or how results are structured. For a tool with no structured metadata, this minimal description leaves significant gaps.

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 input schema has 100% description coverage, with clear documentation for both 'limit' and 'name' parameters. The description adds no parameter information beyond what the schema provides, so it meets the baseline of 3 where the schema does the heavy lifting.

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

Purpose3/5

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

The description 'Get all collections' clearly states the verb ('Get') and resource ('collections'), but it's vague about scope and doesn't distinguish from sibling tools like 'get-products-by-collection'. It doesn't specify whether it returns all collections globally or within a specific context, making it minimally adequate but with clear gaps.

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 sibling tools like 'get-products-by-collection' for filtered access or explain prerequisites. Without any usage context, the agent must infer when this tool is appropriate.

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