shop-analytics-mcp
Provides read-only analytics over SQLite databases, allowing agents to inspect database schemas, view table summaries, and execute 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., "@shop-analytics-mcpWhat are the top 5 customers by total spend?"
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.
Shop Analytics MCP Server
A read-only Model Context Protocol (MCP) server that exposes a SQLite database (shop.db) to AI agents via two tools.
Features
Tool | Description |
| Returns DDL (CREATE TABLE statements) for all tables |
| Returns a summary of a specific table, including row count and the first 5 sample rows |
| Executes a SELECT query and returns results as JSON. Supports pagination via |
Security & Robustness
Mutation keyword blocking – queries containing
INSERT,UPDATE,DELETE,DROP,ALTER,CREATE,REPLACE, orTRUNCATEare rejected before reaching the database.Automatic Pagination –
execute_read_only_sqlautomatically caps results at 100 rows, but can be customized with explicitlimitandoffsetparameters.Read-only SQLite URI – the database is opened with
?mode=ro, preventing any writes at the OS level.Structured Errors – SQL errors are returned as a JSON structure to help agents easily understand and recover from mistakes.
Related MCP server: MCP-Server-data
Requirements
Python 3.10+
Dependencies listed in
requirements.txt
1. Installation
# Clone / enter the project directory
cd shop-analytics-mcp
# Create and activate a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt2. Configuration
Environment Variable | Default | Description |
|
| Absolute or relative path to the SQLite database |
3. Running the Server
The server communicates via stdio (standard input/output), which is the transport used by MCP hosts.
Running Locally
# Run with the default shop.db in the current directory
python server.py
# Run with a custom database path
SHOP_DB_PATH=/path/to/my.db python server.pyRunning with Docker
You can run the server in an isolated Docker container. Since MCP uses stdio, you must run the container in interactive mode (-i).
docker build -t shop-analytics-mcp .
# Run the container (reads and writes to stdio)
docker run -i --rm shop-analytics-mcp4. Connecting to Agent
Any MCP-compatible host can connect to this server via stdio.
Agent Configuration (mcp.json)
{
"mcpServers": {
"shop-analytics": {
"command": "/path/to/.venv/bin/python",
"args": ["/path/to/shop-analytics-mcp/server.py"],
"env": {
"SHOP_DB_PATH": "/path/to/shop.db"
}
}
}
}Programmatic (Python MCP client SDK)
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def main():
params = StdioServerParameters(
command="python",
args=["server.py"],
env={"SHOP_DB_PATH": "shop.db"},
)
async with stdio_client(params) as (r, w):
async with ClientSession(r, w) as session:
await session.initialize()
result = await session.call_tool("get_database_schema", {})
print(result.content[0].text)
asyncio.run(main())Running Tests
Unit Tests
pytest tests/test_server.py -vEvaluation Test Suite
Comprehensive evaluation suite covering all phases defined in EVALS_SPEC.md (Environment, Security, Functional Tasks, and Robustness).
pytest tests/test_evals.py -vContract Smoke Test
The smoke test launches the server as a subprocess and exercises both tools via the MCP client SDK — no LLM required.
python tests/smoke_test.pyProject Structure
shop-analytics-mcp/
├── server.py # FastMCP server (entry point)
├── create_shop_db.py # One-time script to create demo shop.db
├── Dockerfile # Docker image configuration
├── .dockerignore # Files to ignore in Docker context
├── requirements.txt
├── README.md
├── SPEC.md # Initial project specification
├── EVALS_SPEC.md # Evaluation implementation plan
└── tests/
├── test_server.py # pytest unit tests (in-memory SQLite)
├── test_evals.py # Comprehensive TDD evaluation suite
└── smoke_test.py # Contract smoke test (stdio subprocess)This server cannot be deployed
Maintenance
Related MCP Connectors
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceExposes any SQLite database as read-only MCP tools for AI assistants, enabling listing tables, describing schemas, and running SELECT queries with filtering, ordering, and pagination.-
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to query a SQLite database using natural language through the Model Context Protocol (MCP). Includes security guardrails that block destructive SQL operations.-
- FlicenseAqualityCmaintenanceEnables AI agents to safely explore and query a SQLite database in read-only mode, allowing them to inspect schema and run analytical SQL queries without risking data modification.3-
- FlicenseAqualityCmaintenanceEnables AI agents to safely inspect and query a SQLite database through read-only MCP tools for listing tables, describing schemas, and running paginated SELECT queries.3-