Shop Analytics MCP

Shop Analytics MCP

Enables secure analytics on an SQLite database of an online store via six specialized tools covering schema, customer metrics, product sales, category revenue, period revenue, and order leaders.

Category
Visit Server

README

Shop Analytics MCP

MCP-сервер на TypeScript для безопасной аналитики SQLite-базы интернет-магазина. Работает только по stdio и предоставляет шесть специализированных tools; произвольный SQL не принимается.

Требования

  • Node.js 24.10+;
  • npm;
  • sqlite3 CLI только для повторного применения миграции.

Установка и запуск

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 в выбранном шаблоне на путь к этому проекту. Все конфигурации запускают dist/src/index.js по stdio и передают путь к shop.db через SHOP_DB_PATH.

Tools

Tool Назначение
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 authorizer запрещает запись, DDL, ATTACH, DETACH и транзакции.
  • Все значения привязываются как SQL-параметры.
  • Tools не принимают SQL, поэтому агент не может передать destructive statement.
  • Ошибки валидации не раскрывают SQL, абсолютные пути или stack traces.

Тесты

npm test

Тесты покрывают эталонные ответы восьми приемочных вопросов, SQL-инъекцию в параметре страны, запрет DELETE, неизменность SHA-256 временной копии БД и MCP-взаимодействие по stdio.

Приемочные вопросы

  1. Show me all available tables and explain what information each table contains.
  2. How many customers are from Germany?
  3. Which country has the most customers?
  4. Who is the customer who spent the most money?
  5. What are the top 5 best-selling products?
  6. What are the top 3 product categories by revenue?
  7. How much revenue did we generate in 2025?
  8. Which customer placed the most orders?

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured