Skip to main content
Glama
Shop Database MCP Server

Shop Database MCP Server

by melixetian

Shop Database MCP Server

This local stdio MCP server lets an AI agent inspect and analyze shop.db. It is read-only: SQLite is opened read-only, query_only is enabled, and the server rejects anything except one SELECT or WITH ... SELECT query.

Prerequisites

Node.js 20 or newer and the supplied SQLite database.

Related MCP server: shop-database-mcp

Install

npm install

Configure

SHOP_DB_PATH is optional. If set, a relative value is resolved from the process working directory; an absolute value is used directly. Otherwise the server finds shop.db relative to its compiled module, including when launched outside the project directory. See .env.example; it is not loaded automatically.

Build

npm run build

Run manually

npm start

A stdio server normally appears idle because it waits for MCP messages.

Connect to Codex IDE extension and CLI

In the IDE extension: Gear menu → MCP servers → Add server → STDIO. Set command, arguments, and environment from config/codex.config.toml.example, save, and restart the extension.

For a project-scoped setup, copy that example to .codex/config.toml and replace every /ABSOLUTE/PATH/TO/PROJECT placeholder. Codex CLI and the IDE extension share Codex MCP configuration. Do not commit the active configuration file.

Available tools

inspect_database takes no parameters. Use it before querying or when uncertain; it returns tables, columns, primary/foreign keys, relationships, and row counts.

query_database accepts sql (required), params (positional string, finite number, boolean, or null values), limit (1–200; default 100), and offset (default 0). Use ? placeholders; joins and aggregates work. It accepts exactly one read-only SELECT or WITH ... SELECT. Inspect schema before assuming columns, date formats, prices, or statuses. Results contain columns, rows, rowCount, limit, offset, and hasMore; request another page with a new offset.

{"sql":"SELECT country, COUNT(*) AS customer_count FROM customers GROUP BY country ORDER BY customer_count DESC","params":[],"limit":100,"offset":0}

Test

npm test

Tests create temporary fixture databases and never modify shop.db.

Safety design and troubleshooting

Safety layers are read-only file access, SQLite query_only, conservative token-aware validation that ignores comments/strings/quoted identifiers, a single-statement rule, and server-side pagination. Tool errors are concise and do not expose stack traces or local paths.

If startup fails, verify SHOP_DB_PATH names an existing regular SQLite file. If a query fails, call inspect_database, use ? parameters, and verify names and relationships.

Available Tools

2 tools
inspect_databaseA
Read-only

Use before your first query or whenever the schema is uncertain. Returns tables, columns, keys, relationships, and row counts.

Inputs: no named parameters. Returns: tables

query_databaseA
Read-only

Execute one parameterized read-only SELECT or WITH ... SELECT statement. Use ? placeholders and params for dynamic values. Joins and aggregate queries are supported; schema and data changes are forbidden. Results are paginated: use offset for the next page when hasMore is true. Inspect the schema instead of guessing column names, date formats, price fields, or order status semantics.

Inputs: sql (required), limit, offset, params. Returns: rows, limit, offset, columns, +2 more

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 2 tools

    Disambiguation5/5

    inspect_database handles schema metadata while query_database executes read-only SQL queries. There is no functional overlap or ambiguity between the two tools.

    Naming Consistency5/5

    Both tools follow the same lower_snake_case verb_noun pattern: inspect_database and query_database. The naming is consistent, predictable, and clearly reflects each tool's purpose.

    Tool Count4/5

    Two tools is lean but well-suited to the server's read-only database purpose: inspect the schema, then query the data. Each tool is essential, and the narrow scope justifies the small count.

    Completeness5/5

    For a read-only database server, inspect_database plus query_database covers the complete workflow of schema discovery and arbitrary SELECT queries with pagination. Write operations are explicitly out of scope, so their absence is not a gap.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables 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
      236 npm
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables read-only exploration and analysis of an included SQLite shop database through tools for listing tables, describing schemas, and running SQL queries.
      -
    • 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
      A
      quality
      C
      maintenance
      Gives AI agents read-only analytical access to an e-commerce SQLite database (customers, orders, order_items, products) via SQL queries, table listing, and schema inspection.
      3
      -