This guide shows how to connect the AI Analyst MCP server to Claude Desktop.
- Claude Desktop app installed
- AI Analyst MCP server working locally (test with
uv run python test_mcp_server.py)
Find your Claude Desktop configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonGUI apps don't inherit shell PATH, so you need the full path to uv:
which uv
# Common locations:
# macOS (Homebrew): /opt/homebrew/bin/uv
# macOS (curl install): ~/.cargo/bin/uv
# Linux: ~/.cargo/bin/uvOpen the configuration file and add our server to the mcpServers section:
{
"mcpServers": {
"ai-analyst": {
"command": "/opt/homebrew/bin/uv",
"args": [
"run",
"python",
"run_mcp_server.py"
],
"cwd": "/path/to/claude-analyst/semantic-layer"
}
}
}Important:
- Update the
commandpath to your actualuvlocation (fromwhich uv) - Update the
cwdpath to match your actual installation directory
Copy the configuration from claude_desktop_config.json in this directory:
cp claude_desktop_config.json ~/Library/Application\ Support/Claude/claude_desktop_config.jsonOr merge it with your existing configuration if you have other MCP servers.
- Quit Claude Desktop completely
- Restart the application
- The AI Analyst tools should now be available
Once connected, you'll have access to these MCP tools:
list_models- List available semantic models (users, events, engagement)get_model- Get detailed schema for a specific modelquery_model- Query data with execution-first pattern and statistical analysissuggest_analysis- Get suggestions for next analysis stepstest_significance- Run statistical significance tests
health_check- Check system health and database connectionget_sample_queries- Get example queries for a model
Once connected, try these commands in Claude Desktop:
List available models
What's our conversion rate by plan type?
Show me the most popular features
How does engagement vary by industry?
Test if the difference in engagement by plan type is statistically significant
The integration follows this flow:
Claude Desktop → MCP Protocol → AI Analyst Server → Semantic Layer → DuckDB
The system implements Build → Execute → Annotate to prevent fabrication:
- Build: Generate SQL query from semantic model
- Execute: Run query against real database
- Annotate: Generate interpretation based on actual results
- Auto-validates sample sizes
- Runs significance tests when comparing groups
- Calculates effect sizes
- Provides business context with benchmarks
- Concise observations ("Tech 2x higher LTV")
- Shows statistical evidence (p-values, sample sizes)
- Suggests logical next questions
- Includes business benchmarks
-
Test locally first:
cd /path/to/claude-analyst/semantic-layer uv run python test_mcp_server.py -
Check the path in the config file matches your installation
-
Ensure the virtual environment exists:
ls .venv/
- Restart Claude Desktop completely
- Check the configuration file syntax (valid JSON)
- Look for error messages in Claude Desktop
-
Verify database exists:
ls data/analytics.duckdb
-
Test semantic models:
ls models/*.yml -
Run the test script to check all components
To use a different database, update the semantic layer configuration:
- Edit
mcp_server/semantic_layer_integration.py - Change the database path in line 25:
self.db_path = Path("path/to/your/database.duckdb")
Add new semantic models:
- Create
.ymlfiles in themodels/directory - Follow the existing model patterns
- Restart the MCP server
For production use:
- Use a production database (PostgreSQL, Snowflake, etc.)
- Configure authentication and security
- Add monitoring and logging
- Set up proper error handling
If you encounter issues:
- Check the test script passes:
uv run python test_mcp_server.py - Verify Claude Desktop configuration syntax
- Look for error messages in Claude Desktop
- Check the semantic model definitions in
models/
The AI Analyst follows Mercury project learnings and Rasmus Engelbrecht's semantic layer patterns for reliable, statistical analysis.