Read-Only SQLite Shop Database MCP Server
Provides secure read-only access to an SQLite e-commerce database, enabling AI agents to list tables, inspect schemas, and run read-only SQL queries with pagination.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Read-Only SQLite Shop Database MCP Server show me the top 5 best-selling products"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Read-Only SQLite Shop Database MCP Server
An official Model Context Protocol (MCP) server providing secure, read-only database access to an SQLite e-commerce store (shop.db) for AI agents.
π Key Features
Standard
stdioTransport: Works seamlessly with any MCP client (Claude Desktop, Cursor, Gemini CLI, Antigravity, etc.).Multi-layered Read-Only Security:
SQLite URI read-only mode (
?mode=ro).Strict runtime
PRAGMA query_only = ON;.Pre-flight SQL parser rejecting all DDL/DML mutation statements (
INSERT,UPDATE,DELETE,DROP,ALTER,CREATE, etc.).Blocks SQL injection chains and multi-statement execution.
LLM-Optimized Tools: Clear descriptions, robust error handling without raw stack traces, and automatic pagination (
limit/offset).Flexible Path Resolution: Works out of the box with relative paths,
DB_PATHenvironment variable, or--db-pathCLI flag.
Related MCP server: shop-db
ποΈ Database Schema
The SQLite database (shop.db) contains the following entities:
customers
β
βββ< orders
β
βββ< order_items >ββ productscustomers:id,first_name,last_name,email,phone,created_atproducts:id,name,category,price,stock_quantity,created_atorders:id,customer_id,order_date,status(new,processing,shipped,completed,cancelled),total_amountorder_items:id,order_id,product_id,quantity,unit_price
π οΈ MCP Tools
Tool | Parameters | Description |
| None | Lists all user tables with column count and row count summary. |
|
| Returns column definitions, data types, primary keys, foreign keys, row count, and sample rows. |
| None | Returns the complete schema and relationship graph of all tables in one call. |
|
| Executes read-only queries ( |
π Getting Started
1. Installation
Create a virtual environment and install the required dependencies:
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt2. Running Locally
Run the MCP server over standard input/output:
python server.pyOr specify a custom database path:
# Using CLI argument
python server.py --db-path /path/to/shop.db
# Or using Environment Variable
DB_PATH=/path/to/shop.db python server.py3. Running Tests
Run the test suite to verify tool functionality and safety constraints:
python -m unittest discover -s tests -vπ Connecting to AI Agents
Claude Desktop
Add this server to your claude_desktop_config.json (~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"shop-database": {
"command": "/absolute/path/to/.venv/bin/python",
"args": ["/absolute/path/to/server.py"],
"env": {
"DB_PATH": "/absolute/path/to/shop.db"
}
}
}
}Cursor IDE
In Cursor Settings β Features β MCP:
Type:
commandCommand:
/absolute/path/to/.venv/bin/python /absolute/path/to/server.py
Antigravity / Gemini CLI
Add to your MCP configuration file:
{
"mcpServers": {
"shop-database": {
"command": "python",
"args": ["server.py"]
}
}
}π Safety & Validation Examples
If an AI agent or prompt attempts a destructive operation, the server immediately rejects the query gracefully:
Prompt: "Delete all cancelled orders."
Server Response:
{ "error": "Operation rejected: Statement type 'DELETE' is not allowed. Only read-only queries (SELECT, WITH ... SELECT, EXPLAIN) are permitted." }
π Verification Queries
The server enables AI agents to resolve analytical queries such as:
Table Discovery:
list_tables()anddescribe_table(table_name="customers")Customer Demographics:
SELECT count(*) FROM customers WHERE phone LIKE '+7%';Customer Who Spent the Most Money:
SELECT c.first_name, c.last_name, c.email, SUM(o.total_amount) AS total_spent FROM customers c JOIN orders o ON c.id = o.customer_id WHERE o.status != 'cancelled' GROUP BY c.id ORDER BY total_spent DESC LIMIT 1;Top 5 Best-Selling Products:
SELECT p.name, SUM(oi.quantity) AS units_sold, SUM(oi.quantity * oi.unit_price) AS revenue FROM products p JOIN order_items oi ON p.id = oi.product_id JOIN orders o ON oi.order_id = o.id WHERE o.status != 'cancelled' GROUP BY p.id ORDER BY units_sold DESC LIMIT 5;Top 3 Product Categories by Revenue:
SELECT p.category, SUM(oi.quantity * oi.unit_price) AS revenue FROM products p JOIN order_items oi ON p.id = oi.product_id JOIN orders o ON oi.order_id = o.id WHERE o.status != 'cancelled' GROUP BY p.category ORDER BY revenue DESC LIMIT 3;Customer With Most Orders:
SELECT c.first_name, c.last_name, COUNT(o.id) AS order_count FROM customers c JOIN orders o ON c.id = o.customer_id GROUP BY c.id ORDER BY order_count DESC LIMIT 1;
Available Tools
4 toolsdescribe_tableA
Get detailed schema information for a specific database table, including column names, data types, primary keys, foreign key relations, total row count, and sample data.
Inputs: table_name (required). Returns: result
get_database_schemaA
Get the complete schema for all tables and foreign key relationships across the entire database in a single call. Use this to quickly understand the entire database structure.
Inputs: no named parameters. Returns: result
list_tablesA
List all user tables available in the SQLite database, along with column count and row count summary.
Inputs: no named parameters. Returns: result
read_queryA
Execute a read-only SQL query (SELECT, WITH ... SELECT, or EXPLAIN) on the database. Mutating queries (INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, etc.) are strictly prohibited and will be rejected. Results support pagination via limit and offset.
Inputs: query (required), limit, offset. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: listing tables, describing a single table, viewing the full schema, and executing read-only queries. Potential overlap between get_database_schema and describe_table is resolved by one being all-encompassing while the other focuses on one table with sample data.
All tool names follow a consistent verb_noun pattern: list_tables, describe_table, get_database_schema, read_query. The naming style is uniform and predictable, making it easy for an agent to infer tool behavior from names.
Four tools is well-scoped for a read-only SQLite server. Each tool serves a necessary part of database exploration without being redundant or overwhelming, fitting comfortably in the ideal tool count range.
The toolset fully covers the read-only exploration lifecycle: reveal the database structure and allow arbitrary SELECT queries. There are no missing operations for a read-only server, as all needed capabilities are present.
Maintenance
Related MCP Connectors
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view detβ¦
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Astra DB tools for agents: schema, find, vector search, guarded writes, and interactive views.
Related MCP Servers
- FlicenseAqualityCmaintenanceEnables AI agents to answer analytical questions about an online store's SQLite database through specialized read-only tools, without any risk of modifying the underlying data.8-
- FlicenseAqualityCmaintenanceEnables 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-
- FlicenseAqualityCmaintenanceGives 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-
- FlicenseAqualityCmaintenanceEnables AI agents to analyze an SQLite e-commerce database via secure read-only SQL queries, providing tools for table inspection and analytical requests.2-