Skip to main content
Glama

query_health

Retrieve Garmin health metrics like heart rate, sleep, stress, and body battery for a specific field across a date range, with daily or intraday resolution.

Instructions

Query Garmin health data (e.g. heart rate, sleep, stress, body battery) for a field over a date range. resolution is "daily" or "intraday" — most fields only support one of the two (e.g. resting_heart_rate is daily-only, heart_rate_series is intraday-only); pass the field name that matches what you want, see list_available_fields() for the full list. This parameter is accepted for forward compatibility but not currently used to pick between two resolutions of the same field, since no field in this archive currently offers both — each field's own stored resolution already determines whether the answer is a single daily value or a full timeseries.

v1.7.1.1 field-filter fix (2026-08-28 session): field is now passed through to the SQLite branch — previously it was silently dropped, so every call returned all ~26 health fields regardless of what was asked for, including this archive's intraday *_series fields (full day-long timeseries), inflating a single-value answer to hundreds of KB and confusing small local LLMs summarizing the result.

v1.7.1.6 unit field: every field in the returned result now carries a "unit" key alongside "values"/"fallback"/ "source_resolution" — see FIELD_UNITS in mcp_field_registry.py. Applied AFTER the routing weiche below, so it covers both branches identically (today, only the SQLite branch is ever actually taken — see _route_query()'s docstring).

v1.7.1.9 unknown-field detection (this session): mirrors query_context()'s v1.7.1.4 fix, applied here with a delayed session (see that function's docstring for the original rationale -- a valid-but-dataless field and an unregistered field previously returned the identical silent {"health": {}}, leaving the caller unable to tell the two apart). Checked BEFORE the _route_query() switch below, so it applies regardless of which branch (sqlite/ live) ends up serving the request -- the field registry itself (mcp_map.list_available_fields) is unrelated to that routing decision.

Three unknown-field outcomes, checked in this order:

  1. Unambiguous near-match against the known health field names (e.g. a typo) -> auto-resolved, field_used replaces the caller's input transparently, but the substitution is always visible via _meta.field_resolved_from / _meta.field_used — never a silent rewrite.

  2. The field IS registered, but under query_context's domain, not query_health's (e.g. "temperature_max") -> a domain-specific error naming query_context, no did_you_mean list (a health-domain suggestion would be wrong here).

  3. Neither of the above (no close match, and not a query_context field either) -> a generic "unknown field" error, with a did_you_mean suggestion list when difflib found any candidates, without one when it found none.

A valid field's result (with or without data in range) is returned exactly as before this session — none of the above runs unless field is unrecognized.

Deliberately NOT addressed here (see AKTIONSPLAN_v1.7.1.9_ health_fallback.md Abschnitt 3/4 for the full analysis): a model that picks a completely unrelated but real, registered field instead of a near-match typo (verified empirically against the 2026-09-05 test run's Hermes3 cases, e.g. resting_heart_rate returned for a steps question) is not a field-registry problem — no near-match exists for the fallback to catch, since the wrong field is itself a valid, unrelated field name. Tracked as a parking-lot item (query_health docstring example-field guidance), not pulled into this fix.

v1.7.1.9 Session 2 -- sleep_score fan-out: "sleep_score" is itself an already-valid, registered field (unlike the alias candidates below), so it would never reach the unknown-field checks above -- it always short-circuits straight to the normal valid-field path. Checked here, BEFORE the bundle check, precisely because it is valid and would otherwise never trigger any of the outcomes below. Fans out to the two closely related fields sleep_score_feedback and sleep_score_qualifier and returns all three together in the same {"garmin": {field: {...}}} shape a normal multi-field result already has -- no new result shape, _enrich_with_units() handles it unchanged. _meta.field_resolved_from is set to "sleep_score" so the fan-out is visible; no field_used, since all three delivered field names are already the dict's own keys, unlike the 1:1 alias case where the substitution would otherwise be invisible. A direct call to "sleep_score_feedback" or "sleep_score_qualifier" is NOT affected -- only the exact bare "sleep_score" triggers this.

v1.7.1.9 Session 2 -- short-form alias mapping: three short-form field names (steps, hrv, hill) sit far enough below any workable difflib cutoff against their real target field names (steps_series, hrv_last_night, hill_score -- confirmed down to cutoff=0.7, see NOTES_v1.7.1.9.md Session 2) that no cutoff tuning can catch them without introducing new ambiguities elsewhere. HEALTH_FIELD_ALIASES below resolves these explicitly, checked before outcome 1's near-match logic (an alias hit is more certain than a near-match and should not have to pass through it). "spo2" was considered and explicitly excluded (real collision between spo2_avg and spo2_series, no reliable disambiguation signal available -- see NOTES_v1.7.1.9.md Session 2 for the full analysis).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldYes
date_toYes
date_fromYes
resolutionNodaily

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, and it actually discloses meaningful behavior: transparent typo auto-resolution surfaced via _meta.field_resolved_from, three distinct unknown-field error outcomes with did_you_mean behavior, the sleep_score fan-out and its _meta marker, and the 'unit' key added to every returned field. Deeper operational traits (auth, limits, date formats, payload size bounds) remain unstated, but the error-handling disclosure is unusually rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The vast majority of the text is an internal changelog: version numbers (v1.7.1.1, v1.7.1.6, v1.7.1.9), session dates, source file and function names, and references to markdown planning documents. Only the first paragraph and the sleep_score/alias paragraphs serve the calling agent; the rest does not earn its place and pushes critical guidance far from the front.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter, no-output-schema, no-annotation tool, the description covers error behavior and the multi-field result shape ({'garmin': {field: {...}}}) well enough that an agent knows what comes back. It still omits practical invocation basics — date string format, maximum range, and expected response size — which matter more here than the retained release history.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate. It does explain the resolution parameter in depth (daily vs intraday, per-field restrictions, and that it is currently a no-op for routing) and the semantics of valid/aliased/unknown field values. But date_from and date_to — two of three required parameters — are given no format, range, or inclusivity guidance at all.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence gives a specific verb, resource and scope ('Query Garmin health data ... for a field over a date range') with concrete field examples, and it explicitly separates this domain from query_context's domain. However, the purpose is buried under version-history noise, and the distinction from sibling tools like query_fit_activities or query_raw is never stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It tells the caller to pass a field name matching the desired resolution and to consult list_available_fields(), and it implies query_context is the tool for other domains. But there is no explicit statement of when to choose query_health over query_fit_activities/query_raw/query_context, and no prerequisites or exclusions beyond the routing aside.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.