Skip to main content
Glama
k0ry

Shop MCP Server

by k0ry

Shop MCP Server

用于在线商店 SQLite 数据库分析的本地 MCP 服务器。AI 代理调用 MCP 工具,服务器将请求转换为安全的 SQL SELECT,直接读取 shop.db 并返回结构化结果。

Host-приложение
├── AI-агент / LLM
└── MCP-клиент
        │ JSON-RPC / stdio
        ▼
    Shop MCP Server
        │ read-only SQLite
        ▼
    data/shop.db

功能

  • 直接连接 SQLite,无需 HTTP 和独立的数据库服务器;

  • MCP 传输 stdio;

  • 通过 tools/list 发现 query_shop 和 inspect_database;

  • 工具描述和 JSON Schema 中有八个示例任务;

  • 普通文本、JSON intent 或现成的安全 SELECT;

  • 从所有分析中排除 cancelled 订单;

  • 分页和结果限制;

  • 多层只读保护。

Related MCP server: Read-Only SQLite Shop Database MCP Server

安装

需要 Python 3.11 或更高版本。

python3 -m venv .venv
.venv/bin/python -m pip install -e '.[dev]'

准备好的数据库已位于 data/shop.db 中。其中有 150 个客户,customers.country 字段已为所有客户填写,其中 45 个客户属于 Germany。

重新准备数据库

原始数据库不会被修改。该命令创建新的工作副本,并添加带有可重现合成值的 country TEXT NOT NULL:

.venv/bin/shop-prepare-db /path/to/original/shop.db ./data/shop.db

分布仅取决于 customers.id,因此重复准备会产生相同的值。国家/地区是测试数据,不描述客户的实际位置。

路径配置

路径按以下顺序确定:

  1. SHOP_DB_PATH;

  2. 来自 SHOP_MCP_CONFIG 或 config/shop_mcp.json 的 JSON 文件;

  3. 相对于工作目录的 data/shop.db。

环境变量示例位于 .env.example 中,MCP 客户端配置位于 config/mcp.example.json 中。将 /absolute/path/to/MCPDeveloper 替换为项目的绝对路径。

启动

通常,MCP 客户端会从其配置中启动服务器。要手动启动进程:

SHOP_DB_PATH=./data/shop.db .venv/bin/python -m shop_mcp.server

stdout 保留用于 MCP JSON-RPC。诊断信息不会输出到协议流中。

工具

inspect_database

参数:

{"action": "list_tables"}

或:

{"action": "describe_table", "table": "customers"}

query_shop

参数:

{
  "request": "Сколько клиентов из Германии?",
  "limit": 100,
  "offset": 0
}

通过 tools/list 声明的示例:

  1. 数据库中有哪些表,它们有哪些字段?

  2. 有多少来自德国的客户?

  3. 哪个国家的客户最多?

  4. 哪个客户消费最多?返回姓名、电子邮件和总金额。

  5. 按销售数量和收入显示前 5 种商品。

  6. 按收入显示前 3 个类别。

  7. 2025 年的收入是多少?

  8. 哪个客户下的订单最多?

可以传递结构化 intent:

{
  "request": "{\"intent\": \"revenue_by_year\", \"year\": 2025}"
}

或现成的查询:

{
  "request": "SELECT name, category FROM products ORDER BY name"
}

业务规则

  • orders.status = 'cancelled' 不参与指标计算。

  • 客户支出和年收入按 orders.total_amount 计算。

  • 商品和类别的收入按 quantity * unit_price 计算。

  • 年份区间为半开区间:从 1 月 1 日(含)到次年 1 月 1 日(不含)。

  • 在提供的数据库中,所有订单都属于 2026 年,因此 2025 年的收入为 0。

安全性

服务器通过 mode=ro 打开 SQLite,启用 query_only,设置 SQLite authorizer,禁止多个语句、DML、DDL、ATTACH、修改性 PRAGMA、扩展加载,并限制执行时间。

任何尝试执行非 SELECT 操作都会返回精确的答案:

Не доступный вариант запроса

SQLite 内部错误、堆栈跟踪和本地路径不会返回给客户端。

验证

.venv/bin/pytest
.venv/bin/ruff check .
.venv/bin/ruff format --check .

测试包括以子进程方式实际启动 MCP 服务器、通过 stdio 连接 ClientSession、tools/list、调用两个工具、分析场景以及尝试修改数据库。

完整且已批准的规范位于 docs/specification.md 中。

Available Tools

2 tools
inspect_databaseПросмотр структуры базы интернет-магазинаB

Возвращает список таблиц или поля выбранной таблицы. Используйте action=list_tables либо action=describe_table.

NameRequiredDescriptionDefault
tableNoНазвание таблицы для describe_table
actionYesДействие: list_tables или describe_table

Output Schema

NameRequiredDescription
resultYes

TDQS

B3.3/5.0
Behavior2/5

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

