Shop Analytics MCP
Shop Analytics MCP
Servidor MCP en TypeScript para el análisis seguro de la base de datos SQLite de una tienda en línea. Funciona solo a través de stdio y proporciona seis herramientas especializadas; no se acepta SQL arbitrario.
Requisitos
Node.js 24.10+;
npm;
sqlite3CLI solo para volver a aplicar la migración.
Related MCP server: Shop SQLite MCP
Instalación y ejecución
npm ci
npm run build
SHOP_DB_PATH=./shop.db npm startSHOP_DB_PATH tiene prioridad. Si la variable no está definida, el servidor busca shop.db en el directorio de trabajo actual. La ruta a la base de datos no está incrustada en el código fuente.
Datos
En el repositorio se encuentra una shop.db ya migrada. Contiene los países de los clientes y los datos del año 2025. Los valores monetarios se interpretan como EUR y no se convierten.
Para aplicar la migración a la base de datos original una vez:
npm run migrateEl esquema original se encuentra en database/schema.sql, y la migración determinista en database/001-add-analytics-data.sql.
Conexión con el cliente
Las plantillas de configuración listas se encuentran en config/:
claude-code.mcp.json;codex.mcp.json;cursor.mcp.json.
Reemplace /absolute/path/to/mcp-server en la plantilla elegida por la ruta a este proyecto. Todas las configuraciones ejecutan dist/src/index.js a través de stdio y pasan la ruta a shop.db mediante SHOP_DB_PATH.
Herramientas
Herramienta | Descripción |
| Tablas, columnas, claves y relaciones. |
| Número de clientes en un país o el país líder. |
| Ranking de productos por unidades vendidas e ingresos. |
| Ranking de categorías por ingresos. |
| Ingresos para el período UTC |
| Cliente con mayores gastos o mayor número de pedidos. |
Las métricas financieras y de productos, así como el número de pedidos, excluyen cancelled. Los importes se devuelven en campos con el sufijo Eur. Los rankings aceptan limit de 1 a 100; los períodos usan fechas YYYY-MM-DD.
Ejemplo de funcionamiento
A continuación se muestra cómo el cliente MCP llama a get_database_schema para describir las tablas y luego a get_customer_metrics para contar los clientes de Alemania.

Seguridad
SQLite se abre con
readOnly: trueyPRAGMA query_only = ON.El autorizador de SQLite prohíbe la escritura, DDL,
ATTACH,DETACHy transacciones.Todos los valores se vinculan como parámetros SQL.
Las herramientas no aceptan SQL, por lo que el agente no puede enviar una sentencia destructiva.
Los errores de validación no revelan SQL, rutas absolutas ni stack traces.
Pruebas
npm testLas pruebas cubren las respuestas de referencia de las ocho preguntas de aceptación, la inyección SQL en el parámetro de país, la prohibición de DELETE, la inmutabilidad SHA-256 de la copia temporal de la base de datos y la interacción MCP a través de stdio.
Preguntas de aceptación
Muéstrame todas las tablas disponibles y explica qué información contiene cada tabla.
¿Cuántos clientes son de Alemania?
¿Qué país tiene más clientes?
¿Quién es el cliente que gastó más dinero?
¿Cuáles son los 5 productos más vendidos?
¿Cuáles son las 3 principales categorías de productos por ingresos?
¿Cuántos ingresos generamos en 2025?
¿Qué cliente realizó más pedidos?
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
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Read-only Recharge store analytics: metrics, dimensions, and governed queries in plain language.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Read-only web analytics — AI traffic, revenue, goals, funnels — with the SQL behind every number.
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.6145 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-