Shop Analytics MCP
Shop Analytics MCP
MCP-сервер на TypeScript для безопасной аналитики SQLite-базы интернет-магазина. Работает только по stdio и предоставляет шесть специализированных tools; произвольный SQL не принимается.
Требования
Node.js 24.10+;
npm;
sqlite3CLI только для повторного применения миграции.
Related MCP server: Shop SQLite MCP
Установка и запуск
npm ci
npm run build
SHOP_DB_PATH=./shop.db npm startSHOP_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 в выбранном шаблоне на путь к этому проекту. Все конфигурации запускают dist/src/index.js по stdio и передают путь к shop.db через SHOP_DB_PATH.
Tools
Tool | Назначение |
| Таблицы, колонки, ключи и связи. |
| Количество клиентов в стране или страна-лидер. |
| Рейтинг товаров по проданным единицам и выручке. |
| Рейтинг категорий по выручке. |
| Выручка за UTC-период |
| Клиент с наибольшими тратами или количеством заказов. |
Финансовые и товарные показатели, а также количество заказов, исключают cancelled. Суммы возвращаются в полях с суффиксом Eur. Рейтинги принимают limit от 1 до 100; периоды используют даты YYYY-MM-DD.
Пример работы
Ниже показано, как MCP-клиент вызывает get_database_schema для описания таблиц, а затем get_customer_metrics для подсчета клиентов из Германии.

Безопасность
SQLite открывается с
readOnly: trueиPRAGMA query_only = ON.SQLite authorizer запрещает запись, DDL,
ATTACH,DETACHи транзакции.Все значения привязываются как SQL-параметры.
Tools не принимают SQL, поэтому агент не может передать destructive statement.
Ошибки валидации не раскрывают SQL, абсолютные пути или stack traces.
Тесты
npm testТесты покрывают эталонные ответы восьми приемочных вопросов, SQL-инъекцию в параметре страны, запрет DELETE, неизменность SHA-256 временной копии БД и MCP-взаимодействие по stdio.
Приемочные вопросы
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.
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
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.
Related MCP Connectors
Read-only analytics for all your apps: users, AI traffic, revenue, with the SQL behind every number.
Text-to-SQL for Claude & ChatGPT: OAuth sign-in, read-only Postgres/MySQL/SQL Server, free demo_shop
Cookieless web analytics an agent creates and queries: goals, funnels, revenue, SQL. Open source.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables 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 gradedqualityDmaintenanceEnables safe, read-only analysis of an online store's SQLite database, providing schema introspection, restricted SELECT queries, and specialized analytics tools through MCP.-
- FlicenseAqualityDmaintenanceEnables 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-
- FlicenseAqualityDmaintenanceEnables 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-