Skip to main content
Glama

Read-only-MCP-Server für den Shop

Python-MCP-Server per stdio für die vorhandene SQLite-Datenbank des Onlineshops (data/shop.db). Die Datei wird nur schreibgeschützt geöffnet; ändernde SQL-Anweisungen werden abgelehnt und nicht ausgeführt.

Installation

Python 3.11+:

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

Related MCP server: Shop SQLite MCP

Start

Aus dem Projektstammverzeichnis (Standardpfad zur Datenbank — ./data/shop.db):

python -m shop_mcp
# или
shop-mcp

Anderer Pfad zur Datenbank:

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

Der Prozess kommuniziert über MCP via stdin/stdout. Geben Sie keine Befehle in dieses Terminal ein, solange kein MCP-Client angeschlossen ist.

MCP-Konfiguration in Cursor

Fügen Sie den Eintrag mcpServers hinzu (Cursor Settings → MCP oder .cursor/mcp.json im Projekt). Transport — stdio.

In den Beispielen ist der Pfad ~/my/test-mcp-db dieses Repository. SHOP_DB_PATH wird vom Server selbst aufgelöst (~ → Home-Verzeichnis). Wenn Cursor ~ in command / cwd nicht auflöst, geben Sie dort /Users/<вы>/my/test-mcp-db/... an.

Lokal (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"
      }
    }
  }
}

Falls nach pip install -e . ein Konsolenskript bequemer ist:

{
  "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

Das Image einmal erstellen:

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"
      ]
    }
  }
}

Das Flag -i ist erforderlich, damit stdio verbunden bleibt. Mounten Sie nur shop.db; der Container darf die Datei auf dem Host nicht überschreiben.

Werkzeuge

Tool

Zweck

list_tables

Benutzerdefinierte Tabellen und eine kurze Rollenbeschreibung (sqlite_sequence wird nicht angezeigt)

describe_table

Tatsächliche Spalten, Typen, PK/FK

execute_readonly_sql

Ein SELECT / WITH / EXPLAIN; limit (Standard 100, Maximum 1000) und offset

shop_analytics

Bewertungen und Jahresumsatz pro Jahr ohne manuelles SQL

Summen, Stückzahlen und Umsatz werden als order_items.quantity * order_items.unit_price berechnet; Bestellungen mit dem Status cancelled werden ausgeschlossen. Das Kalenderjahr wird aus strftime('%Y', orders.order_date) übernommen.

Sicherheit

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

  • Kommentare werden entfernt; Befehlsketten (SELECT 1; DELETE ...) werden abgelehnt

  • INSERT / UPDATE / DELETE / DROP / ALTER / CREATE / ATTACH / PRAGMA / … → expliziter Fehler „nicht erlaubt“

  • SQLite-Syntaxfehler und unbekannte Spalten werden strukturiert zurückgegeben; der Prozess wird nicht beendet

Hinweise zur Bewertung

  • customers hat keine Spalte country. Dies ist über describe_table sichtbar; Geografie darf nicht erfunden werden. SELECT country FROM customers ergibt einen SQLite-Fehler.

  • Die Bestelltermine im aktuellen Dump stammen aus dem Jahr 2026. Der Umsatz für 2025 kann 0 sein. Das ist eine korrekte Antwort und kein defekter Filter.

Tests

pytest

Die Tests kopieren data/shop.db in eine temporäre Datei und prüfen, dass sich der Hash der Kopie nach abgelehnten Schreibvorgängen nicht ändert.

Beispiel ausgeführter Abfrage

screenshot.png

Available Tools

4 tools
describe_tableA

Describe columns, types, primary keys, and foreign keys for one table.

Use before writing joins. Returns actual SQLite metadata only — never fabricates fields such as country. Parameters: table (name from list_tables). Returns {table, columns: [{name, type, primary_key, ...}], foreign_keys}.

Inputs: table (required). Returns: object

execute_readonly_sqlA

Run a single read-only SQL statement against shop.db.

Allowed: one SELECT, WITH (CTE), or EXPLAIN. Writes and DDL (INSERT, UPDATE, DELETE, REPLACE, DROP, ALTER, CREATE, TRUNCATE, ATTACH, VACUUM, REINDEX, PRAGMA) are rejected with an explicit not-allowed error. Stacked statements (semicolons) are rejected. Prefer shop_analytics for rankings and yearly revenue.

Pagination: default limit 100, maximum 1000 (error if exceeded), offset default 0. Returns {columns, rows, truncated, row_count, next_offset} or {error, sqlite_error?}. The database is opened read-only; refused mutations leave the file unchanged.

Inputs: sql (required), limit, offset. Returns: object

list_tablesA

List user tables in shop.db with a one-line purpose for each.

Use this first to discover the real schema. Internal SQLite tables such as sqlite_sequence are omitted. Does not invent columns (customers has no country). Returns {tables: [{name, purpose}, ...]}.

Inputs: no named parameters. Returns: object

shop_analyticsA

Shop aggregations without hand-written SQL.

Operations: top_customers_by_spend (name, email, total_amount; default limit 5), customer_most_orders (name, email, order_count), top_products (product_name, units_sold, revenue; default limit 5), top_categories (category, revenue; default limit 3), revenue_by_year (requires year). Spend/units/revenue use quantity * unit_price and exclude cancelled orders. Year is taken from order_date.

Inputs: operation (required), year, limit. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 4 tools

    Disambiguation4/5

    The schema-discovery tools are clearly separated from the querying/analytics tools. There is some overlap between execute_readonly_sql and shop_analytics, but the descriptions explicitly steer agents toward shop_analytics for rankings and revenue, reducing confusion.

    Naming Consistency4/5

    Three tools follow a clear verb-first snake_case pattern: list_tables, describe_table, execute_readonly_sql. shop_analytics breaks that pattern as a nouny resource name, though it is still understandable and not chaotic.

    Tool Count5/5

    Four tools is a well-scoped set for a read-only shop database. Each tool fills a distinct role: schema discovery, table metadata, raw SQL execution, and prebuilt analytics, with no redundancy.

    Completeness5/5

    For a read-only database exploration server, the workflow is complete: list the tables, describe one, run arbitrary safe SQL, and get common analytics. There are no missing mutations or write operations because the server is explicitly read-only.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      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.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables safe, read-only analysis of an online store's SQLite database, providing schema introspection, restricted SELECT queries, and specialized analytics tools through MCP.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      This MCP server lets an AI agent securely connect to a read-only SQLite store database, inspect its tables and schema, and run analytical SQL queries without modifying any data.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to read-only analyze a SQLite e-commerce database, exploring schema and running analytical SQL queries over stdio.
      -