MCP server exposing Apple Health, Location, and Activity data from a local Soma SQLite replica
Project description
soma-mcp
MCP server that exposes Apple Health, Location, and Activity data to AI agents.
Reads from a local SQLite replica maintained by the Soma Mac app. Designed for use with any MCP-compatible agent (Claude, ChatGPT, Cursor, etc.).
Consumer Setup
For end users, the Soma Mac app bundles soma-mcp and generates the correct MCP configuration automatically from the menu bar.
Development Quick Start
uvx soma-mcp --db ~/.soma/sensors.db
Agent Configuration
Claude Desktop / Claude Code
For development-only installs, add to your MCP config (~/.claude/claude_desktop_config.json or Claude Code settings):
{
"mcpServers": {
"soma": {
"command": "uvx",
"args": ["soma-mcp", "--db", "~/.soma/sensors.db"]
}
}
}
Any MCP Client
The server uses stdio transport. Spawn soma-mcp as a subprocess with the --db flag pointing to your Soma SQLite replica.
Tools
| Tool | Description |
|---|---|
get_user_location() |
Current GPS coordinates, address, and freshness metadata |
get_location_history(since?, limit?) |
Location time-series, newest first |
get_health_summary() |
Latest sample metrics + current activity + daily snapshots |
get_health_metric(metric, since?, limit?) |
Metric history with metric-aware routing |
get_health_metrics_list() |
Available metrics inventory with latest values |
get_user_activity() |
Current physical activity (stationary, walking, running, etc.) |
get_daily_summary(date?) |
Daily health rollup with cumulative and aggregate stats |
get_workouts(since?, limit?) |
Workout session history with type, duration, distance, calories |
query_sensor_data(sql, limit?) |
Read-only SQL against the local replica |
Health Metrics (49 across 6 kinds)
Hourly stats (17): steps, active_calories, basal_calories, distance_walking/cycling/swimming, workout_minutes, flights_climbed, dietary metrics (energy, water, caffeine, protein, carbs, fat, fiber, sugar, sodium)
Daily snapshots (2): stand_hours, sleep_duration
Sample events (20): heart_rate, resting_heart_rate, walking_heart_rate_avg, blood_oxygen, respiratory_rate, body composition (mass, fat %, BMI, lean mass, height, waist), hrv, vo2_max, body/wrist temperature, blood pressure, blood_glucose, environmental_audio, walking_steadiness
Category events (11): mindful_session, cardiac events (low/high HR, irregular rhythm), symptoms (headache, fatigue, nausea), reproductive health (menstrual_flow, cervical_mucus, ovulation_test, sexual_activity)
Activity: user_activity (stationary, walking, running, automotive, cycling, unknown)
Workouts: Full HKWorkout records with type, duration, distance, energy
Freshness Metadata
Every response includes freshness fields so agents can assess data recency:
recorded_at— when the sensor reading was takenupdated_at— when it was last applied to local SQLiteage_seconds— how old the reading isstale— boolean based on metric-specific thresholds
Requirements
- The Soma iOS app collecting sensor data on your iPhone
- The Soma Mac app replicating data to
~/.soma/sensors.db - Python 3.10+ (managed automatically by
uvx)
Changelog
0.2.0
Response field names normalized to snake_case for consistency with SQLite column names and Python conventions:
ageSeconds→age_secondsactivityLabel→activity_labellatestMetrics→latest_metrics
Backward compatibility: The old camelCase keys are emitted alongside the new snake_case keys as deprecated aliases. Both forms work in 0.2.x. The camelCase aliases will be removed in 0.3.0.
Added MCP tool annotations (readOnlyHint, idempotentHint) and server instructions for agent discovery. Error responses for invalid SQL now use MCP ToolError instead of raw exceptions.
0.1.0
Initial release with all 8 MCP tools.
Development
cd soma-mcp
pip install -e .
soma-mcp --db ~/.soma/sensors.db
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file soma_mcp-0.2.0.tar.gz.
File metadata
- Download URL: soma_mcp-0.2.0.tar.gz
- Upload date:
- Size: 88.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f3179e79ea6ebbba887e1330cc345f63e34fe5ba4122d0ae005a1e3301bbcaf
|
|
| MD5 |
fb70e314891e37b49ce7b5b8ec33746a
|
|
| BLAKE2b-256 |
6548d15c47a7f5d019510e88dc6882d4c1721a48f483988d261ff14f1ce3c865
|
File details
Details for the file soma_mcp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: soma_mcp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
819082f3cae5447bcbad98d4e5ec1c1a0eef9a54c7f7b27730f320292b8fd86a
|
|
| MD5 |
6a728981c08a2b0fd66e12e6fd53226a
|
|
| BLAKE2b-256 |
bdd8693b35c4b687d743cb3be215d3aa97adcdee37d3c7afdc5df2f85e59239f
|