Skip to main content
Glama
Thecimal

Quantified Self MCP Server

Detect metric anomalies

detect_metric_anomalies
Read-onlyIdempotent

Flag days when one personal-health metric deviates sharply from its usual baseline, using a robust median/MAD z-score to catch spikes or dips in noisy short series.

Instructions

Flag days where one metric deviated sharply from its own baseline over the window, using a median/MAD-based modified z-score rather than a mean/stdev z-score — more robust for short, noisy personal-health series, where the mean/stdev version is easily dragged around by the very outliers it's supposed to catch.

Use this tool when:

  • the user asks whether anything looked unusual/off/weird on particular days for one metric (e.g. "was there anything unusual about my sleep last month?").

Do not use this tool when:

  • the user wants a general sense of what's typical, with no interest in flagging specific days -> use get_baseline instead.

  • the user asks about a steady increase/decrease over time rather than isolated spikes/dips -> use calculate_metric_trend instead.

  • the user already has one specific date in mind and wants the full "why" behind it (baseline, anomaly, trend, and correlations together) -> use explain_metric_change 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.
thresholdNoModified z-score cutoff. 3.5 (the default, Iglewicz & Hoaglin's standard value) flags only clear outliers; lower it (e.g. 2.5) to see more borderline days.
start_dateNoFirst day to include, formatted YYYY-MM-DD. Defaults to 90 days before end_date.

Output Schema

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

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",
      -  "threshold",
      -  "anomalies",
      -  "claim",
      -  "evidence",
      -  "evidence_profile",
      -  "claim_decision"
      -]New value: +[
      +  "metric",
      +  "range",
      +  "threshold",
      +  "anomalies",
      +  "claim",
      +  "evidence"
      +]
  2. Changed8 schema fields changedv1.0.26
    • addedOutput schema / properties / claim
      Added value: +{
      +  "description": "Evidence and decision for the anomaly 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",
      -  "threshold",
      -  "anomalies",
      -  "evidence"
      -]New value: +[
      +  "metric",
      +  "range",
      +  "threshold",
      +  "anomalies",
      +  "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",
      -  "threshold",
      -  "anomalies",
      -  "evidence"
      -]New value: +[
      +  "evidence_profile",
      +  "claim_decision",
      +  "metric",
      +  "range",
      +  "threshold",
      +  "anomalies",
      +  "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. 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",
      -  "threshold",
      -  "anomalies"
      -]New value: +[
      +  "metric",
      +  "range",
      +  "threshold",
      +  "anomalies",
      +  "evidence"
      +]
  6. Addedv1.0.16
  7. Removedv1.0.15
  8. Addedv1.0.11

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already cover read-only, idempotent, non-destructive, and closed-world traits, so the description is not obligated to restate safety. It adds real value beyond that by explaining why the method is robust for short noisy series and by disclosing a privacy consequence (returned data enters the conversation sent to the client's model). It does not mention handling of missing/short series, which would round this out.

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?

Well front-loaded: what it does and why, then when/when-not, then the privacy caveat. Every section earns its place, though the privacy note is lengthy and could be tightened without losing meaning.

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?

An output schema exists so return values need no explanation, annotations carry the safety profile, and all four parameters are fully documented in the schema. Combined with the routing guidance, an agent has everything required 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 coverage is 100% and the schema already documents every parameter thoroughly, including the allowed metric values, date formats, and the Iglewicz & Hoaglin rationale for the 3.5 threshold default. The description adds no parameter-level detail beyond that, so the baseline 3 is correct.

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 scope ('Flag days where one metric deviated sharply from its own baseline over the window') and even names the statistical method (median/MAD modified z-score). An agent can distinguish this from get_baseline, calculate_metric_trend, and explain_metric_change 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?

Explicit 'Use this tool when' and 'Do not use this tool when' blocks, with three named alternatives (get_baseline, calculate_metric_trend, explain_metric_change) and the exact user-intent condition that selects each. Includes a concrete example query. Nothing 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.