Skip to main content

Prerequisites

Before setting up your development environment, ensure you have:

Python 3.12+

Required for running the application

Node.js 18+

Required for chart rendering and SSR

Docker & Docker Compose

For running PostgreSQL and Redis

System Build Tools

gcc, gfortran, and scientific libraries

Git

For version control

Code Editor

VS Code, PyCharm, or your preferred IDE

Quick Setup

1

Clone the repository

git clone https://github.com/thetahealth/mirobody-health.git
cd mirobody-health
2

Install system dependencies

xcode-select --install
brew install gcc gfortran fftw hdf5 openblas lapack
3

Create virtual environment

python3.12 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
4

Install Python dependencies

pip install mirobody -r requirements.txt
The mirobody package contains core utilities. Installing in development mode with -e . is optional.
5

Install Node.js dependencies

npm install @antv/gpt-vis-ssr ws
Required for chart rendering service.
6

Start services

docker-compose up -d postgres redis
Or use your own PostgreSQL and Redis instances.
7

Configure environment

cp .env.example .env
cp config.yaml config.localdb.yaml
Edit .env:
ENV=localdb
Edit config.localdb.yaml with your settings:
# At least one LLM API key required
GOOGLE_API_KEY: ''
OPENAI_API_KEY: ''
OPENROUTER_API_KEY: ''

# Database settings
PG_HOST: 'localhost'
PG_PORT: 5432
PG_USER: 'holistic_user'
PG_PASSWORD: 'holistic_password'
PG_DBNAME: 'holistic_db'
PG_SCHEMA: 'theta_ai'

# Redis settings
REDIS_HOST: 'localhost'
REDIS_PORT: 6379
REDIS_DB: 0
REDIS_PASSWORD: ''

# MCP and Agent directories
MCP_TOOL_DIRS:
  - mirobody/pub/tools
  - mirobody/pub/tools_health

MCP_RESOURCE_DIRS:
  - mirobody/pub/resources

AGENT_DIRS:
  - mirobody/pub/agents
8

Run the application

python main.py
Server should start on http://localhost:18080
If running under WSL, access from Windows via http://localhost:18080

Development Tools

.vscode/extensions.json
{
  "recommendations": [
    "ms-python.python",
    "ms-python.vscode-pylance",
    "ms-python.black-formatter",
    "charliermarsh.ruff",
    "tamasfe.even-better-toml",
    "redhat.vscode-yaml"
  ]
}

Code Formatting

# Install development dependencies
pip install black ruff pytest pytest-asyncio

# Format code
black .

# Lint code
ruff check .

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=connect --cov-report=html

# Run specific test file
pytest tests/test_provider_garmin.py

# Run integration tests
pytest -m integration

Project Structure

mirobody-health/
├── mirobody/                # Main application package
│   ├── chat/               # Chat and agent services
│   │   ├── adapters/      # Protocol adapters (HTTP, WebSocket)
│   │   ├── agent.py       # Agent registry and loading
│   │   ├── service.py     # Chat service routes
│   │   └── unified_chat_service.py  # Core chat logic
│   ├── mcp/                # MCP protocol implementation
│   │   ├── service.py     # JSON-RPC handler
│   │   ├── tool.py        # Tool loading and execution
│   │   └── resource.py    # Resource management
│   ├── pulse/              # Health data platform
│   │   ├── theta/         # OAuth providers (Garmin, Whoop, etc.)
│   │   ├── apple/         # Apple Health platform
│   │   ├── core/          # Core health services
│   │   ├── file_parser/   # File processing handlers
│   │   └── router/        # API routes
│   ├── pub/                # Public tools and agents
│   │   ├── tools/         # General MCP tools
│   │   ├── tools_health/  # Health-specific MCP tools
│   │   ├── resources/     # MCP resources
│   │   └── agents/        # Agent implementations
│   ├── server/             # HTTP server
│   ├── user/               # Authentication
│   └── utils/              # Utilities
├── database/               # Database schemas and migrations
│   └── resource/          # SQL initialization files
├── compose.yaml           # Docker Compose configuration
├── config.yaml            # Base configuration (immutable)
├── config.localdb.yaml    # Your environment configuration
├── .env                   # Environment variables
├── main.py                # Application entry point
├── requirements.txt       # Python dependencies
├── package.json           # Node.js dependencies
└── run.sh                 # Deployment script

Key Directories

Chat service with agent orchestration, message history, and protocol adapters for HTTP (SSE) and WebSocket.
MCP protocol implementation with JSON-RPC 2.0 handler, tool/resource loading, and authentication.
Health data platform with OAuth providers, Apple Health integration, file processing, and data aggregation.
Public tools, resources, and agents that can be discovered via MCP. Add custom tools here.

Next Steps