Skip to main content
Glama

get_all_products

Retrieve all products from a BigCommerce store using API integration. Store hash can be provided or automatically sourced from environment variables for product management.

Instructions

Get all products from the BigCommerce API. Store hash is automatically retrieved from environment variables.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
store_HashNoOptional store hash. If not provided, uses BIGCOMMERCE_STORE_HASH from environment variables.

Implementation Reference

  • The `executeFunction` implements the core logic to fetch all products from the BigCommerce v3 catalog API endpoint using fetch, with error handling, empty response handling, and JSON parsing.
    const executeFunction = async ({ store_Hash } = {}) => {
      const baseUrl = 'https://api.bigcommerce.com/stores';
      const apiKey = process.env.BIGCOMMERCE_API_KEY;
    
      // Use provided store hash or default from environment
      const storeHash = store_Hash || process.env.BIGCOMMERCE_STORE_HASH;
      try {
        // Construct the URL for the request
        const url = `${baseUrl}/${storeHash}/v3/catalog/products`;
    
        // Set up headers for the request (matching n8n configuration)
        const headers = {
          'X-Auth-Token': apiKey,
          'Content-Type': 'application/json',
          'Accept': 'application/json'
        };
    
        // Perform the fetch request
        const response = await fetch(url, {
          method: 'GET',
          headers
        });
    
        // Check if the response was successful
        if (!response.ok) {
          let errorData;
          try {
            errorData = await response.json();
          } catch (e) {
            // If JSON parsing fails, use the text response
            const errorText = await response.text();
            throw new Error(`HTTP ${response.status}: ${errorText || response.statusText}`);
          }
          throw new Error(JSON.stringify(errorData));
        }
    
        // Get response text first to handle empty responses
        const responseText = await response.text();
    
        // Check if response is empty
        if (!responseText || responseText.trim() === '') {
          return { data: [], meta: { total: 0 } };
        }
    
        // Parse and return the response data
        try {
          const data = JSON.parse(responseText);
          return data;
        } catch (parseError) {
          throw new Error(`Invalid JSON response: ${responseText.substring(0, 200)}...`);
        }
      } catch (error) {
        console.error('Error getting all products:', error);
        return {
          error: `An error occurred while getting all products: ${error instanceof Error ? error.message : JSON.stringify(error)}`
        };
      }
    };
  • The tool schema definition, including name, description, and input parameters schema (store_Hash optional string).
      type: 'function',
      function: {
        name: 'get_all_products',
        description: 'Get all products from the BigCommerce API. Store hash is automatically retrieved from environment variables.',
        parameters: {
          type: 'object',
          properties: {
            store_Hash: {
              type: 'string',
              description: 'Optional store hash. If not provided, uses BIGCOMMERCE_STORE_HASH from environment variables.'
            }
          },
          required: []
        }
      }
    }
  • The `apiTool` object that binds the handler function to its schema definition and exports it for registration in the MCP server via discoverTools.
    const apiTool = {
      function: executeFunction,
      definition: {
        type: 'function',
        function: {
          name: 'get_all_products',
          description: 'Get all products from the BigCommerce API. Store hash is automatically retrieved from environment variables.',
          parameters: {
            type: 'object',
            properties: {
              store_Hash: {
                type: 'string',
                description: 'Optional store hash. If not provided, uses BIGCOMMERCE_STORE_HASH from environment variables.'
              }
            },
            required: []
          }
        }
      }
    };
    
    export { apiTool };
  • The `discoverTools` function dynamically imports all apiTool exports from tool paths (including get-all-products.js) and prepares them for MCP server registration, handling name deduplication.
    export async function discoverTools() {
      const tools = await Promise.all(
        toolPaths.map(async (file) => {
          const { apiTool } = await import(`../tools/${file}`);
          return { ...apiTool, path: file };
        })
      );
    
      // deduplicate tool names
      const nameCounts = {};
    
      return tools.map((tool) => {
        const name = tool.definition?.function?.name;
        if (!name) return tool;
    
        nameCounts[name] = (nameCounts[name] || 0) + 1;
    
        if (nameCounts[name] > 1) {
          tool.definition.function.name = `${name}_${nameCounts[name]}`;
        }
    
        return tool;
      });
    }
  • The `toolPaths` array registers the file path for the get_all_products tool, used by discoverTools to load it.
    export const toolPaths = [
      'bigcommerce/res-tful-api-basics-blueprint/get-all-products.js',
      'bigcommerce/res-tful-api-basics-blueprint/get-all-customers.js',
      'bigcommerce/res-tful-api-basics-blueprint/get-all-orders.js'
    ];
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions automatic retrieval of store hash from environment variables, which is useful context, but doesn't describe important behavioral aspects like pagination, rate limits, authentication requirements, error conditions, or what 'all products' means in practice (e.g., maximum results, filtering options).

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

Conciseness4/5

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

The description is appropriately concise with two sentences that both add value. The first sentence states the core purpose, and the second provides important implementation context about environment variable usage. No wasted words or redundant information.

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 tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (product format, data structure), doesn't mention pagination or result limitations for 'all products,' and provides minimal behavioral context. The agent would struggle to use this tool effectively without additional information.

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?

Schema description coverage is 100%, so the schema already fully documents the single optional parameter. The description adds the context that store hash is automatically retrieved from environment variables when not provided, which provides useful operational context beyond the schema's technical documentation.

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 verb ('Get') and resource ('all products from the BigCommerce API'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like get_all_customers and get_all_orders, but the resource specificity provides implicit differentiation.

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, prerequisites, or contextual factors that would help an agent decide between get_all_products, get_all_customers, or get_all_orders.

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/isaacgounton/bigcommerce-api-mcp'

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