Skip to main content
Glama
Myrhoiazov

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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.6/5.0
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It discloses the non-cancelled filter, revenue-based ranking, and the limit constraint of 1-100, which adds useful behavior. However, it does not describe the output format, the ranking direction explicitly, or default behavior when date ranges are omitted.

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

Conciseness5/5

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

Two sentences with the purpose front-loaded ahead of parameter notes. Zero wasted words, and every phrase earns its place - scope, filter, metric, and input constraints are all covered efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for invocation - purpose, filter, and parameter constraints are all present. But with no output schema and no annotations, the return format and the meaning of 'ranked' (list of categories with revenue values, directional order, handling of omitted dates) are left to inference, which is a real gap for a short tool description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema is effectively empty (0 properties, additionalProperties: true), so the description is the only documentation of parameters. It names from/to date parameters with YYYY-MM-DD format and the limit with a 1-100 integer range, fully compensating for the bare schema. It could clarify that limit caps the number of returned categories, but it noticeably exceeds the schema's contribution.

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?

States a specific verb and resource ('Rank non-cancelled categories by EUR revenue'), which makes it distinguishable from siblings like get_revenue_by_period (time-based) and get_product_sales (product-based). The purpose is unambiguous, though it doesn't explicitly name those siblings to differentiate itself.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage context is implied rather than explicit: an agent can infer this is for revenue ranking by category, but there is no guidance on when to prefer it over get_revenue_by_period or get_product_sales, nor any exclusion criteria. The scope ('non-cancelled', 'EUR') gives some context but no alternative routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.3/5.0
Behavior2/5

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

Annotations are absent, so the description carries the full burden. The description only states the two modes and parameter combinations. It doesn't disclose anything about the return format, whether the tool is read-only, performance implications, or any side effects. For a query tool that presumably reads data, this is a minimal disclosure. Given zero annotations, a score of 2 is warranted because the description doesn't clarify error behavior or output structure beyond the mode.

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 concise and front-loaded: 'Count customers in a country or find the top country.' That is followed by parameter instructions. Two sentences, no fluff. It loses a point because it could be more structured, e.g., listing parameters explicitly, but it is efficient.

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?

Given that the schema provides no property definitions and there is no output schema, the description must explain both input and output. It explains modes but does not describe the return format or any caveats (e.g., does top_country return just the country name or also a count? Does count_by_country return a single number?). For an agent to call this correctly, it needs to know what output to expect, which is missing. The tool complexity is low, but with such sparse schema, the description is incomplete.

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?

The input schema is empty (no properties defined) and has additionalProperties true, but the description mentions parameters 'mode' and 'country'. Schema coverage is 100% because the schema is essentially empty, so the description provides the only meaning for parameters. It says 'mode=count_by_country with country' and 'mode=top_country without country', which clarifies the parameters. However, it doesn't specify the data types, allowed values for mode beyond two examples, or required status. Since the description does add essential meaning that the schema lacks, but it is not exhaustive, a 3 is appropriate.

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 explicitly states two modes: 'count customers in a country' and 'find the top country'. This is specific enough to distinguish from siblings like get_product_sales or get_revenue_by_period. However, it doesn't name any sibling tool, so it gets a 4 rather than a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear context for when to use each mode: 'mode=count_by_country with country' or 'mode=top_country without country'. It implies that if you want counts by country you use count mode, and if you want the top country you use top_country mode. No explicit exclusions or alternatives are named, but the conditions for each mode are clear. This is good but not fully explicit about when not to use this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_database_schemaA

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description must carry the burden, and 'Inspect' implies a read-only operation. It does not go further to state side effects, authorization needs, or that object types like indexes/constraints may be included, but the simple no-parameter introspection scope makes this acceptable.

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

Conciseness5/5

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

The description is two short sentences with no filler. The core behavior is front-loaded and every word contributes to understanding the tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter introspection tool, the description captures the essential return scope: tables, columns, keys, and relationships. It does not describe output formatting or exact return structure, but no invocation decisions are required.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, and the description explicitly states 'Parameters: none,' matching the empty input schema. With no parameters to define, the description provides all necessary semantic context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly specifies the resource (database schema) and the action (Inspect), and enumerates the concrete objects involved: tables, columns, keys, and relationships. This separates it from the sibling metric-focused tools without needing to open their definitions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not mention when to use this tool versus alternatives, nor does it explicitly say it is for structural introspection rather than data queries. However, the sibling list and the term 'schema' make the intended use contextually clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description carries the burden of disclosing behavior. It explains mode semantics (date acceptance per mode) but doesn't disclose return format, edge cases (e.g., ties, no customers found), or any filtering/scoping behavior beyond the two modes. This is adequate but lacks rich behavioral context.

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?

