Shop Analytics MCP
Provides read-only analytics tools for a SQLite database of an online shop, including schema inspection, customer metrics, product sales, category revenue, revenue by period, and order leader queries.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Shop Analytics MCPWhat are the top 5 best-selling products?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Shop Analytics MCP
MCP server in TypeScript for secure analytics of an online store's SQLite database. Works only via stdio and provides six specialized tools; arbitrary SQL is not accepted.
Requirements
Node.js 24.10+;
npm;
sqlite3CLI only for re-applying the migration.
Related MCP server: Shop SQLite MCP
Installation and Running
npm ci
npm run build
SHOP_DB_PATH=./shop.db npm startSHOP_DB_PATH takes precedence. If the variable is not set, the server looks for shop.db in the current working directory. The path to the database is not hardcoded in the source code.
Data
The repository contains a ready-migrated shop.db. It contains customer countries and data for 2025. Monetary values are interpreted as EUR and are not converted.
To apply the migration to the original database once:
npm run migrateThe original schema is in database/schema.sql, and the deterministic migration is in database/001-add-analytics-data.sql.
Connecting to a Client
Ready-made configuration templates are in config/:
claude-code.mcp.json;codex.mcp.json;cursor.mcp.json.
Replace /absolute/path/to/mcp-server in the chosen template with the path to this project. All configurations run dist/src/index.js via stdio and pass the path to shop.db through SHOP_DB_PATH.
Tools
Tool | Purpose |
| Tables, columns, keys, and relationships. |
| Number of customers in a country or the leading country. |
| Product ranking by units sold and revenue. |
| Category ranking by revenue. |
| Revenue for the UTC period |
| Customer with the highest spending or number of orders. |
Financial and product metrics, as well as order counts, exclude cancelled. Amounts are returned in fields with the Eur suffix. Rankings accept a limit from 1 to 100; periods use YYYY-MM-DD dates.
Example Usage
Below shows how an MCP client calls get_database_schema to describe tables, and then get_customer_metrics to count customers from Germany.

Security
SQLite is opened with
readOnly: trueandPRAGMA query_only = ON.The SQLite authorizer forbids writes, DDL,
ATTACH,DETACH, and transactions.All values are bound as SQL parameters.
Tools do not accept SQL, so the agent cannot pass a destructive statement.
Validation errors do not reveal SQL, absolute paths, or stack traces.
Tests
npm testThe tests cover reference answers to eight acceptance questions, SQL injection in the country parameter, the prohibition of DELETE, the immutability of the SHA-256 of a temporary copy of the DB, and MCP interaction via stdio.
Acceptance Questions
Show me all available tables and explain what information each table contains.
How many customers are from Germany?
Which country has the most customers?
Who is the customer who spent the most money?
What are the top 5 best-selling products?
What are the top 3 product categories by revenue?
How much revenue did we generate in 2025?
Which customer placed the most orders?
Available Tools
6 toolsget_category_revenueA
Rank non-cancelled categories by EUR revenue. Optional YYYY-MM-DD from/to and integer limit 1-100.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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.
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.
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.
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.
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.
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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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.
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.
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.
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.
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.
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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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.
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.
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.
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.
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.
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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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.
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.
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.
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.
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.
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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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.
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.
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.
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.
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.
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).
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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.
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.
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.
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.
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.
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.
6 tool updates
v1.0.0- First observed
get_category_revenue - First observed
get_customer_metrics - First observed
get_database_schema - First observed
get_order_leaders - First observed
get_product_sales - First observed
get_revenue_by_period
TDQS
Scored across 6 tools
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.
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.
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.
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
Related MCP Connectors
- dataOAuthco.thinair
Read-only PostgreSQL, MySQL, SQL Server access via MCP — 24 dialect-aware hosted tools.
Read-only Recharge store analytics: metrics, dimensions, and governed queries in plain language.
Generate, fix, explain and run read-only SQL on PostgreSQL, MySQL and SQL Server
Read-only revenue, subscriptions, customers, and experiments tools for ZeroSettle accounts.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables 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.-
- FlicenseNot gradedqualityCmaintenanceEnables safe, read-only analysis of an online store's SQLite database, providing schema introspection, restricted SELECT queries, and specialized analytics tools through MCP.-
- AlicenseAqualityBmaintenanceEnables 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.647 npmMIT
- FlicenseAqualityCmaintenanceEnables 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-