Skip to main content
Glama
ios_shortcut.md3.98 kB
# iOS Shortcut Setup for HealthKit MCP\n\nThis guide walks you through creating an iOS Shortcut to sync your Apple Health workouts to the HealthKit MCP.\n\n## Prerequisites\n\n- iPhone with iOS 16+\n- Apple Watch (optional, for workout HR data)\n- HealthKit MCP deployed on Railway\n\n## Creating the Shortcut\n\n### Step 1: Open Shortcuts App\n\nOpen the **Shortcuts** app on your iPhone.\n\n### Step 2: Create New Shortcut\n\n1. Tap **+** to create a new shortcut\n2. Name it **"Sync Workouts to Kaffer"**\n\n### Step 3: Add HealthKit Query\n\n1. Add action: **Find Health Samples**\n2. Set Type: **Workouts**\n3. Set Filter: **Start Date is in the last 7 days**\n4. Sort by: **Start Date (Latest First)**\n5. Limit: **50** (or adjust as needed)\n\n### Step 4: Build JSON Payload\n\n1. Add action: **Repeat with Each** (input: Health Samples)\n2. Inside the repeat, add **Text** action with this template:\n\n```json\n{\n "type": "[Repeat Item - Workout Activity Type]",\n "start": "[Repeat Item - Start Date]",\n "end": "[Repeat Item - End Date]",\n "duration_minutes": [Repeat Item - Duration (minutes)],\n "calories": [Repeat Item - Active Energy (kcal)],\n "distance_miles": [Repeat Item - Distance (mi)],\n "source": "[Repeat Item - Source Name]"\n}\n```\n\n3. Add **Add to Variable** action, variable name: `workoutsList`\n\n### Step 5: Create Final JSON\n\nAfter the repeat loop:\n\n1. Add **Text** action:\n```json\n{\n "workouts": [Variable: workoutsList],\n "device": "iPhone",\n "sync_timestamp": "[Current Date - ISO 8601]"\n}\n```\n\n### Step 6: Send to Server\n\n1. Add **Get Contents of URL** action\n2. URL: `https://healthkit-mcp-production.up.railway.app/ingest/workouts`\n3. Method: **POST**\n4. Headers:\n - `Content-Type`: `application/json`\n - `X-API-Key`: `[Your API Key]` (if configured)\n5. Request Body: **File** → select the Text from Step 5\n\n### Step 7: Show Result (Optional)\n\n1. Add **Show Result** action to see the server response\n\n## Automation Setup\n\n### Daily Sync\n\n1. Go to **Automations** tab in Shortcuts\n2. Tap **+** → **Create Personal Automation**\n3. Choose **Time of Day** → 9:00 PM (or your preference)\n4. Add **Run Shortcut** action → select "Sync Workouts to Kaffer"\n5. Disable **Ask Before Running**\n\n### Manual Sync\n\nYou can also:\n- Add the shortcut to your Home Screen\n- Run it via Siri: "Hey Siri, sync workouts to Kaffer"\n- Add to widget\n\n## Troubleshooting\n\n### No workouts found\n- Check HealthKit permissions for Shortcuts app\n- Verify workouts exist in the Health app for the date range\n\n### Server error\n- Check the Railway deployment logs\n- Verify the URL is correct\n- Check API key if configured\n\n### Duplicate workouts\n- The server deduplicates by (type + start time)\n- Re-running the shortcut won't create duplicates\n\n## Sample Workout Types from HealthKit\n\n| HealthKit Type | Display Name |\n|---------------|--------------|\n| `HKWorkoutActivityTypeFunctionalStrengthTraining` | Functional Training |\n| `HKWorkoutActivityTypeGolf` | Golf |\n| `HKWorkoutActivityTypeYoga` | Yoga |\n| `HKWorkoutActivityTypeRunning` | Running |\n| `HKWorkoutActivityTypeRowing` | Rowing |\n| `HKWorkoutActivityTypeWalking` | Walking |\n| `HKWorkoutActivityTypeCycling` | Cycling |\n| `HKWorkoutActivityTypeSwimming` | Swimming |\n| `HKWorkoutActivityTypeHighIntensityIntervalTraining` | HIIT |\n| `HKWorkoutActivityTypeTraditionalStrengthTraining` | Strength Training |\n\n## Testing\n\nTest with curl:\n\n```bash\ncurl -X POST https://healthkit-mcp-production.up.railway.app/ingest/workouts \\\n -H "Content-Type: application/json" \\\n -d '{\n "workouts": [{\n "type": "Functional Training",\n "start": "2025-12-06T08:30:00-08:00",\n "end": "2025-12-06T09:15:00-08:00",\n "duration_minutes": 45,\n "calories": 350,\n "source": "Apple Watch"\n }],\n "device": "Test",\n "sync_timestamp": "2025-12-06T21:00:00-08:00"\n }'\n```\n

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Orchid1970/healthkit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server