MCP server that gives Claude tools to analyze an e-commerce SQLite database. 5 tools: sales reports, customer insights, inventory status, order search, business dashboard.
MCP Server: E-Commerce Analytics
An MCP (Model Context Protocol) server that gives Claude direct access to an e-commerce SQLite database. Ask natural-language questions about sales, customers, inventory, and orders -- Claude calls the right tools automatically.
Built with the official Anthropic MCP Python SDK and designed as a single-file, zero-config demo. The database is created and seeded with realistic data on first run.
Features
| Tool | Description |
|---|---|
| query_sales_report | Revenue, order count, average order value, and top products for any date range. Optional category filter. |
| get_customer_insights | Full customer profile: purchase history, lifetime spend, favourite categories, recent orders. Look up by ID or email. |
| check_inventory_status | Stock levels for every product with low-stock alerts. Optional category filter and configurable threshold. |
| search_orders | Flexible order search by status, customer email, and minimum amount. Paginated results with item counts. |
| get_business_summary | High-level dashboard: total revenue, revenue by category, 6-month trends, and top 5 customers. |
Quick Start
1. Install dependencies
pip install -r requirements.txt
2. Run the server directly (stdio transport)
python server.py
On first run the server creates ecommerce_demo.db in the same directory and seeds it with:
- 50 products across 5 categories (Electronics, Clothing, Home & Kitchen, Books, Sports)
- 200 customers with realistic names, emails, and signup dates
- 1 200 orders with varied statuses and 1-5 line items each
3. Connect to Claude Desktop
Add the following to your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ecommerce-analytics": {
"command": "python",
"args": ["/absolute/path/to/server.py"]
}
}
}
Restart Claude Desktop. The tools will appear automatically.
Example Queries
Once connected, try asking Claude:
- "Show me a sales report for the last 30 days."
- "How is the Electronics category performing this quarter?"
- "Look up the customer with email james.smith@example.com."
- "Which products are running low on stock?"
- "Find all pending orders over $100."
- "Give me an overall business summary with trends."
Claude will select the appropriate tool, execute the query, and present the results in a readable format.
Tech Stack
- Python 3.10+
- MCP Python SDK (
mcppackage with FastMCP) - Pydantic v2 for response validation
- SQLite (zero-config, file-based)
Project Structure
mcp-server-ecommerce-analytics/
server.py # MCP server -- tools, DB setup, entry point
requirements.txt # Python dependencies
README.md # This file
ecommerce_demo.db # Auto-generated on first run
License
MIT