deep_analysis
Deep Analysis: read-only SQLite SQL over a private copy of the user's full health history. Use for: questions spanning several data types (training with sleep, nutrition with weight); long or all-time horizons; trends, progress, period comparisons; totals, averages, rankings, correlations; anything focused tools would need many calls for; any request for a "deep analysis". For one recent fact (today's workout, last night's sleep), goals or profile use the focused tool. mode=discover: for tables or columns not listed below. topics -> matching tables with columns, units, row counts, dates; no topics -> table index. mode=query: one SELECT/WITH. period or date_from/date_to limits the copy (faster); omit for all history. Core tables, date = local day, main columns only (discover lists the rest): sleep_log: date, bedtime, wake_time, total_hours, sleep_score, deep_sleep_hours, rem_sleep_hours, light_sleep_hours, awakenings body_metrics: date, weight_lb, body_fat_pct, lean_mass_lb, fat_mass_lb, bmi, muscle_mass_lb, waist_in workout_sessions: id, date, started_at, activity_label, focus_type, duration_sec, calories, distance_mi, rpe daily_nutrition: date, total_calories, total_protein, total_fat, total_carbs (g), total_alcohol_kcal, meal_count wearable_daily: date, step_count, resting_hr_display, hrv_morning, active_calories_burned, total_calories_burned, stress_score, vo2max_estimate, spo2_avg_pct Every result carries calendar; the first also carries user_rules. Take relative dates from calendar or period, never your own math. Results list coverage per table (dates, rows, cuts): a short or empty result is not proof data is missing. Scope dates to the request. Joining sessions to sets repeats session values: aggregate each level alone, then join. Not every session is lifting: filter by activity for strength questions. An association is not a cause. Values stored in lb, mi, kcal, C: convert to user_rules units. Plain table names (wearable_daily, sleep_log, body_metrics, runs, food_log, hydration_entries) hold what the app counts; *_by_source hold raw per-source rows: never total those. Dates are YYYY-MM-DD. Timestamps are UTC: group and filter by local_date. glucose_readings_daily and hydration_entries_daily are per local day and source, for long ranges; if a copy is refused for size, query the _daily table or narrow the dates. Helpers: median(x), percentile(x,p), stddev(x) (NULL under 3 values), corr(x,y) (NULL under 8 pairs), corr_n(x,y) (pairs used), week_start(date[,dow 0=Sun 1=Mon]), month_start(date). Report n with any statistic.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"mode": "<mode>"
},
"name": "deep_analysis"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | No | query: one SELECT or WITH statement. | |
| mode | Yes | See mode= lines above. | |
| period | No | query: a named calendar period, resolved by the server; sets the dates copied. | |
| topics | No | discover: subjects or table names, e.g. ["sleep","resting heart rate"]. | |
| date_to | No | query: last date to copy, YYYY-MM-DD. | |
| purpose | No | query: what this answers, a few words. | |
| date_from | No | query: first date to copy, YYYY-MM-DD. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes | Human-readable result text returned by the tool. |