GitHub - commercelayer/mcp-server-metrics: Commerce Layer local MCP server for Metrics API (original) (raw)

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:
  3. Build the project:
  4. Create the server:
    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:
  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

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

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

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

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:

Analysis

All the available Commerce Layer Metrics API helper endpoints.


References