A macOS CLI & MCP server for Apple HealthKit - enabling AI agents to read and write health data.
- Read Health Data: Steps, heart rate, workouts, activity rings, weight, blood glucose, and more
- Write Health Data: Record measurements, workouts, and health samples
- Query & Statistics: Get aggregated stats, trends, and historical data
- MCP Server: Expose HealthKit to AI agents via Model Context Protocol
- macOS 26+ (Tahoe)
- Swift 6.2+
- HealthKit available on the device
cd ~/Developer/Vitalink
swift build -c release
# Copy to PATH (optional)
cp .build/release/vitalink /usr/local/bin/IMPORTANT: HealthKit requires the binary to be code-signed with a valid Apple Developer certificate. Without proper signing, macOS will terminate the process immediately (SIGKILL / exit code 137).
- Apple Developer account (free or paid)
- Valid code signing certificate installed in Keychain
- Xcode installed (for certificate management)
security find-identity -v -p codesigningLook for a certificate like Apple Development: Your Name (TEAMID).
# Build release
swift build -c release
# Sign with your certificate and entitlements
codesign --force --sign "Apple Development: Your Name (TEAMID)" \
--entitlements Resources/Vitalink.entitlements \
--options runtime \
.build/release/vitalink
# Verify signing
codesign -dvvv .build/release/vitalinkOn first run, macOS will prompt for HealthKit authorization. You can also grant access in System Settings → Privacy & Security → Health.
- Exit code 137: Binary is not properly signed. Re-sign with valid certificate.
- "No identity found": No developer certificate installed. Open Xcode → Settings → Accounts → Manage Certificates.
- HealthKit not available: Running on unsupported Mac or VM. HealthKit requires real Mac hardware.
vitalink statusvitalink authorize # Full read/write access
vitalink authorize --read-only # Read-only access# Steps
vitalink read steps --from 7d --to now
# Heart Rate
vitalink read heart-rate --from 1d --json
# Workouts
vitalink read workouts --from 30d --activity-type running
# Activity Summary (Apple Watch rings)
vitalink read activity --date today
# Any quantity type
vitalink read quantity weight --from 30d# Record weight
vitalink write quantity weight 75.5
# Record blood glucose
vitalink write quantity blood_glucose 95 --unit mg/dl
# Log a workout
vitalink write workout running \
--start "2025-01-05T07:00:00" \
--end "2025-01-05T07:30:00" \
--calories 300 \
--distance 5000# Get stats for steps over the last week
vitalink query stats steps --from 7d
# Get daily trends for heart rate
vitalink query trends heart_rate --from 30d --interval dayStart the MCP server for AI agent integration:
vitalink mcp serveList available tools:
vitalink mcp tools --jsonAdd to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"vitalink": {
"command": "/path/to/vitalink",
"args": ["mcp", "serve"]
}
}
}# Install mcpli
bun install -g mcpli
# Test MCP server
mcpli --help -- /path/to/vitalink mcp serve
# Call a specific tool
mcpli health_status -- /path/to/vitalink mcp serve- ISO8601:
2025-01-05T10:30:00Z,2025-01-05 - Relative:
1d(1 day ago),7d,1w(1 week),1m(1 month) - Keywords:
now,today
| Type | CLI Name | Description |
|---|---|---|
| Steps | steps |
Daily step count |
| Heart Rate | heart_rate |
Heart rate in BPM |
| Active Energy | active_energy |
Active calories burned |
| Basal Energy | basal_energy |
Resting calories |
| Distance | distance |
Walking/running distance |
| Weight | weight |
Body mass |
| Height | height |
Body height |
| Body Temperature | body_temperature |
Temperature readings |
| Blood Pressure | blood_pressure_systolic/diastolic |
BP measurements |
| Blood Glucose | blood_glucose |
Glucose levels |
| Oxygen Saturation | oxygen_saturation |
SpO2 readings |
| Respiratory Rate | respiratory_rate |
Breathing rate |
| Tool | Description |
|---|---|
health_status |
Check HealthKit availability |
health_authorize |
Request health data access |
health_read_steps |
Read step count data |
health_read_heart_rate |
Read heart rate samples |
health_read_workouts |
Read workout history |
health_read_activity |
Read activity summary (rings) |
health_read_quantity |
Read any quantity type |
health_query_stats |
Get statistics for data type |
health_write_quantity |
Write health measurement |
health_write_workout |
Record a workout |
Vitalink/
├── Package.swift
├── Sources/
│ ├── VitalinkCLI/
│ │ ├── Commands/
│ │ │ ├── Vitalink.swift # Main command
│ │ │ ├── AuthorizeCommand.swift
│ │ │ ├── ReadCommand.swift
│ │ │ ├── WriteCommand.swift
│ │ │ ├── QueryCommand.swift
│ │ │ ├── StatusCommand.swift
│ │ │ └── MCPCommand.swift
│ │ ├── Services/
│ │ │ ├── HealthKitService.swift
│ │ │ └── DataTypes.swift
│ │ └── MCP/
│ │ └── VitalinkMCPServer.swift
│ └── VitalinkExec/
│ └── main.swift
└── Resources/
├── Vitalink.entitlements
└── Info.plist
MIT