Skip to main content
Glama

商店的只读 MCP 服务器

用于现有在线商店 SQLite 数据库(data/shop.db)的 Python MCP 服务器,通过 stdio 运行。该文件仅以只读方式打开;任何修改类 SQL 都会被拒绝且不会执行。

安装

Python 3.11+:

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Related MCP server: sqlite-mcp-local

运行

从项目根目录运行(默认数据库路径为 ./data/shop.db):

python -m shop_mcp
# или
shop-mcp

使用其他数据库路径:

SHOP_DB_PATH=~/my/test-mcp-db/data/shop.db python -m shop_mcp

进程通过 MCP 经由 stdin/stdout 通信。在 MCP 客户端连接到此终端之前,请不要在该终端中输入命令。

在 Cursor 中配置 MCP

添加 mcpServers 条目(Cursor Settings → MCP 或项目中的 .cursor/mcp.json)。传输方式为 stdio

示例中的路径 ~/my/test-mcp-db 就是此仓库。SHOP_DB_PATH 服务器会自行展开(~ → 主目录)。如果 Cursor 在 command / cwd 中没有展开 ~,请在那里填写 /Users/<你>/my/test-mcp-db/...

本地(venv)

{
  "mcpServers": {
    "shop": {
      "command": "~/my/test-mcp-db/.venv/bin/python",
      "args": ["-m", "shop_mcp"],
      "cwd": "~/my/test-mcp-db",
      "env": {
        "SHOP_DB_PATH": "~/my/test-mcp-db/data/shop.db"
      }
    }
  }
}

如果在 pip install -e . 之后更喜欢使用控制台脚本:

{
  "mcpServers": {
    "shop": {
      "command": "~/my/test-mcp-db/.venv/bin/shop-mcp",
      "cwd": "~/my/test-mcp-db",
      "env": {
        "SHOP_DB_PATH": "~/my/test-mcp-db/data/shop.db"
      }
    }
  }
}

Docker

构建一次镜像:

docker build -t shop-mcp .
{
  "mcpServers": {
    "shop": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "~/my/test-mcp-db/data/shop.db:/data/shop.db:ro",
        "-e",
        "SHOP_DB_PATH=/data/shop.db",
        "shop-mcp"
      ]
    }
  }
}

-i 标志是必需的,以便保持 stdio 连接。请只挂载 shop.db;容器不应覆盖主机上的文件。

工具

Tool

作用

list_tables

用户表及其角色的简要说明(不显示 sqlite_sequence

describe_table

实际列、类型、PK/FK

execute_readonly_sql

单个 SELECT / WITH / EXPLAINlimit(默认 100,最大 1000)和 offset

shop_analytics

无需手写 SQL 即可获得年度评分和收入

金额、件数和收入按 order_items.quantity * order_items.unit_price 计算;状态为 cancelled 的订单会被排除。日历年取自 strftime('%Y', orders.order_date)

安全性

  • SQLite URI file:<abs>?mode=ro

  • 注释会被去除;查询串(SELECT 1; DELETE ...)会被拒绝

  • INSERT / UPDATE / DELETE / DROP / ALTER / CREATE / ATTACH / PRAGMA / … → 明确错误「不允许」

  • SQLite 语法错误和未知列会以结构化方式返回;进程不会退出

评估注意事项

  • customers 没有 country 列。 这可以通过 describe_table 看到;不能虚构地理位置。SELECT country FROM customers 会返回 SQLite 错误。

  • 当前数据转储中的订单日期是 2026 年。 2025 年的收入可能为 0。这是正确结果,不是过滤条件失效。

测试

pytest

测试会将 data/shop.db 复制到临时文件,并验证在拒绝写入后副本的哈希没有变化。

已处理请求示例

screenshot.png

Install Server
F
license - not found
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    A read-only MCP server that enables LLMs to safely explore and query any SQLite database via natural language. It exposes tools for listing tables, describing schemas, and executing SELECT/WITH queries with built-in safety guards like write prevention and row limits.
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables read-only querying of a local SQLite database via MCP, with tools to list tables, retrieve schema, and execute SELECT/WITH/EXPLAIN queries.
  • F
    license
    Not graded
    quality
    C
    maintenance
    Provides read-only access to a sales database, letting LLMs answer analytics questions like revenue by region or top customers via MCP tools.
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables natural-language sales queries against a SQLite database, generating and executing read-only SQL through a secure MCP server with table listing, schema description, and query execution.

View all related MCP servers

Related MCP Connectors

  • Read-only MCP server for ClassQuill, a tutoring-business-management platform.

  • Read-only MCP access to sessions, funnels, campaigns, errors, live visitors, and anomalies.

  • Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DrZeD-13/test-mcp-db'

If you have feedback or need assistance with the MCP directory API, please join our Discord server