Skip to main content
Glama

Multi-day Trends

apple_health_trends

Analyze daily health trends from Apple Health data to track metrics like steps, heart rate, sleep, and weight over time.

Instructions

Get daily health metrics for a date range (steps, HR, HRV, sleep, weight)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoNumber of days to look back (default 7)

Implementation Reference

  • The 'apple_health_trends' tool is registered and implemented in src/mcp.ts. It calculates daily health metrics (steps, active energy, resting heart rate, HRV, sleep, and weight) over a specified number of days.
    server.registerTool("apple_health_trends", {
      title: "Multi-day Trends",
      description: "Get daily health metrics for a date range (steps, HR, HRV, sleep, weight)",
      inputSchema: z.object({
        days: z.number().optional().describe("Number of days to look back (default 7)"),
      }),
    }, async ({ days }) => {
      const n = days ?? 7;
      const results: Array<Record<string, unknown>> = [];
    
      for (let i = n - 1; i >= 0; i--) {
        const dt = new Date();
        dt.setDate(dt.getDate() - i);
        const d = dt.toISOString().split("T")[0];
        const metrics = parseMetrics(d);
        if (metrics) {
          const rhr = avg(metrics.resting_hr);
          const hrv = avg(metrics.hrv);
          results.push({
            date: d,
            steps: Math.round(metrics.steps),
            active_energy: Math.round(metrics.active_energy),
            resting_hr: rhr ? Math.round(rhr) : null,
            hrv: hrv ? Math.round(hrv) : null,
            sleep_total_hrs: +metrics.sleep_total.toFixed(1),
            weight: avg(metrics.weight),
          });
        }
      }
    
      return text(results);
    });
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses what metrics are returned (steps, HR, HRV, sleep, weight) which is valuable behavioral context. However, it lacks information on data availability (what happens if no data exists?), whether this is read-only (implied but not stated), or rate limits.

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

Conciseness4/5

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

The description consists of a single efficient sentence with no wasted words. The parenthetical list of metrics is compact and informative. It could benefit from a second sentence addressing sibling differentiation, but as written it is appropriately sized.

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?

Given the low complexity (one optional parameter, no nested objects) and lack of output schema, the description adequately compensates by enumerating the specific health metrics returned. However, for a data-retrieval tool with no annotations, it should confirm the read-only nature and mention any data availability constraints.

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 description coverage is 100% for the single 'days' parameter, establishing a baseline of 3. The description adds minimal meaning beyond the schema for the parameter itself, though the phrase 'date range' contextualizes the 'days' parameter appropriately.

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 description uses a specific verb ('Get') and resource ('daily health metrics'), and scopes the output with specific examples (steps, HR, HRV, sleep, weight). It implicitly distinguishes from sibling 'apple_health_daily' by specifying 'date range' versus implied single-day scope, though it doesn't explicitly name siblings.

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?

Usage is implied by the tool name ('trends'), the parameter ('days' to look back), and the phrase 'date range,' suggesting multi-day analysis. However, there is no explicit guidance on when to select trends versus daily snapshots or workout-specific data.

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

Install Server

Other Tools

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/daveremy/apple-health-mcp'

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