A comprehensive multi-agent system that extracts, analyzes, and visualizes 12+ years of health data from Apple Health exports using Claude Desktop, Snowflake, and advanced AI agents.
This project demonstrates the power of modern AI agent architectures by solving a critical real-world problem: Your health data is trapped in a digital graveyard.
Apple Health aggregates years of medical records, lab results, medications, and vitals from multiple healthcare providers into comprehensive PDFs. Yet this treasure trove of personal health data remains frustratingly inaccessible - static, unsearchable, and impossible to analyze. Your health history becomes a 200+ page document that no one reads, including you.
The solution transforms these static Apple Health PDF exports into a conversational health intelligence system that achieves:
- High extraction accuracy - Every data point preserved
- Natural language querying - Ask questions like "What's my cholesterol trend?"
- Instant insights - From hours of manual analysis to seconds of AI-powered intelligence
- 12+ years of analysis - Uncover patterns and correlations across your entire health history
Multi-Agent System with Claude + MCP + Snowflake
📺 Watch Part 1 Video | 📖 Read Part 1 Blog
Learn how to build a multi-agent health system from scratch, including:
- Setting up the Health Data Extractor Agent in Claude Desktop
- Extracting 12+ years of health data with high accuracy
- Understanding the multi-agent architecture and design decisions
Building Multi-Agent Health System with Claude Code
📺 Watch Part 2 Video | 📖 Read Part 2 Blog
Discover why Claude Code revolutionizes agentic development:
- Building custom MCP servers with Claude Code
- Creating Snowflake integrations and semantic models
- Achieving production-ready code in 1-2 attempts
The system leverages three core technologies:
- Claude Desktop: No-code agent creation with natural language instructions
- Model Context Protocol (MCP): Seamless connections between agents and enterprise systems
- Snowflake Cortex: Enterprise-grade analytics with natural language processing
Traditional single-agent approaches fail at complex health data processing because they try to do everything at once. This project embraces specialized agent collaboration where each agent excels at one critical task:
- Extraction requires perfection - The Extractor Agent focuses solely on highly accurate data capture
- Analysis requires intelligence - The Analyst Agent leverages enterprise tools for complex queries
- Scale requires specialization - Processing 200+ pages demands optimized context windows
This separation of concerns delivers what users desperately need:
- ✅ Track biomarker trends across decades
- ✅ Instantly identify abnormal lab results
- ✅ Correlate medication changes with health outcomes
- ✅ Generate insights from 12+ years of health history
- ✅ Create data-driven visualizations for healthcare providers
The architecture follows a clear Extract → Load → Analyze pipeline, with each component having one specialized job:
Role: Transforms unstructured PDFs into structured JSON with high accuracy
Why it matters: The extraction agent doesn't try to analyze or visualize - it just extracts data with exceptional precision. This laser focus on a single responsibility is what enables the high accuracy requirement to be met consistently across hundreds of pages of complex medical data.
Capabilities:
- Processes 200+ page Apple Health PDF exports
- Extracts data using Claude Opus 4 with structured JSON schemas
- Organizes by clinical type and year to optimize context windows
- Validates extraction accuracy against source documents
Configuration:
- Agent Platform: Claude Desktop
- LLM: Claude Opus 4 (document intelligence optimized)
- Knowledge Base: Apple Health PDF + JSON extraction schemas
- Output: Structured JSON files by category and year
Role: First loads extracted JSON files into Snowflake, then orchestrates the analytics workflow
The analyst agent coordinates specialized tools that excel at natural language processing and SQL generation, then executes the SQL against the Snowflake data warehouse after receiving the generated SQL from the Cortex Analyst endpoint.
Capabilities:
- Imports extracted JSON into Snowflake data warehouse
- Orchestrates natural language queries via Cortex Analyst
- Generates interactive visualizations using Claude Artifacts
- Provides comprehensive health dashboards and trend analysis
Configuration:
- Agent Platform: Claude Desktop
- LLM: Claude Opus 4
- Tools: Custom MCP Server with Snowflake integration
- Output: Interactive React visualizations and health insights
Role: Provides enterprise-grade storage and query performance
When you're dealing with 12 years of lab results across multiple providers, you need sub-second response times. Snowflake delivers the performance and scalability required for complex health analytics.
Features:
- Enterprise-grade cloud data platform
- Sub-second query response times for large datasets
- Automatic scaling and optimization
- Integrated Cortex Analyst capabilities
Role: Converts natural language to SQL with specialized focus
Cortex Analyst doesn't try to be a general chatbot - it does one thing brilliantly: understanding health-related questions and generating precise SQL queries against your structured health data.
Capabilities:
- Natural language to SQL translation
- Health domain-specific query understanding
- Semantic model-powered query generation
- Complex temporal and correlation analysis
Role: Provides the connectivity layer between agents and Snowflake
The MCP server bridges Claude Desktop agents with Snowflake infrastructure through two specialized tools: one for bulk data import, one for query execution.
Tools Provided:
- Health Data Import Tool: Batch processing of JSON extraction files
- Natural Language Query Tool: Real-time query execution via Cortex Analyst
- Authentication: Secure connection management with Snowflake
- Error Handling: Comprehensive validation and rollback capabilities
This project demonstrates Claude Code's revolutionary approach to agentic development - a capability that represents the most fundamental difference from every other development tool available today.
Traditional development tools like Cursor and Copilot require constant manual context management: adding files to context, explaining component relationships, and ensuring the AI understands the broader architecture. This context overhead significantly limits productivity and often results in dozens of iterations to achieve working code.
Claude Code eliminates this friction entirely through automatic comprehension of your complete project structure.
The key to unlocking Claude Code's capabilities lies in creating comprehensive design and requirements that serve as Claude Code's instruction manual. This project showcases the CLAUDE.md Framework:
📋 Business Requirements (agents/analyst-agent/config/)
- User workflows and access patterns
- Health query types and success criteria
- End-user perspective and use cases
⚙️ Technical Requirements (requirements/technical/)
- Database design patterns and data modeling principles
- Cortex Analyst integration specifications
- MCP server implementation guidelines
This comprehensive context foundation transformed development outcomes:
- 🎯 Production-ready code in 1-2 attempts instead of dozens of iterations
- 🚀 Complete MCP server generation from technical specifications
- 📊 Semantic model creation directly from business requirements
- 🗄️ Snowflake DDL generation following data modeling principles
- ⏱️ Hours to seconds - What took hours of manual coding now happens in seconds
- 🔄 Zero context switching - Claude Code maintains full project understanding throughout
Key Artifacts Built with Claude Code:
- Custom MCP Server (
tools/health-mcp/) - Complete implementation with dual health tools - Semantic Model (
semantic-model/snowflake/) - Cortex Analyst configuration - Database Schema (
data-store/snowflake/ddl/) - Enterprise-grade health data model
The upfront investment in creating detailed design and requirements pays exponential dividends in development velocity and code quality. This approach showcases how proper project structure enables Claude Code to function as a true development partner rather than just a code completion tool.
The system generates comprehensive health insights:
Natural Language Query: "What's my cholesterol trend over the past decade?"
AI-Generated Insights:
- 📉 33% decrease in total cholesterol over 12 years
⚠️ Identification of concerning triglyceride spike in 2025- 💊 Correlation with medication adherence patterns
- 📊 Clear visualization of normal ranges vs. actual values
From static PDF to actionable intelligence in seconds.
Query: "Analyze cholesterol medication adherence patterns and correlate with lab results over time"
Demonstrates:
- Multi-factor analysis across medications, labs, and dosing
- Timeline correlation between statin therapy and cholesterol improvement
- Impact of dosage adjustments on health outcomes
Query: "Show my abnormal lab results from recent tests"
Features:
- Automated detection of values outside normal ranges
- Trend identification across multiple biomarkers
- Clinical relevance scoring and recommendations
Query: "How has my HbA1c changed since starting metformin, and is there correlation with weight measurements?"
Advanced Analytics:
- Three-way correlation analysis (medication + labs + vitals)
- Statistical significance testing
- Predictive trend modeling
- Clinical decision support insights
Database: HEALTH_INTELLIGENCE
Schema: HEALTH_RECORDS
Tables: PATIENTS, HEALTH_RECORDS, IMPORTS
Design Principles:
- Unified health records table (no separate tables per data type)
- Optimized for natural language query generation
- Snowflake Cortex Analyst compatible schema design
- Enterprise-grade data lineage and audit trails
@mcp.tool()
async def snowflake_import_analyze_health_records_v2():
"""Import extracted health JSON files into Snowflake warehouse"""Features:
- Batch processing of JSON extraction files
- Data validation and quality reporting
- Import statistics and visualization dashboard generation
- Error handling and rollback capabilities
@mcp.tool()
async def execute_health_query_v2():
"""Execute natural language health queries via Cortex Analyst"""Capabilities:
- Snowflake Cortex Analyst integration
- Semantic model-powered SQL generation
- Complex multi-table joins and correlations
- Real-time query execution and result formatting
File: semantic-model/snowflake/health_intelligence_semantic_model.yaml
Features:
- Business-friendly data definitions for Cortex Analyst
- Pre-configured health metrics and relationships
- Natural language query optimization
- Support for complex temporal and correlation queries
- Claude Desktop (for agent creation and management)
- Snowflake Account (for data warehousing and Cortex Analyst)
- Python 3.9+ with
uvpackage manager - Apple Health Export (PDF format)
- Open Apple Health app on iPhone
- Tap your profile picture (top right)
- Scroll down to "Export All Health Data"
- Share the generated ZIP file
- Extract and locate the
export.pdffile (200+ pages)
- Open Claude Desktop
- Create new project: "Health Data Extractor Agent"
- Select Claude Opus 4 as the LLM
- Upload agent instructions:
agents/extractor-agent/config/agent-instructions.md
- Upload your Apple Health
export.pdf - Upload extraction schemas from
agents/extractor-agent/knowledge/:clinical-data-extraction-schema.jsonlab-results-extraction-schema.jsonmedications-extraction-schema.jsonvitals-extraction-schema.json
- Start with: "Extract my lab results into organized JSON files"
- Continue with: "Extract my medications", "Extract my vitals", "Extract my clinical data"
- Download all generated JSON artifacts
- Save to a local directory (e.g.,
extracted-data/)
-- Execute the DDL script
source data-store/snowflake/ddl/health_intelligence_ddl.sqlThis creates:
HEALTH_INTELLIGENCEdatabaseHEALTH_RECORDSschema with tables:PATIENTS,HEALTH_RECORDS,IMPORTS- Required stages and permissions for Cortex Analyst
# Upload semantic model to Snowflake stage
PUT file://semantic-model/snowflake/health_intelligence_semantic_model.yaml @RAW_DATA;cd tools/health-mcp
uv installexport SNOWFLAKE_USER="your_username"
export SNOWFLAKE_ACCOUNT="your_account"
export SNOWFLAKE_PRIVATE_KEY_PATH="/path/to/your/private_key.p8"
export SNOWFLAKE_WAREHOUSE="your_warehouse"
export SNOWFLAKE_DATABASE="HEALTH_INTELLIGENCE"
export SNOWFLAKE_SCHEMA="HEALTH_RECORDS"
export SNOWFLAKE_ROLE="ACCOUNTADMIN"
export SNOWFLAKE_SEMANTIC_MODEL_FILE="@RAW_DATA/health_intelligence_semantic_model.yaml"# Test data import functionality
uv run test_import.py
# Test natural language querying
uv run test_query.py- Create new project: "Health Analyst Agent"
- Select Claude Opus 4 as the LLM
- Upload agent instructions:
agents/analyst-agent/config/agent-instructions.md
- Open Claude Desktop settings
- Add MCP server configuration:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "/path/to/extracted-data"]
},
"health-mcp": {
"command": "uv",
"args": ["--directory", "/path/to/tools/health-mcp", "run", "python", "src/health_mcp.py"],
"env": {
"SNOWFLAKE_USER": "your_username",
"SNOWFLAKE_ACCOUNT": "your_account"
}
}
}
}Share the path to your extracted JSON files with the Health Analyst Agent: "Please import my health data from /path/to/extracted-data/"
Try these example queries:
- "What's my cholesterol trend over the past 5 years?"
- "Show abnormal lab results from recent tests"
- "Correlate my blood pressure medications with my readings"
- "How has my HbA1c changed since starting metformin?"
# Install dependencies
uv install
# Run tests
uv run pytest
# Format code
uv run black src/
uv run isort src/
# Type checking
uv run mypy src/
# Run MCP health server locally
uv run python src/health_mcp.py├── agents/ # Agent configurations
│ ├── extractor-agent/ # Health Data Extractor Agent
│ │ ├── config/ # Agent instructions and descriptions
│ │ └── knowledge/ # JSON extraction schemas
│ └── analyst-agent/ # Health Analyst Agent
│ └── config/ # Agent instructions
├── data-store/ # Database schemas and scripts
│ └── snowflake/
│ └── ddl/ # Snowflake DDL for health database
├── semantic-model/ # Cortex Analyst configuration
│ └── snowflake/ # YAML semantic model definitions
├── tools/ # Custom MCP server implementation
│ └── health-mcp/ # Snowflake integration tools
├── example/ # Sample extracted health data
│ └── extraction/ # JSON files by category and year
├── docs/ # Documentation and demo materials
│ ├── images/ # Architecture diagrams and screenshots
│ └── videos/ # Demo video scripts and flows
└── requirements/ # Technical specifications
└── technical/ # Implementation requirements
MIT License - See LICENSE for details.
Transform your health data from a static graveyard into living, actionable intelligence. Built with Claude Code's revolutionary agentic development approach - achieving in hours what traditionally takes weeks.









