pizza-analytics
Exposes local DuckDB pizza sales data as MCP tools for querying store-level and total sales metrics via natural language, enabling local LLMs to perform real-time analytical queries.
README
🍕 Pizza Analytics: Local dbt + DuckDB + FastMCP Pipeline
An end-to-end local data analytics stack featuring a dbt transformation pipeline on DuckDB, fully containerized with Docker, and exposed as a Model Context Protocol (MCP) server for local LLMs via LM Studio.
📐 Architecture Overview
Data Ingestion & Transformation: Raw CSV data is transformed using modular dbt models into Staging (stg_*), Fact (fct_*), and Dimension (dim_*) layers within a single-file DuckDB database (dev.duckdb).
MCP Tool Server: A Python-based FastMCP server connects to DuckDB in read-only mode to expose structured analytical tools over standard input/output (stdio).
LLM Orchestration: Local LLMs in LM Studio invoke these tools on demand to answer complex analytical questions with real-time database queries.
📁 Repository Structure
.
├── dbt_project/
│ ├── models/ # dbt transformation models (stg_*, fct_*, dim_*)
│ ├── seeds/ # Raw sample data CSVs
│ ├── dbt_project.yml # dbt project configurations
│ └── profiles.yml # DuckDB profile settings
├── Dockerfile # Container definition for dbt & Python environment
├── docker-compose.yml # Multi-container service orchestration
├── mcp_server.py # FastMCP server exposing database tools to LLMs
├── requirements.txt # Local Python dependencies for MCP host
├── .gitignore # Ignores compiled DuckDB binaries & temporary logs
└── README.md
⚡ Quickstart Guide
Prerequisites
Docker Desktop installed with WSL2 backend.
Python 3.10+ installed locally (for running the host MCP server).
LM Studio installed.
Step 1: Clone & Build Containers
Clone this repository to your local machine:
git clone https://github.com/YOUR_USERNAME/pizza-analytics-mcp.git
cd pizza-analytics-mcp
Build and spin up the Docker services in the background:
docker compose up -d --build
Step 2: Build the dbt Data Pipeline
Run dbt seeds and models inside the container to build your local DuckDB database:
# Populate raw CSV seed files into DuckDB
docker compose exec dbt dbt seed
# Execute staging, fact, and dimension transformations
docker compose exec dbt dbt run
Note: This creates the database file at ./dbt_project/dev.duckdb.
Step 3: Install Local Dependencies for MCP
Install the required Python packages on your local host system so LM Studio can execute the MCP server script:
pip install -r requirements.txt
(Or install manually: pip install duckdb fastmcp pandas)
Step 4: Configure LM Studio
Open LM Studio and navigate to the MCP / Integrations settings.
Edit your mcp.json file to register the pizza-analytics server:
{
"mcpServers": {
"pizza-analytics": {
"command": "python",
"args": [
"-u",
"C:\\FULL\\PATH\\TO\\pizza-analytics-mcp\\mcp_server.py"
]
}
}
}
Note: Ensure you use the -u flag to disable Python's standard output buffering, and replace C:\\FULL\\PATH\\TO\\ with your exact absolute path.
Save the file and click Refresh in LM Studio. The tool indicators should turn green!
🛠️ Available MCP Tools
get_store_sales
Queries store-level performance metrics directly from fct_orders.
Parameters: store_id (optional string, e.g., "1")
Returns: JSON array with store_id, total_orders, and total_revenue.
get_total_sales
Queries overall performance metrics (total revenue and total pizza order counts across all stores) directly from fct_orders.
Parameters: None
Returns: JSON array with total_orders and total_revenue.
💡 Key Design & Troubleshooting Notes
DuckDB Concurrency & Locking: FastMCP connects to DuckDB using read_only=True and a Python with context manager. This ensures connections are released immediately after queries execute and prevents file lock deadlocks.
Serialization: Data types such as Decimal and Date from DuckDB queries are serialized using json.dumps(data, default=str) to ensure clean JSON transmission over stdio.
Speculative Decoding: When using local models (e.g., Gemma, Llama) with tool calling in LM Studio, disable Speculative Decoding / Draft Models in your model parameters to prevent context cache decoding crashes.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。