db-mcp
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.
README
db-mcp
A read-only MCP server that gives an AI
agent safe access to a small SQLite shop database (shop.db): schema
discovery, free-form read-only SQL, and pre-built analytics reports.
Install
npm install
Configure
The server reads SHOP_DB_PATH from the process environment to locate the
database file. It is optional — if unset, the server uses shop.db in the
project root. .env files are not read automatically (there is no
dotenv dependency and no --env-file flag in package.json's scripts);
.env.example is provided only as a reminder of the variable name. Set
SHOP_DB_PATH in the actual environment the server runs in — for a stdio
MCP client, that means the env key of its config (see "Connect a client"
below).
Build
npm run build
Run
npm start
# or directly:
node dist/index.js
The server speaks MCP over stdio — it expects to be launched as a child process by an MCP client/host, not run interactively.
Connect a client
Generic stdio MCP client config:
{
"mcpServers": {
"db-mcp": {
"command": "node",
"args": ["/absolute/path/to/db-mcp/dist/index.js"],
"env": { "SHOP_DB_PATH": "/absolute/path/to/shop.db" }
}
}
}
Claude Desktop: add the same block under mcpServers in
claude_desktop_config.json (see MCP.md for the per-OS config file
location), then restart Claude Desktop.
Tools
| Tool | Description |
|---|---|
list_tables |
List all tables with a short description and row count. Call this first. |
describe_table |
Column definitions, keys, row count, and sample rows for one table (customers, products, orders, order_items). |
query |
Run a single read-only SELECT (or WITH ... SELECT) with limit/offset pagination. |
get_top_customers |
Top customers by total spending or order count. Excludes cancelled orders. |
get_top_products |
Best-selling products by units sold, with revenue. Excludes cancelled orders. |
get_revenue_report |
Revenue grouped by category, year, or month, optionally filtered to one year. Excludes cancelled orders. |
Security notes
- The database connection is opened with
{ readonly: true, fileMustExist: true }— the SQLite engine itself physically refuses any write, regardless of what SQL is sent. - The
querytool additionally validates that the input is a singleSELECT(orWITH ... SELECT) statement before it ever reaches the database, rejectingINSERT/UPDATE/DELETE/DROP/ALTER/CREATE/PRAGMA/ATTACH/DETACH/REPLACE/VACUUM/REINDEX/TRIGGERand multi-statement input, with a friendly error message. - Errors are caught at each tool's boundary and returned as an MCP tool
result with
isError: trueand a short message — no stack traces or filesystem paths are ever sent to the client. - All logs go to
stderr(console.error) —stdoutis reserved exclusively for the JSON-RPC protocol stream.
Tests
npm test
Runs node --test (via tsx) across every *.test.ts file: unit tests for
the SQL guard, the DB connection, and each tool's query logic against the
real shop.db, plus an end-to-end test that spawns the compiled server and
drives it with a real MCP client over stdio.
Docker
docker build -t db-mcp .
docker run -i db-mcp
Not required to run the server locally (the client config above expects a
local node process), but provided as an alternative way to verify/run it.
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.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
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.