Skip to main content
Glama

Get Sleep

get_sleep
Read-only

Retrieve sleep data by date range at aggregate, cycle, or stage detail to answer questions about sleep totals, sessions, or full hypnograms.

Instructions

Return the user's sleep data at a chosen level of detail.

Pick the coarsest level that answers the question — results grow with detail:

  • "aggregate": stage totals per period (default 1 day), one row per period per stage. Best for multi-day questions ("how did I sleep this month").

  • "cycles": one row per sleep session.

  • "stages": every stage interval (the full hypnogram); single-night detail.

Sleep spans midnight (starts day N, ends day N+1) — extend the time range accordingly. Stage integers: 0=In Bed, 1=Asleep/Unknown, 2=Awake, 3=Light, 4=Deep, 5=REM. Result timestamps include time zones; translate them to the user's local time zone when known.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNo"aggregate" only. Assign by "start", "end" or "split" (default "end").
levelNoLevel of detail (see above).cycles
periodNo"aggregate" level only. Period length, e.g. "1d", "1w" (default "1d").
stagesNoStage integers to include (default: all).
end_timeYesRange end (exclusive). Must include tz (ISO8601).
cycle_gapNoMinimum interval separating distinct cycles (e.g. "PT2H").
time_zoneNo"aggregate" only. IANA tz for period bounds; use the user's local one.
gap_stagesNoStage integers treated as gaps between cycles.
start_timeYesRange start (inclusive). Must include tz (ISO8601).
agg_functionsNo"aggregate" level only. E.g. "sum", "mean" (default ["sum"]).
clip_to_rangeNoClip results to the requested range (default True).
merge_contiguousNo"stages" level only. Merge adjacent same-stage samples (default True).
merge_overlappingNo"stages" level only. Merge overlapping stages (default True).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.1.0

TDQS

A4.7/5.0
Behavior5/5

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

The readOnlyHint annotation only establishes safety; the description adds substantial behavioral context the annotation cannot: results grow with detail level, sleep sessions cross midnight, stage integers decode to specific sleep states, and returned timestamps carry time zones that should be translated to the user's local zone. This is exactly the added value a description should provide.

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

Conciseness5/5

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

The level-selection rule is front-loaded, the three modes are a tight bulleted list, and the trailing caveats about midnight-spanning ranges, stage integers and time zones are each a single clause. No filler sentences.

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

Completeness5/5

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

With 13 parameters and an output schema present, the description supplies the pieces the schema cannot: level-selection heuristics, the midnight boundary caveat, and the stage-code legend. Return values need not be described since an output schema exists, and the remaining params are documented in the schema.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description goes beyond the schema by defining the stage integer encoding (0=In Bed ... 5=REM) and by explaining the semantics of the level options, which the schema only gestures at with "see above". It does not clarify the more obscure params (cycle_gap, gap_stages, merge_*), keeping it from a 5.

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

Purpose5/5

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

"Return the user's sleep data at a chosen level of detail" is a specific verb+resource, and the three level options (aggregate/cycles/stages) carve out a clear domain distinct from siblings like get_workouts, get_records, and get_time_series. An agent can tell what this returns and at what granularity without opening the schema.

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

Usage Guidelines4/5

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

It gives real routing guidance ("Pick the coarsest level that answers the question") plus concrete best-for examples such as multi-day vs single-night questions, and it warns that sleep spans midnight so the range must be extended. It stops short of naming when to prefer a sibling tool (e.g. get_time_series) for non-sleep data, so no explicit exclusion criteria.

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