Skip to main content
Glama
Thecimal

Quantified Self MCP Server

Calculate metric trend

calculate_metric_trend
Read-onlyIdempotent

Analyze if a health or finance metric is trending up, down, or flat over a date range by fitting a straight line and reporting slope and r-squared.

Instructions

Fit a simple straight-line trend to one metric over a window and report its direction, slope (change per day), and r_squared (how well a straight line actually fits — low r_squared means "noisy," not "flat").

Use this tool when:

  • the user asks whether one metric is trending up/down/flat over a continuous window (e.g. "is my weight trending down?", "how has my HRV changed?").

Do not use this tool when:

  • the user wants two specific, separately-defined ranges compared (e.g. "this month vs last month") rather than a single continuous slope -> use compare_metric_periods instead.

  • the user asks what's typical/normal rather than which direction it's moving -> use get_baseline instead.

  • the user asks about isolated unusual days rather than an overall direction -> use detect_metric_anomalies instead.

Privacy note: this server and its SQLite file are entirely local, but the data returned by this tool becomes part of the conversation sent to whatever model the calling client is configured with. If that model runs in the cloud rather than on your machine, treat this the same as pasting the data into a chat with that provider.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metricYesOne of steps, sleep_hours, resting_heart_rate, weight_kg, workout_minutes, mood, water_ml, heart_rate, hrv_ms.
end_dateNoLast day to include, formatted YYYY-MM-DD. Defaults to today.
start_dateNoFirst day to include, formatted YYYY-MM-DD. Defaults to 30 days before end_date.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
claimYesEvidence and decision for the trend claim; read claim.decision before reporting it.
rangeYes
trendYes
metricYes
evidenceYesDEPRECATED: identical to claim.evidence. Use claim.decision, not evidence.confidence.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.0.28
    • removedOutput schema / properties / claim_decision
      Removed value: -{
      -  "deprecated": true,
      -  "description": "DEPRECATED: identical to claim.decision. Use claim.decision instead.",
      -  "properties": {
      -    "must_state": {
      -      "items": {
      -        "type": "string"
      -      },
      -      "type": "array"
      -    },
      -    "permitted_phrasing_class": {
      -      "type": "string"
      -    },
      -    "template": {
      -      "type": "string"
      -    },
      -    "tier": {
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "tier",
      -    "permitted_phrasing_class",
      -    "must_state",
      -    "template"
      -  ],
      -  "type": "object"
      -}
    • removedOutput schema / properties / evidence_profile
      Removed value: -{
      -  "deprecated": true,
      -  "description": "DEPRECATED: identical to claim.profile. Use claim.decision instead.",
      -  "properties": {
      -    "analysis": {
      -      "type": "string"
      -    },
      -    "dimensions": {
      -      "items": {
      -        "properties": {
      -          "can_block": {
      -            "default": true,
      -            "type": "boolean"
      -          },
      -          "details": {
      -            "additionalProperties": true,
      -            "type": "object"
      -          },
      -          "dimension": {
      -            "enum": [
      -              "sample",
      -              "temporal",
      -              "robustness",
      -              "missingness",
      -              "practical",
      -              "measurement_validity",
      -              "provenance"
      -            ],
      -            "type": "string"
      -          },
      -          "reason_codes": {
      -            "items": {
      -              "type": "string"
      -            },
      -            "type": "array"
      -          },
      -          "status": {
      -            "enum": [
      -              "adequate",
      -              "negligible",
      -              "not_assessed",
      -              "weak",
      -              "concern",
      -              "blocking"
      -            ],
      -            "type": "string"
      -          }
      -        },
      -        "required": [
      -          "dimension",
      -          "status"
      -        ],
      -        "type": "object"
      -      },
      -      "type": "array"
      -    },
      -    "effect": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "metric": {
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "metric",
      -    "analysis",
      -    "dimensions"
      -  ],
      -  "type": "object"
      -}
    • changedOutput schema / required
      Previous value: -[
      -  "metric",
      -  "range",
      -  "trend",
      -  "claim",
      -  "evidence",
      -  "evidence_profile",
      -  "claim_decision"
      -]New value: +[
      +  "metric",
      +  "range",
      +  "trend",
      +  "claim",
      +  "evidence"
      +]
  2. Changed8 schema fields changedv1.0.26
    • addedOutput schema / properties / claim
      Added value: +{
      +  "description": "Evidence and decision for the trend claim; read claim.decision before reporting it.",
      +  "properties": {
      +    "decision": {
      +      "description": "How strongly this claim may be stated. tier is insufficient, suggestive, detectable_not_meaningful or supported; every entry in must_state has to be mentioned when reporting it.",
      +      "properties": {
      +        "must_state": {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        "permitted_phrasing_class": {
      +          "type": "string"
      +        },
      +        "template": {
      +          "type": "string"
      +        },
      +        "tier": {
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "tier",
      +        "permitted_phrasing_class",
      +        "must_state",
      +        "template"
      +      ],
      +      "type": "object"
      +    },
      +    "evidence": {
      +      "description": "Descriptive data coverage behind this claim.",
      +      "properties": {
      +        "confidence": {
      +          "type": "string"
      +        },
      +        "coverage_ratio": {
      +          "type": "number"
      +        },
      +        "expected_days": {
      +          "type": "integer"
      +        },
      +        "freshness_days": {
      +          "anyOf": [
      +            {
      +              "type": "integer"
      +            },
      +            {
      +              "type": "null"
      +            }
      +          ],
      +          "default": null
      +        },
      +        "gaps": {
      +          "items": {
      +            "properties": {
      +              "days": {
      +                "type": "integer"
      +              },
      +              "end": {
      +                "type": "string"
      +              },
      +              "start": {
      +                "type": "string"
      +              }
      +            },
      +            "required": [
      +              "start",
      +              "end",
      +              "days"
      +            ],
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "measurement_count": {
      +          "type": "integer"
      +        },
      +        "missing_days": {
      +          "type": "integer"
      +        },
      +        "observed_days": {
      +          "type": "integer"
      +        },
      +        "observed_end": {
      +          "anyOf": [
      +            {
      +              "type": "string"
      +            },
      +            {
      +              "type": "null"
      +            }
      +          ],
      +          "default": null
      +        },
      +        "observed_start": {
      +          "anyOf": [
      +            {
      +              "type": "string"
      +            },
      +            {
      +              "type": "null"
      +            }
      +          ],
      +          "default": null
      +        },
      +        "recent_gap_days": {
      +          "type": "integer"
      +        },
      +        "requested_end": {
      +          "type": "string"
      +        },
      +        "requested_start": {
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "requested_start",
      +        "requested_end",
      +        "expected_days",
      +        "observed_days",
      +        "coverage_ratio",
      +        "missing_days",
      +        "measurement_count",
      +        "gaps",
      +        "recent_gap_days",
      +        "confidence"
      +      ],
      +      "type": "object"
      +    },
      +    "profile": {
      +      "description": "Per-dimension evidence quality behind this claim (sample, temporal, missingness, ...). Dimensions without an evaluator yet are 'not_assessed' and cap the claim, never count as adequate.",
      +      "properties": {
      +        "analysis": {
      +          "type": "string"
      +        },
      +        "dimensions": {
      +          "items": {
      +            "properties": {
      +              "can_block": {
      +                "default": true,
      +                "type": "boolean"
      +              },
      +              "details": {
      +                "additionalProperties": true,
      +                "type": "object"
      +              },
      +              "dimension": {
      +                "enum": [
      +                  "sample",
      +                  "temporal",
      +                  "robustness",
      +                  "missingness",
      +                  "practical",
      +                  "measurement_validity",
      +                  "provenance"
      +                ],
      +                "type": "string"
      +              },
      +              "reason_codes": {
      +                "items": {
      +                  "type": "string"
      +                },
      +                "type": "array"
      +              },
      +              "status": {
      +                "enum": [
      +                  "adequate",
      +                  "negligible",
      +                  "not_assessed",
      +                  "weak",
      +                  "concern",
      +                  "blocking"
      +                ],
      +                "type": "string"
      +              }
      +            },
      +            "required": [
      +              "dimension",
      +              "status"
      +            ],
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "effect": {
      +          "additionalProperties": true,
      +          "type": "object"
      +        },
      +        "metric": {
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "metric",
      +        "analysis",
      +        "dimensions"
      +      ],
      +      "type": "object"
      +    }
      +  },
      +  "required": [
      +    "evidence",
      +    "profile",
      +    "decision"
      +  ],
      +  "type": "object"
      +}
    • addedOutput schema / properties / claim_decision / deprecated
      Added value: +true
    • changedOutput schema / properties / claim_decision / description
      Previous value: -"How strongly this result may be stated. tier is insufficient, suggestive, detectable_not_meaningful or supported; every entry in must_state has to be mentioned when reporting it."New value: +"DEPRECATED: identical to claim.decision. Use claim.decision instead."
    • addedOutput schema / properties / evidence / deprecated
      Added value: +true
    • changedOutput schema / properties / evidence / description
      Previous value: -"Coverage/quality of the data a single-metric analytical result is\nbased on. See evidence.build_evidence for how each field is computed."New value: +"DEPRECATED: identical to claim.evidence. Use claim.decision, not evidence.confidence."
    • addedOutput schema / properties / evidence_profile / deprecated
      Added value: +true
    • changedOutput schema / properties / evidence_profile / description
      Previous value: -"Per-dimension evidence quality behind this result (sample, temporal, missingness, ...). Dimensions without an evaluator yet are 'not_assessed' and cap the claim, never count as adequate."New value: +"DEPRECATED: identical to claim.profile. Use claim.decision instead."
    • changedOutput schema / required
      Previous value: -[
      -  "evidence_profile",
      -  "claim_decision",
      -  "metric",
      -  "range",
      -  "trend",
      -  "evidence"
      -]New value: +[
      +  "metric",
      +  "range",
      +  "trend",
      +  "claim",
      +  "evidence",
      +  "evidence_profile",
      +  "claim_decision"
      +]
  3. Changed11 schema fields changedv1.0.23
    • removedOutput schema / properties / claim_decision / anyOf
      Removed value: -[
      -  {
      -    "properties": {
      -      "must_state": {
      -        "items": {
      -          "type": "string"
      -        },
      -        "type": "array"
      -      },
      -      "permitted_phrasing_class": {
      -        "type": "string"
      -      },
      -      "template": {
      -        "type": "string"
      -      },
      -      "tier": {
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "tier",
      -      "permitted_phrasing_class",
      -      "must_state",
      -      "template"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • removedOutput schema / properties / claim_decision / default
      Removed value: -null
    • addedOutput schema / properties / claim_decision / properties
      Added value: +{
      +  "must_state": {
      +    "items": {
      +      "type": "string"
      +    },
      +    "type": "array"
      +  },
      +  "permitted_phrasing_class": {
      +    "type": "string"
      +  },
      +  "template": {
      +    "type": "string"
      +  },
      +  "tier": {
      +    "type": "string"
      +  }
      +}
    • addedOutput schema / properties / claim_decision / required
      Added value: +[
      +  "tier",
      +  "permitted_phrasing_class",
      +  "must_state",
      +  "template"
      +]
    • addedOutput schema / properties / claim_decision / type
      Added value: +"object"
    • removedOutput schema / properties / evidence_profile / anyOf
      Removed value: -[
      -  {
      -    "properties": {
      -      "analysis": {
      -        "type": "string"
      -      },
      -      "dimensions": {
      -        "items": {
      -          "properties": {
      -            "can_block": {
      -              "default": true,
      -              "type": "boolean"
      -            },
      -            "details": {
      -              "additionalProperties": true,
      -              "type": "object"
      -            },
      -            "dimension": {
      -              "enum": [
      -                "sample",
      -                "temporal",
      -                "robustness",
      -                "missingness",
      -                "practical",
      -                "measurement_validity",
      -                "provenance"
      -              ],
      -              "type": "string"
      -            },
      -            "reason_codes": {
      -              "items": {
      -                "type": "string"
      -              },
      -              "type": "array"
      -            },
      -            "status": {
      -              "enum": [
      -                "adequate",
      -                "negligible",
      -                "not_assessed",
      -                "weak",
      -                "concern",
      -                "blocking"
      -              ],
      -              "type": "string"
      -            }
      -          },
      -          "required": [
      -            "dimension",
      -            "status"
      -          ],
      -          "type": "object"
      -        },
      -        "type": "array"
      -      },
      -      "effect": {
      -        "additionalProperties": true,
      -        "type": "object"
      -      },
      -      "metric": {
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "metric",
      -      "analysis",
      -      "dimensions"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • removedOutput schema / properties / evidence_profile / default
      Removed value: -null
    • addedOutput schema / properties / evidence_profile / properties
      Added value: +{
      +  "analysis": {
      +    "type": "string"
      +  },
      +  "dimensions": {
      +    "items": {
      +      "properties": {
      +        "can_block": {
      +          "default": true,
      +          "type": "boolean"
      +        },
      +        "details": {
      +          "additionalProperties": true,
      +          "type": "object"
      +        },
      +        "dimension": {
      +          "enum": [
      +            "sample",
      +            "temporal",
      +            "robustness",
      +            "missingness",
      +            "practical",
      +            "measurement_validity",
      +            "provenance"
      +          ],
      +          "type": "string"
      +        },
      +        "reason_codes": {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        "status": {
      +          "enum": [
      +            "adequate",
      +            "negligible",
      +            "not_assessed",
      +            "weak",
      +            "concern",
      +            "blocking"
      +          ],
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "dimension",
      +        "status"
      +      ],
      +      "type": "object"
      +    },
      +    "type": "array"
      +  },
      +  "effect": {
      +    "additionalProperties": true,
      +    "type": "object"
      +  },
      +  "metric": {
      +    "type": "string"
      +  }
      +}
    • addedOutput schema / properties / evidence_profile / required
      Added value: +[
      +  "metric",
      +  "analysis",
      +  "dimensions"
      +]
    • addedOutput schema / properties / evidence_profile / type
      Added value: +"object"
    • changedOutput schema / required
      Previous value: -[
      -  "metric",
      -  "range",
      -  "trend",
      -  "evidence"
      -]New value: +[
      +  "evidence_profile",
      +  "claim_decision",
      +  "metric",
      +  "range",
      +  "trend",
      +  "evidence"
      +]
  4. Changed2 schema fields changedv1.0.20
    • addedOutput schema / properties / claim_decision
      Added value: +{
      +  "anyOf": [
      +    {
      +      "properties": {
      +        "must_state": {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        "permitted_phrasing_class": {
      +          "type": "string"
      +        },
      +        "template": {
      +          "type": "string"
      +        },
      +        "tier": {
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "tier",
      +        "permitted_phrasing_class",
      +        "must_state",
      +        "template"
      +      ],
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "How strongly this result may be stated. tier is insufficient, suggestive, detectable_not_meaningful or supported; every entry in must_state has to be mentioned when reporting it."
      +}
    • addedOutput schema / properties / evidence_profile
      Added value: +{
      +  "anyOf": [
      +    {
      +      "properties": {
      +        "analysis": {
      +          "type": "string"
      +        },
      +        "dimensions": {
      +          "items": {
      +            "properties": {
      +              "can_block": {
      +                "default": true,
      +                "type": "boolean"
      +              },
      +              "details": {
      +                "additionalProperties": true,
      +                "type": "object"
      +              },
      +              "dimension": {
      +                "enum": [
      +                  "sample",
      +                  "temporal",
      +                  "robustness",
      +                  "missingness",
      +                  "practical",
      +                  "measurement_validity",
      +                  "provenance"
      +                ],
      +                "type": "string"
      +              },
      +              "reason_codes": {
      +                "items": {
      +                  "type": "string"
      +                },
      +                "type": "array"
      +              },
      +              "status": {
      +                "enum": [
      +                  "adequate",
      +                  "negligible",
      +                  "not_assessed",
      +                  "weak",
      +                  "concern",
      +                  "blocking"
      +                ],
      +                "type": "string"
      +              }
      +            },
      +            "required": [
      +              "dimension",
      +              "status"
      +            ],
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "effect": {
      +          "additionalProperties": true,
      +          "type": "object"
      +        },
      +        "metric": {
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "metric",
      +        "analysis",
      +        "dimensions"
      +      ],
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Per-dimension evidence quality behind this result (sample, temporal, missingness, ...). Dimensions without an evaluator yet are 'not_assessed' and cap the claim, never count as adequate."
      +}
  5. Changed1 schema field changedv1.0.17
    • addedOutput schema / properties / trend / properties / span_days
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
  6. Changed2 schema fields changed
    • addedOutput schema / properties / evidence
      Added value: +{
      +  "description": "Coverage/quality of the data a single-metric analytical result is\nbased on. See evidence.build_evidence for how each field is computed.",
      +  "properties": {
      +    "confidence": {
      +      "type": "string"
      +    },
      +    "coverage_ratio": {
      +      "type": "number"
      +    },
      +    "expected_days": {
      +      "type": "integer"
      +    },
      +    "freshness_days": {
      +      "anyOf": [
      +        {
      +          "type": "integer"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null
      +    },
      +    "gaps": {
      +      "items": {
      +        "properties": {
      +          "days": {
      +            "type": "integer"
      +          },
      +          "end": {
      +            "type": "string"
      +          },
      +          "start": {
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "start",
      +          "end",
      +          "days"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "measurement_count": {
      +      "type": "integer"
      +    },
      +    "missing_days": {
      +      "type": "integer"
      +    },
      +    "observed_days": {
      +      "type": "integer"
      +    },
      +    "observed_end": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null
      +    },
      +    "observed_start": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null
      +    },
      +    "recent_gap_days": {
      +      "type": "integer"
      +    },
      +    "requested_end": {
      +      "type": "string"
      +    },
      +    "requested_start": {
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "requested_start",
      +    "requested_end",
      +    "expected_days",
      +    "observed_days",
      +    "coverage_ratio",
      +    "missing_days",
      +    "measurement_count",
      +    "gaps",
      +    "recent_gap_days",
      +    "confidence"
      +  ],
      +  "type": "object"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "metric",
      -  "range",
      -  "trend"
      -]New value: +[
      +  "metric",
      +  "range",
      +  "trend",
      +  "evidence"
      +]
  7. Addedv1.0.16
  8. Removedv1.0.15
  9. Addedv1.0.11

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare read-only, idempotent, non-destructive behavior, and the description adds genuinely new context on top: how to interpret r_squared (low = noisy, not flat) and an explicit privacy disclosure that local data becomes part of the conversation sent to the calling client's model. That privacy/egress caveat is behavioral information no structured field provides.

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?

Front-loaded with the core action and its outputs, then structured into scannable when/when-not bullets. The privacy paragraph is longer than the rest but earns its place by flagging a non-obvious data-handling consequence.

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?

Despite an output schema existing (so return values need not be explained), the description still clarifies the meaning of the key returned statistic. Combined with the branching guidance and privacy note, an agent has everything needed to select and call this correctly.

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%, including the enumerated metric values and the start/end date defaults, so the schema carries the parameter burden. The description only restates 'one metric over a window' without adding format or edge-case detail beyond the schema, which is the baseline-3 case.

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?

States a specific verb and resource ('fit a simple straight-line trend to one metric over a window') and enumerates the exact outputs (direction, slope per day, r_squared). It also disambiguates itself from three named siblings, so an agent can distinguish it without opening any schema.

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

Usage Guidelines5/5

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

Provides explicit 'use this tool when' and 'do not use this tool when' sections, each routing to a concrete alternative (compare_metric_periods, get_baseline, detect_metric_anomalies) with the exact user phrasing that selects each one. Nothing about tool selection is left to inference.

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