Skip to main content
Glama

search-shopify

Search across Shopify store content including products, articles, blogs, and pages using specific queries to find relevant information quickly.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query to find content across the store
typesNoTypes of resources to search for. If not specified, searches all types.
firstNoNumber of results to return (max 50)

Implementation Reference

  • The execute method implements the core logic of the 'search-shopify' tool, querying Shopify GraphQL for articles, blogs, pages, and products based on the input query and types, then formatting and returning the results.
    async execute(input: SearchShopifyInput) {
      try {
        // We'll query each type separately since Shopify doesn't have a unified search endpoint
        const queries = {
          ARTICLE: gql`
            query SearchArticles($query: String!, $first: Int!) {
              articles(first: $first, query: $query) {
                nodes {
                  id
                  title
                  handle
                  summary
                  blog {
                    title
                  }
                }
              }
            }
          `,
          BLOG: gql`
            query SearchBlogs($query: String!, $first: Int!) {
              blogs(first: $first, query: $query) {
                nodes {
                  id
                  title
                  handle
                }
              }
            }
          `,
          PAGE: gql`
            query SearchPages($query: String!, $first: Int!) {
              pages(first: $first, query: $query) {
                nodes {
                  id
                  title
                  handle
                  bodySummary
                }
              }
            }
          `,
          PRODUCT: gql`
            query SearchProducts($query: String!, $first: Int!) {
              products(first: $first, query: $query) {
                nodes {
                  id
                  title
                  handle
                  description
                }
              }
            }
          `
        };
    
        const types = input.types || ["ARTICLE", "BLOG", "PAGE", "PRODUCT"];
        const results: Record<string, any> = {};
    
        // Execute queries for each requested type
        await Promise.all(
          types.map(async (type) => {
            try {
              const data = await shopifyClient.request(queries[type], {
                query: input.query,
                first: input.first
              }) as SearchResponse;
              
              const key = type.toLowerCase() + "s";
              results[type.toLowerCase()] = data[key].nodes.map((node: SearchNode) => ({
                id: node.id,
                title: node.title,
                handle: node.handle,
                summary: node.summary || node.bodySummary || node.description || null,
                ...(node.blog ? { blogTitle: node.blog.title } : {})
              }));
            } catch (error) {
              console.error(`Error searching ${type}:`, error);
              results[type.toLowerCase()] = [];
            }
          })
        );
    
        return {
          results
        };
      } catch (error) {
        console.error("Error searching Shopify:", error);
        throw new Error(
          `Failed to search Shopify: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Zod schema defining the input validation for the search-shopify tool: query (required string), types (optional array of resource types), first (optional number, default 10, max 50).
    const SearchShopifyInputSchema = z.object({
      query: z.string().min(1).describe("The search query to find content across the store"),
      types: z.array(z.enum(["ARTICLE", "BLOG", "PAGE", "PRODUCT"])).optional().describe("Types of resources to search for. If not specified, searches all types."),
      first: z.number().min(1).max(50).optional().default(10).describe("Number of results to return (max 50)")
    });
  • src/index.ts:286-295 (registration)
    MCP server registration of the 'search-shopify' tool, using the schema from the imported tool object and delegating execution to searchShopify.execute.
    server.tool(
      "search-shopify",
      searchShopify.schema.shape,
      async (args: z.infer<typeof searchShopify.schema>) => {
        const result = await searchShopify.execute(args);
        return {
          content: [{ type: "text", text: JSON.stringify(result) }]
        };
      }
    );
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/luckyfarnon/Shopify-MCP'

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