With no annotations, the description carries full responsibility for behavioral disclosure. It only states that it returns tables or fields, which is basic. It does not disclose any side effects, permission requirements, error behaviors, or what happens when the table does not exist. For a read-only inspection tool this is relatively benign, but the coverage is minimal.

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 a single sentence that fully conveys the essential information. It is front-loaded with the primary function and immediately outlines the two actions. No redundancy or filler.

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?

Given that an output schema exists, the return format is likely covered elsewhere. The description is sufficient for a simple schema-inspection tool, but it lacks any mention of error handling or the distinction from query_shop. It is adequate but not comprehensive.

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 already provides 100% coverage: 'action' is described as 'list_tables or describe_table' and 'table' as 'table name for describe_table'. The description repeats this mapping without adding new information, so it meets the baseline but does not exceed it.

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 states the tool's purpose: it returns a list of tables or fields of a selected table. This is a specific verb-resource combination and distinguishes it from the sibling query_shop, which presumably queries data rather than schema. The two modes (list_tables, describe_table) are explicitly mentioned.

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?

The description provides instructions on how to use the tool (choose action) but does not explain when to use this tool versus the sibling query_shop. It offers no context about typical scenarios, prerequisites, or exclusions. The usage guidance is limited to internal action selection, not selection among alternatives.

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

query_shopЗапрос к базе интернет-магазинаA

Выполняет аналитический запрос к базе интернет-магазина только для чтения. MCP преобразует запрос в безопасный SQL SELECT. Отменённые заказы не учитываются. Примеры: 1) Какие таблицы есть в базе и какие в них поля? 2) Сколько клиентов из Германии? 3) В какой стране больше всего клиентов? 4) Какой клиент потратил больше всего? Верни имя, email и общую сумму. 5) Покажи топ-5 товаров по проданному количеству и выручке. 6) Покажи топ-3 категории по выручке. 7) Какая выручка была в 2025 году? 8) Какой клиент сделал больше всего заказов?

NameRequiredDescriptionDefault
limitNoМаксимальное число строк
offsetNoСмещение для пагинации
requestYesАналитический запрос обычным текстом, JSON intent или SQL SELECT.

Output Schema

NameRequiredDescription
resultYes

TDQS

A3.9/5.0
Behavior4/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 explicitly states the tool is read-only, that MCP converts queries into safe SQL SELECT, and that canceled orders are excluded from results. This is useful and goes beyond minimal. It does not mention error handling or response format, but the core behavior is well disclosed.

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 fairly long because it contains eight examples, but those examples are practical and illustrate valid request formats that are directly relevant to the tool. The purpose statement is front-loaded, and each example adds value, so the length is justified. It is well-structured and not overly verbose.

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 natural-language query tool that has an output schema (indicated by the schema signals), the description covers essential context: what the tool does, how it handles queries, and what data is excluded (canceled orders). It could add more about limitations or error behavior, but given the output schema exists and the description is already thorough, it is largely complete.

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?

Schema description coverage is 100% — every parameter has a clear description. The description itself adds little beyond the schema: it repeats the request examples but does not elaborate on limit or offset semantics, which the schema already covers adequately. The baseline of 3 is appropriate because the schema handles the heavy lifting.

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 states the verb and resource: 'performs a read-only analytical query to the online store database' and explains the MCP converts queries to safe SQL SELECT. It is specific about being read-only and analytical, which differentiates it from a generic database tool and gives a clear sense of its function, though it does not explicitly name the sibling tool.

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 is implied through a set of concrete examples that show typical analytical questions (e.g., 'which country has most customers?'). However, the description does not explicitly state when to use this tool versus the sibling 'inspect_database', nor does it provide any exclusions or when-not-to-use guidance. It relies on the reader to infer that this is for read-only analytical queries.

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. 2 tool updatesv0.1.0
    • First observedinspect_database
    • First observedquery_shop

TDQS

A3.8/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have clearly distinct purposes: one handles database schema inspection (list tables/describe fields), the other executes analytical queries. There is no overlap in their functional boundaries, making selection unambiguous for an agent.

Naming Consistency5/5

Both tools follow a consistent verb_noun snake_case pattern ('inspect_database', 'query_shop'), using clear, descriptive verbs. Naming style is uniform and predictable.

Tool Count3/5

With only 2 tools, the server feels minimal for a shop analytics domain. While the query tool is versatile, a more granular set (e.g., get_customers, get_orders) might be expected. The count is borderline, not excessive but thin.

Completeness5/5

The tool surface fully covers the stated purpose: schema discovery via inspect_database and arbitrary read-only analytical queries via query_shop. There are no obvious gaps for a read-only analytics server, as the query tool can address any data retrieval need.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • 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
    -
  • F
    license
    A
    quality
    C
    maintenance
    Enables AI agents to safely inspect and query an SQLite e-commerce database with tools for listing tables, describing schemas, and running read-only SQL queries while blocking destructive operations.
    4
    -
  • F
    license
    A
    quality
    C
    maintenance
    Enables AI agents to read-only query an online store's SQLite database, listing tables, inspecting schemas, and running SELECT queries over customers, products, orders, and order items.
    3
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents to read-only analyze a SQLite e-commerce database, exploring schema and running analytical SQL queries over stdio.
    -