Commerce Layer Metrics MCP Server

Commerce Layer Metrics MCP Server

Enables AI agents to query commerce metrics data such as orders, carts, and returns via breakdowns, stats, and searches through the Commerce Layer Metrics API.

Category
Visit Server

README

Commerce Layer Metrics MCP Server

This repository provides a local MCP Server implementation with a suite of metrics tools for Commerce Layer data analysis.


Table of Contents


Overview

The Metrics Local MCP Server exposes a set of tools to interact with Commerce Layer Metrics API and enables you to extract almost any kind of data information from your organization order, return, or cart history.


Installation

From GIT repository

  1. Clone the repository:

    git clone https://github.com/your-org/mcp-server-metrics.git
    cd mcp-server-metrics
    
  2. Install dependencies:

    pnpm install
    
  3. Build the project:

    pnpm build
    
  4. Create the server:

    pnpm dist
    

    The compiled files will be available in the dist/ directory and can be used to setup the MCP local server in the preferred AI agent (Claude Dekstop, OpenAI Chat-GPT ...).

As Claude Desktop extension

Claude Dekstop makes now easy the installation of custom MCP local servers both as a prebuilt bundles or an unpacked extensions. Here you can find the instructions from the Anthropic's support to perform the installation.

Follow the steps as for installing from a GIT repository and then:

  1. Create the extension bundle:

    npm run mcpb
    
  2. Install the extension: Upload the packed extension taking the bundle from mcpb/commercelayer-metrics.mcpb

When requested insert client_id and client_secret to connect to your Commerce Layer's organization.


Tools

Queries

These tools let you retrieve metric data and statistics about orders, carts and returns through four types of queries:

  1. Breakdown
  • orders-breakdown
  • carts-breakdown
  • returns-breakdown

Breakdowns are aggregations that summarize your data as metrics (based on specific operators) or statistics, computed on field values. When performing a breakdown query on the Metrics API endpoint you get in the response the value of the computation (based on the selected operator) on the selected field, aggregated by another field.

  1. Date breakdown
  • orders-date-breakdown
  • carts-date-breakdown
  • returns-date-breakdown

Date breakdowns are aggregations that show the frequency of occurrence of a specific date value within a dataset and let you apply a specific operator over a selected field of the records that are present on that date. When performing a date breakdown query on the Metrics API endpoint you get in the response the list by date of the values of the computation (based on the selected operator) on the selected field, over the selected time interval, aggregated by another field.

  1. Stats
  • orders-stats
  • carts-stats
  • returns-stats*

Stats are numeric computations (based on specific operators) calculated over values extracted from a specific field of the selected resource. When performing a stats query on the Metrics API endpoint you get in the response the value of the computation (based on the selected operator) on the selected field.

  1. Search
  • orders-search
  • carts-search
  • returns-search

Searches are a type of query a bit different from the other ones (breakdowns, date breakdowns, and stats). A search is not an aggregation and doesn't involve any computation based on operators, but an actual search. When performing a search query on the Metrics API endpoint you get in the response the list of the requested fields (sorted, filtered, and paginated) of the actual records that match the query.

Use cases

Commerce Layer Metrics API lets you extract and aggregate relevant metric data from your organizations. Combining the 4 available types of queries (breakdown, date breakdown, stats, and search) on the 3 available resources (orders, returns, and carts) and adding the appropriate filters lets you cover a wide range of use cases that can fit your business needs.

This is a list of tools that cover the most common application scenarios of Commerce Layer Metrics API:

  • best-selling-products-by-market get the Top N best-selling products for each of your organization's market
  • customers-that-bought-a-specific-product get the total number of customers that bought a specific product or bundle
  • frequently-bought-together-products get the products that have been most frequently bought together with other ones
  • last-carts-with-a-specific-product-from-a-specific-market get the most recently created carts containing a specific SKU, from a specific market
  • latest-archived-orders get the most recently archived orders
  • latest-placed-orders-from-customers-with-specific-email-domains get the last placed orders containing specific email domains in the aggregated details
  • number-of-products-per-order-by-country get mixed stats about the number of SKUs included in the orders of your organization, grouped by different countries
  • orders-associated-with-a-specific-promotion get the total number of orders that triggered a specific promotion
  • orders-by-bundle get the total number of orders containing a bundle, grouped by the bundle name
  • orders-by-currency get the total number of orders of your organization, grouped by different currencies
  • orders-by-day get the total number of orders of your organization, grouped by day
  • orders-by-repeat-customer get the total number of orders of your organization, grouped by customers that bought from you more than once
  • orders-by-resource-error-code-and-message check the errors associated with the orders of your organization (if any)
  • orders-by-shipment-status-and-shipping-method-name get the total number of orders of your organization, grouped by the associated shipment status and the related shipping method name
  • orders-by-status-and-payment-status get the total number of orders of your organization, grouped by their status and the related payment status
  • orders-paid-with-gift-cards get the total number of orders that were paid using a gift card
  • refunds-by-country-and-currency get the total number of refunds of your organization, grouped by the different countries and currencies
  • returns-per-year-by-destination-city get the total number of returns requested for your orders, grouped by year and destination city
  • shipments-average-time-in-picking get the average time your shipments stay in picking status before being packed
  • top-10-spenders-by-currency get the top spenders among your customers and know how their total purchase amount is divided by currency

Analysis

All the available Commerce Layer Metrics API helper endpoints.

  • FBT Also known as Frequently Bought Together, FBTs are a type of analysis query that, based on your entire order history, allows you to retrieve the items that most frequently have been added as line items in the same orders as a specified item (SKU or bundle) or array of items.

References

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured