This project demonstrates AI-enhanced dbt development using MCP (Model Context Protocol) and Claude Code. Built around the classic Jaffle Shop dataset (a fictional restaurant), it showcases how to integrate Claude AI directly into your dbt workflow for interactive data modeling, analysis, and development.
- MCP Integration: Direct Claude access to dbt commands, SQL execution, and data exploration
- Claude Code Workflows: AI-assisted model development, testing, and debugging
- Local Development: PostgreSQL + Docker setup optimized for AI coding
- Real-time Interaction: Query data, generate models, and analyze results with AI assistance
MCP local server
Claude Desktop connected to dbt.
- Docker and Docker Compose
- Python 3.9+
- Claude Desktop
Download Claude Desktop:
- macOS or Windows: Mac/Windows
- Claude Desktop Linux Debian: Linux Debian
Install and sign in:
- Install the application
- Sign in with your Claude account
- Verify Claude Desktop is running
Download Claude Code:
# macOS (via Homebrew)
brew install claude
# Or download directly from: https://claude.ai/code
# Follow installation instructions for your platformVerify installation:
claude --version# Clone and enter the project
git clone https://github.com/AngelAlvarado/jaffle-shop-with-ai
cd jaffle-shop-with-ai
# Start PostgreSQL and dbt containers
docker-compose up -d
# Load sample data (1 year of restaurant data)
docker exec -it jaffle_shop_dbt dbt seed --full-refresh --vars '{"load_source_data": true}'
# Build all models
docker exec -it jaffle_shop_dbt dbt buildInstall MCP prerequisites:
# Install uv (Python package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh
source ~/.local/bin/env
# Install dbt for MCP integration
uv tool install dbt-core
# Install and test the dbt MCP server
uvx dbt-mcp --helpVerify installation:
The uvx dbt-mcp --help command above will show environment variable errors - this is expected and means the MCP server is installed correctly.
Create MCP configuration:
Add to your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"dbt-mcp": {
"command": "uvx",
"args": [
"--env-file",
"/absolute/path/to/your/jaffle-shop-with-ai/.env.local",
"dbt-mcp"
]
}
}
}Important: Replace /absolute/path/to/your/jaffle-shop-with-ai/ with your actual project path.
Verify the .env.local file exists:
The project includes a .env.local file with:
DISABLE_DBT_CLI=false
DISABLE_SEMANTIC_LAYER=true
DISABLE_DISCOVERY=true
DISABLE_REMOTE=true
DBT_PROJECT_DIR=/absolute/path/to/your/jaffle-shop-with-ai
DBT_PATH=dbt
DBT_CLI_TIMEOUT=30Update the DBT_PROJECT_DIR to match your project location.
With Claude Desktop (macOS/Windows):
- Restart Claude Desktop to load the MCP configuration.
- Note: In linux you must kill the Electron process.
- Open Claude Desktop.
- Test MCP integration by asking:
- "List all dbt models in this project"
- "Show me the first 10 rows from the customers table"
- "Run dbt test and show me the results"
With Claude Code (all platforms):
# Start Claude Code in your project directory
cd /path/to/jaffle-shop-with-ai
claude codeThen interact with your dbt project through Claude Code.
Enable MCP in VSCode:
-
Install the Claude extension for VSCode
-
Open Settings (Cmd+,) β Features β Chat β Enable "Mcp"
-
Configuration files are at:
- User-level:
~/Library/Application Support/Code/User/mcp.json - Workspace-level:
.vscode/mcp.json(included in project)
- User-level:
-
Restart VSCode
-
Use
@dbtin chat to access dbt functionality
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Claude Desktop/ βββββΊβ MCP Server βββββΊβ dbt + Postgres β
β Claude Code β β (dbt-mcp) β β (Docker) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
- PostgreSQL Container: Stores your Jaffle Shop data
- dbt Container: Handles model building and transformations
- MCP Server: Bridges Claude AI with your dbt project
- Claude Interface: Provides AI interaction (Desktop, Code, or VSCode)
The project includes realistic restaurant data:
- Customers: Customer profiles and segmentation
- Orders: Transaction history with seasonality
- Products: Menu items with pricing and categories
- Stores: Multi-location restaurant operations
Perfect for exploring:
- Revenue analysis and forecasting
- Customer lifetime value modeling
- Product performance analytics
- Seasonal trend analysis
You: "What are our top-selling products this quarter?"
Claude Desktop: [Queries data and shows results with insights]
You: "Create a customer segmentation model based on purchase behavior"
Claude: [Generates SQL model with business logic and tests]
You: "This test is failing - can you help debug it?"
Claude: [Analyzes test, identifies issue, suggests fixes]
Using Claude with MCP:
# In Claude Desktop/Code:
"Run dbt build and show me any errors"
"Test the customers model"
"Show me the compiled SQL for the orders model"
"Generate documentation and serve it"
Direct Docker commands:
# Run specific models
docker exec -it jaffle_shop_dbt dbt run --select model_name
# Test models
docker exec -it jaffle_shop_dbt dbt test --select model_name
# Generate documentation
docker exec -it jaffle_shop_dbt dbt docs generate
docker exec -it jaffle_shop_dbt dbt docs serve --host 0.0.0.0 --port 8080# Generate 3 years of data for more interesting analysis
docker exec -it jaffle_shop_dbt jafgen 3
docker exec -it jaffle_shop_dbt sh -c "rm -rf seeds/jaffle-data && mv jaffle-data seeds"
docker exec -it jaffle_shop_dbt dbt seed --full-refresh --vars '{"load_source_data": true}'The project supports different environments:
dev: Default development (container-to-container)local: Local dbt with Docker PostgreSQLprod: Production deployment
models/
βββ staging/ # Data cleaning and standardization
βββ marts/ # Business logic and analytics
seeds/jaffle-data/ # Sample CSV data
macros/ # SQL utilities
.env.local # MCP configuration
mcp-config.json # VSCode MCP settings
Claude Desktop not available (Linux users):
- Use VSCode with MCP integration instead
- Or use Claude Code via the web interface
- Consider running on macOS/Windows via VM if needed
Claude Desktop MCP not working?
- Verify
.env.localhas correctDBT_PROJECT_DIRpath - Test:
uvx dbt-mcp --helpshould work without errors - Check Claude Desktop config file JSON syntax
- Restart Claude Desktop after config changes
MCP server errors?
- Ensure dbt is installed:
dbt --version - Check project path in
.env.localis absolute - Verify Docker containers are running:
docker ps
Container issues?
- Run
docker-compose logsto see error details - Ensure ports 5432 and 8080 aren't in use
- Try
docker-compose down && docker-compose up -d
dbt errors?
- Check database connection:
docker exec -it jaffle_shop_dbt dbt debug - Verify data loaded:
docker exec -it jaffle_shop_dbt dbt ls
Important Security Considerations:
This setup provides Claude AI with significant access to your development environment. Please be aware of the following:
- Claude Desktop can execute SQL queries and read all data in your PostgreSQL database
- This includes any sensitive or proprietary data you load into the Jaffle Shop database
- Claude can read table schemas, data contents, and query results
- Claude Code can read environment variables, including passwords and API keys
- Both tools can access your dbt project files, SQL models, and configuration files
- The
.env.localfile contains database connection details that Claude can access
- Consider using anonymized or synthetic data for experimentation
- Avoid loading production data or sensitive information into the database
- Review any SQL queries or code suggestions before execution
- Be mindful when asking Claude to analyze data that might contain PII
- The MCP server runs locally and communicates with Claude's services
- Database connections are local (localhost), but query results may be transmitted to Claude
- Consider network isolation if working with sensitive data
Important Privacy Changes:
- New Opt-in System (2025): Anthropic now allows training on user conversations and coding sessions by default
- Deadline: Users have until September 28, 2025 to opt out of data training
- Data Retention:
- Opted in: Up to 5 years for model improvement
- Opted out: 30 days (existing policy)
- Applies to: Claude Free, Pro, Max users, including Claude Code sessions
- MCP Data: Raw MCP server content not used for training (unless directly copied to conversations)