One compact sentence that front-loads the core purpose and immediately adds functional details. It would earn a 5 with slightly clearer separation of mode semantics, but the density of information per word is high.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with zero parameters in the schema, the description covers the main functional dimensions (what modes exist, date handling). However, it lacks details on output shape, potential error conditions, or ordering behavior, which an agent might need. Given the tool's simplicity, it's reasonably complete but not fully comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema is empty (no properties defined), so the description fully compensates by documenting 'mode' parameter with its two values and date parameters in terms of format and applicability. Since schema coverage is listed as 100% but the schema literally has no properties, the description is the only source of parameter meaning and does it well.

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 tool finds a customer with highest spend or most non-cancelled orders, which is a specific purpose distinguishing it from revenue/product-focused siblings. However, it doesn't explicitly name sibling tools for contrast, so it loses a point for not differentiating from alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through mode-based guidance (highest_spend vs most_orders) and date handling, but doesn't explicitly state when to prefer this over sibling tools like get_customer_metrics. The mode distinction provides some usage context, but no exclusion criteria or alternative routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_product_salesA

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4/5.0
Behavior3/5

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

Annotations are absent, so the description carries full burden. It discloses operational behavior (excludes cancelled, returns ranking, supports date range and limit), which is above minimal. However, it does not mention edge cases, default responses, or how it handles malformed dates/limits, so it's adequate but not exhaustive.

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

Conciseness5/5

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

A single, front-loaded sentence with no filler. The core ranking purpose is first, followed by precise optional parameters with formats and ranges. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 0 params and no output schema, the description covers the essential behavior: what ranks, what filters apply, and parameter constraints. It lacks explicit mention of output structure, but since no output schema exists, the description's focus on the ranking result is reasonable. Minor gap: doesn't specify how limit behaves if omitted, but that's a small omission.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema is empty (0 params, 100% coverage), meaning the description is the only source of parameter meaning. It clearly specifies optional YYYY-MM-DD from/to and integer limit 1-100, which is valuable and sufficient for an agent to understand what can be passed even without a schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states a specific verb ('Rank'), resource ('products'), and scope ('non-cancelled'), and includes key dimensions (units sold, EUR revenue, date range, limit). Distinguishes from sibling tools by focusing on product-level ranking, not schema, customer metrics, or broader categories.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description provides context for when to use (ranking products by sales) and implies an alternative exists (e.g., get_category_revenue for category-level), but does not explicitly state when not to use or recommend a sibling. It gives enough for basic selection but lacks explicit exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_revenue_by_periodA

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations provided, the description carries the full burden. It does disclose the half-open interval semantics [from, to) and the revenue filters (non-cancelled, EUR), which are useful behavioral details. However, it omits output format, aggregation method, and default period behavior.

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

Conciseness5/5

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

The description is two tight sentences with the purpose stated first and no extraneous words. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple calculation tool with no output schema, the description covers the core purpose and parameters, but lacks behavioral and return-value context (e.g., whether it returns a scalar, a series, or a breakdown), leaving some ambiguity for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has zero properties and only allows additionalProperties, so the description is the sole source of parameter documentation. It explicitly names 'from' and 'to', specifies the YYYY-MM-DD format, and precisely defines the interval as half-open [from, to).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the verb 'Calculate' and the specific resource 'non-cancelled EUR revenue', with the time period implied by the optional from/to parameters. This differentiates it well from sibling tools like get_category_revenue or get_product_sales.

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?

No guidance is given on when to choose this tool over siblings such as get_category_revenue or get_product_sales. The optional date range is descriptive, but there is no explicit routing or exclusion criterion.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 6 tool updatesv1.0.0
    • First observedget_category_revenue
    • First observedget_customer_metrics
    • First observedget_database_schema
    • First observedget_order_leaders
    • First observedget_product_sales
    • First observedget_revenue_by_period

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.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    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
    C
    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.
    -
  • A
    license
    A
    quality
    B
    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
    145 npm
    MIT
  • F
    license
    A
    quality
    C
    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
    -