shop-database-mcp
Enables read-only exploration and analysis of an included SQLite shop database through tools for listing tables, describing schemas, and running SQL queries.
README
Shop Database MCP Server
A local, read-only Model Context Protocol server for exploring and analyzing the included educational SQLite shop fixture. It exposes exactly three tools: list_tables, describe_table, and query_database.
The committed shop.db contains synthetic educational country values. They are deterministic fixture data, not inferred personal attributes.
1. Install
Prerequisites: Node.js 20 or newer, npm, and a platform supported by better-sqlite3 (or a local C/C++ build toolchain if npm cannot obtain a prebuilt native binary).
npm install
2. Configure
No configuration is required when using the included shop.db. To select a different compatible database, set an absolute or relative path:
export SHOP_DB_PATH=/path/to/shop.db
The server resolves the default database relative to its own module, not the caller's working directory. It will never create a missing database. See .env.example; environment files are not loaded automatically.
3. Prepare or verify the fixture
npm run prepare-db
This explicit setup command atomically adds or validates the deterministic synthetic customers.country fixture and its index. It preserves existing customer fields and IDs and is idempotent. It is never invoked by start, dev, or server runtime. The repository already contains the prepared database, so this normally acts as verification.
4. Build
npm run typecheck
npm run build
5. Run
npm run start
The process speaks MCP over stdin/stdout and waits for a client. It does not print a startup banner; stdout is reserved exclusively for MCP messages. Development mode is available as npm run dev.
6. Connect
A generic stdio MCP configuration is provided in configuration.example.json:
{
"mcpServers": {
"shop_database": {
"command": "node",
"args": ["/absolute/path/to/project/dist/server.js"],
"env": { "SHOP_DB_PATH": "/absolute/path/to/project/shop.db" }
}
}
}
For Codex CLI, either add the server at the command line:
codex mcp add shop_database --env SHOP_DB_PATH=/absolute/path/to/project/shop.db -- node /absolute/path/to/project/dist/server.js
codex mcp list
Or copy the template from config/codex-config.example.toml into your Codex configuration and replace the placeholders:
[mcp_servers.shop_database]
command = "node"
args = ["/absolute/path/to/project/dist/server.js"]
tool_timeout_sec = 15
required = true
enabled_tools = ["list_tables", "describe_table", "query_database"]
[mcp_servers.shop_database.env]
SHOP_DB_PATH = "/absolute/path/to/project/shop.db"
Run codex mcp list, start Codex, and use /mcp to verify that shop_database and all three tools are available.
7. Test
npm test
The suite covers input boundaries, SQL tokenization and refusal, serialization, schema discovery, all acceptance analytics, pagination, named bindings, stdio protocol behavior, and database immutability across the destructive-query matrix.
Example prompts
- Show me all available tables and explain what information each table contains.
- How many customers are from Germany?
- Which country has the most customers?
- Who is the customer who spent the most money?
- What are the top 5 best-selling products?
- What are the top 3 product categories by revenue?
- How much revenue did we generate in 2025?
- Which customer placed the most orders?
Query rules and read-only guarantee
The database is opened with readonly: true and fileMustExist: true, then placed in SQLite query-only mode. The SQL policy independently permits only one SELECT or non-recursive WITH ... SELECT; mutation, DDL, PRAGMA, attachment, maintenance, extension loading, recursive CTEs, and extra statements are refused. Prepared statements must also identify as readers. User values are passed only through named bindings.
Each result page contains at most 500 rows. Use a deterministic ORDER BY and continue with next_offset while has_more is true. The synchronous SQLite driver cannot interrupt a CPU-heavy query in-process; v1 relies on query restrictions, bounded output, and the recommended 15-second MCP client timeout rather than a hard server-side execution deadline.
Revenue, spending, units sold, and product/category sales exclude cancelled orders. Placed-order counts include every status. Whole-order revenue and customer spending use orders.total_amount; historical product/category revenue uses order_items.quantity * order_items.unit_price. Dates are timezone-naive, and calendar-year filters use half-open intervals. The database declares no currency, so amounts are monetary units.
Troubleshooting
DATABASE_UNAVAILABLE: verifySHOP_DB_PATH, file existence, and read permission. The server does not create databases.DATABASE_SCHEMA_MISMATCH: use the committed fixture or runnpm run prepare-db; a custom database must have every required table, column, foreign key, and fixture prerequisite.- Native dependency installation fails: use a supported Node.js release and install your platform's compiler/build tools, then rerun
npm install. - MCP framing or JSON errors: do not add
console.logor other stdout logging to runtime code. Send diagnostics to stderr only. - A query returns
SQL_ERROR: inspect tables first, use unique aliases for duplicate result-column names, and verify placeholder names and SQL syntax.
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.