Skip to main content
Glama
Shop Analytics MCP

Shop Analytics MCP

by Myrhoiazov

Shop Analytics MCP

TypeScript製のMCPサーバーで、オンラインストアのSQLiteデータベースを安全に分析します。stdioのみで動作し、6つの専門ツールを提供します。任意のSQLは受け付けません。

要件

  • Node.js 24.10以上

  • npm

  • sqlite3 CLI(マイグレーションを再適用する場合のみ)

Related MCP server: Shop SQLite MCP

インストールと起動

npm ci
npm run build
SHOP_DB_PATH=./shop.db npm start

SHOP_DB_PATHが優先されます。この変数が設定されていない場合、サーバーは現在の作業ディレクトリでshop.dbを探します。データベースへのパスはソースコードに埋め込まれていません。

データ

リポジトリには、マイグレーション済みのshop.dbが含まれています。これには顧客の国と2025年のデータが含まれています。金額はEURとして解釈され、換算されません。

元のデータベースにマイグレーションを一度だけ適用するには:

npm run migrate

元のスキーマはdatabase/schema.sqlにあり、決定的なマイグレーションはdatabase/001-add-analytics-data.sqlにあります。

クライアントへの接続

config/に既製の設定テンプレートがあります:

  • claude-code.mcp.json

  • codex.mcp.json

  • cursor.mcp.json

選択したテンプレートの/absolute/path/to/mcp-serverを、このプロジェクトへのパスに置き換えてください。すべての設定は、stdioでdist/src/index.jsを起動し、SHOP_DB_PATHを介してshop.dbへのパスを渡します。

ツール

ツール

目的

get_database_schema

テーブル、列、キー、リレーション。

get_customer_metrics

特定の国の顧客数、または最多顧客国。

get_product_sales

販売数量と売上による商品ランキング。

get_category_revenue

売上によるカテゴリランキング。

get_revenue_by_period

UTC期間[from, to)の売上。

get_order_leaders

最も支出が多い、または注文数が多い顧客。

財務・商品指標、および注文数にはcancelledは含まれません。金額はEurサフィックス付きのフィールドで返されます。ランキングはlimitを1〜100で受け付けます。期間はYYYY-MM-DD形式の日付を使用します。

動作例

以下は、MCPクライアントがget_database_schemaを呼び出してテーブルを説明し、次にget_customer_metricsを呼び出してドイツの顧客数をカウントする例です。

MCPツール呼び出しの例

セキュリティ

  • SQLiteはreadOnly: trueとPRAGMA query_only = ONで開かれます。

  • SQLiteオーソライザーは、書き込み、DDL、ATTACH、DETACH、トランザクションを禁止します。

  • すべての値はSQLパラメータとしてバインドされます。

  • ツールはSQLを受け付けないため、エージェントは破壊的なステートメントを渡すことができません。

  • バリデーションエラーは、SQL、絶対パス、スタックトレースを公開しません。

テスト

npm test

テストは、8つの受け入れ質問の基準応答、国のパラメータへのSQLインジェクション、DELETEの禁止、一時データベースコピーのSHA-256不変性、stdioを介したMCPインタラクションをカバーしています。

受け入れ質問

  1. 利用可能なすべてのテーブルを表示し、各テーブルに含まれる情報を説明してください。

  2. ドイツからの顧客は何人ですか?

  3. 最も多くの顧客がいる国はどこですか?

  4. 最も多くお金を使った顧客は誰ですか?

  5. ベストセラー商品トップ5は何ですか?

  6. 売上上位3つの商品カテゴリは何ですか?

  7. 2025年に生み出した売上はいくらですか?

  8. 最も多くの注文をした顧客は誰ですか?

Available Tools

6 tools
get_category_revenueA

Rank non-cancelled categories by EUR revenue. Optional YYYY-MM-DD from/to and integer limit 1-100.

Inputs: no named parameters.

get_customer_metricsB

Count customers in a country or find the top country. Parameters: mode=count_by_country with country, or mode=top_country without country.

Inputs: no named parameters.

get_database_schemaA

Inspect tables, columns, keys, and relationships. Parameters: none.

Inputs: no named parameters.

get_order_leadersA

Find a customer with highest spend or most non-cancelled orders. mode=highest_spend accepts optional YYYY-MM-DD from/to; mode=most_orders accepts no dates.

Inputs: no named parameters.

get_product_salesA

Rank non-cancelled products by units sold and EUR revenue. Optional YYYY-MM-DD from/to and integer limit 1-100.

Inputs: no named parameters.

get_revenue_by_periodA

Calculate non-cancelled EUR revenue. Optional YYYY-MM-DD from/to define [from, to).

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct entity or aggregation level: database schema, customer counts, product sales rankings, category revenue, total revenue, and customer leaders. Even though get_customer_metrics and get_order_leaders both involve customers, their purposes (country-level counts vs. individual customer extremes) are clearly separated. No two tools are likely to cause misselection.

    Naming Consistency5/5

    All tool names follow the consistent pattern 'get_' followed by a descriptive noun phrase, using snake_case throughout. Examples: get_database_schema, get_product_sales, get_revenue_by_period. This uniform phrasing makes the set predictable and easy to navigate.

    Tool Count5/5

    With 6 tools, the server is well-scoped for a shop analytics use case. It covers the essential query types without unnecessary proliferation, and each tool earns its place by addressing a distinct analytical question. The count is within the ideal range for a focused server.

    Completeness4/5

    The tool set covers key analytics workflows: schema inspection, customer metrics, product and category performance, total revenue, and top customer identification. Minor gaps include lack of time-series revenue breakdown (e.g., by day/month) and no list of customers beyond the leader, but the core analytical needs are met. These omissions are workable around.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants like Claude to query, analyze, and summarize local SQLite e-commerce databases using natural language through 11 tools, schema resources, and pre-built analytical prompts.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables safe, read-only analysis of an online store's SQLite database, providing schema introspection, restricted SELECT queries, and specialized analytics tools through MCP.
      -
    • F
      license
      A
      quality
      D
      maintenance
      Enables AI agents to safely interact with a SQLite shop database through schema discovery, read-only SQL queries, and pre-built analytics reports like top customers, top products, and revenue summaries.
      6
      -
    • F
      license
      A
      quality
      D
      maintenance
      Enables AI agents to answer analytical questions about an online store's SQLite database through specialized read-only tools, without any risk of modifying the underlying data.
      8
      -