Skip to main content
Glama
io.github.rwestergren/cronometer-api-mcp

io.github.rwestergren/cronometer-api-mcp

by rwestergren

cronometer-api-mcp

License: MIT CI Build Docker image PyPI

Hosted version for Claude.ai, ChatGPT, and Grok coming soon. Join the waitlist →

An MCP (Model Context Protocol) server for Cronometer nutrition tracking, built on the reverse-engineered mobile REST API.

Unlike cronometer-mcp, which takes a comprehensive GWT-RPC approach against Cronometer's web backend, this server talks to the same JSON REST API used by the Cronometer Android app -- with clean payloads and stable, versioned endpoints.

Features

  • Food log -- diary entries with food names, amounts, meal groups

  • Nutrition data -- daily macro/micro totals and nutrition scores with per-nutrient confidence

  • Food search -- search the Cronometer food database, get detailed nutrition info

  • Diary management -- add/remove entries, copy days, mark days complete

  • Custom foods -- create foods with custom nutrition data

  • Macro targets -- read weekly schedule and saved templates

  • Fasting -- view history and aggregate statistics

  • Biometrics -- weight, body fat, heart rate, and other tracked metrics over a date range

Related MCP server: nutrition-mcp

Quick Start

1. Install uv

curl -LsSf https://astral.sh/uv/install.sh | sh

2. Set credentials

export CRONOMETER_USERNAME="your@email.com"
export CRONOMETER_PASSWORD="your-password"

Optional: two-factor authentication

If the account has two-factor authentication enabled, /api/v2/login answers TOTP_CODE_REQUIRED unless the request carries the current 6-digit code. Give the server the base32 key that Cronometer showed when 2FA was set up (the same key you scanned into your authenticator app) and it derives the code itself at every login (RFC 6238, SHA-1, 30 s period):

export CRONOMETER_TOTP_SECRET="ABCD EFGH IJKL MNOP QRST UVWX YZ23 4567"

Spaces and lowercase are fine. Leave it unset for accounts without 2FA.

Optional: override the account timezone

Diary entries are stamped in your Cronometer account's timezone, which the server reports at login. If that zone is wrong (for example, an older build had reset it) you can force a specific IANA zone without changing your account settings:

export CRONOMETER_ACCOUNT_TZ="America/Los_Angeles"

When set, this takes precedence over both the value reported at login and any cached session, so it also overrides a stale cached timezone.

3. Configure your MCP client

uvx downloads and runs the server on demand -- no separate install step.

OpenCode (opencode.json)

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "cronometer": {
      "type": "local",
      "command": ["uvx", "cronometer-api-mcp"],
      "environment": {
        "CRONOMETER_USERNAME": "{env:CRONOMETER_USERNAME}",
        "CRONOMETER_PASSWORD": "{env:CRONOMETER_PASSWORD}",
        "CRONOMETER_TOTP_SECRET": "{env:CRONOMETER_TOTP_SECRET}",
        "CRONOMETER_ACCOUNT_TZ": "{env:CRONOMETER_ACCOUNT_TZ}"
      },
      "enabled": true
    }
  }
}

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "cronometer": {
      "command": "uvx",
      "args": ["cronometer-api-mcp"],
      "env": {
        "CRONOMETER_USERNAME": "your@email.com",
        "CRONOMETER_PASSWORD": "your-password",
        "CRONOMETER_TOTP_SECRET": "your-base32-key",
        "CRONOMETER_ACCOUNT_TZ": "America/Los_Angeles"
      }
    }
  }
}

Available Tools

Food Log & Nutrition

Tool

Description

get_food_log

Diary entries for a date, each enriched with food name, source, serving measure/count, that food's per-entry nutrient contribution, and the diary group (meal slot) it sits in, plus an energy_summary (target/consumed/remaining kcal) and a nutrition_summary of consumed totals for every tracked nutrient

get_daily_nutrition

Consumed macro and micronutrient totals for every nutrient tracked in Cronometer

get_nutrition_scores

Category scores (Vitamins, Minerals, etc.) with per-nutrient consumed amounts and confidence levels

Food Search & Details

Tool

Description

search_foods

Search the Cronometer food database by name

get_food_details

Full nutrition profile and serving sizes for a food

Diary Management

Tool

Description

get_diary_groups

The account's diary groups (meal slots) and their names, for interpreting the group in each entry's order

add_food_entry

Log a food serving to the diary

remove_food_entry

Remove one or more diary entries: foods, exercises, notes or biometrics

add_custom_food

Create a custom food with specified nutrition and optional barcodes

update_custom_food

Edit a custom food in place: name, nutrition, serving size, or barcodes

delete_custom_food

Retire a custom food so it leaves search and the Custom Foods list (existing diary entries are kept)

delete_recipe

Delete a recipe or saved meal: retired by default (diary entries are kept), or permanently, which also removes the diary entries that logged it

add_recipe

Create a recipe from existing foods referenced by ID and gram weight

update_recipe

Edit a recipe in place: name, ingredients and amounts, serving size, or notes; nutrition is recalculated

import_recipe

Create a recipe from a free-text ingredient list; Cronometer matches each line to a database food and converts the amount to grams

copy_day

Copy all entries from the previous day

mark_day_complete

Mark a diary day as complete or incomplete

add_note

Add a note to a diary day

update_note

Replace the text of a diary note

Targets & Tracking

Tool

Description

search_activities

Find activities to log as exercise, by name

add_exercise

Log an exercise with its duration and calories burned

get_macro_targets

Fixed-gram macro targets, weight goal, macro split (percent of energy), weekly macro schedule and saved target templates

set_macro_targets

Set protein / fat / net-carb targets in grams, the weekly weight goal (which moves the calorie target) and the sodium range; writes both the profile prefs and the per-nutrient target rows

set_macro_split

Set the protein / carbs / fat split in percent of energy

get_fasting_history

Fasting history within a date range

get_fasting_stats

Aggregate fasting statistics

list_biometrics

List trackable biometric metrics and their units

get_biometrics

Biometric time series (e.g. weight, body fat) within a date range

add_biometric

Record a biometric reading such as a weight or body fat

All date parameters use YYYY-MM-DD format and default to today when omitted.

Relative dates and recent days

get_food_log, get_daily_nutrition, and get_nutrition_scores also accept "today", "yesterday", and "N days ago" as their date. These are resolved at call time using your Cronometer account timezone, so Claude can pass relative inputs without relying on dates from earlier in a long conversation.

get_food_log and get_daily_nutrition accept days (1–31, default 1), counting back from the inclusive end date:

get_food_log(date="yesterday")
get_nutrition_scores(date="3 days ago")
get_daily_nutrition(days=3)  # Last 3 days, including today
get_daily_nutrition(date="yesterday", days=3)  # Previous 3 complete calendar days
get_food_log(days=7)  # Recent meals, including today

For “my calories the last few days,” use get_daily_nutrition(days=3). Single-day responses retain their existing shape. Multi-day responses contain start_date, end_date, and a days list of daily results, oldest first. Returned dates are always concrete YYYY-MM-DD values.

Transport

stdio only. For remote/hosted use, the stdio server is wrapped by supergateway (see Dockerfile), which owns the HTTP listener and exposes MCP streamable-HTTP at /mcp. The server has no built-in authentication — any remote deployment must sit behind an authenticating gateway or reverse proxy.

Development

For local development, copy .env.example to .env and fill in your credentials:

cp .env.example .env
# edit .env
uv run cronometer-api-mcp

The CLI auto-loads .env on startup (dev convenience only). Real environment variables always win over .env, so production deployments and MCP client env blocks are unaffected.

How It Works

This server communicates with mobile.cronometer.com -- the same REST API used by the Cronometer Android/Flutter app. The API was reverse-engineered through:

  1. Static analysis of libapp.so (Dart AOT snapshot) from the APK to discover endpoint names

  2. Traffic interception via Frida + mitmproxy to capture exact request/response formats

  3. Trial-and-error against the live API to confirm payload shapes

The API uses two protocols:

  • v2 (POST /api/v2/*) -- JSON-body auth, used for most operations (food search, diary read/write, nutrition, fasting, macros, biometrics)

  • v3 (DELETE /api/v3/user/{id}/*) -- Header-based auth (x-crono-session), used for diary entry deletion

Recipe import is the one asynchronous operation: import_recipe returns a job id, and poll_async_result is polled until the server reports 100% progress and attaches the parsed ingredients.

Python API

You can use the client directly:

from cronometer_api_mcp.client import CronometerClient
from datetime import date

client = CronometerClient()

# Search for foods
results = client.search_food("chicken breast")

# Get food details
food = client.get_food(results[0]["id"])

# Log a serving
client.add_serving(
    food_id=food["id"],
    measure_id=food["defaultMeasureId"],
    grams=200,
)

# Get today's diary
diary = client.get_diary()

# Import a recipe from a free-text ingredient list
recipe = client.import_recipe("one hot dog\nketchup\nbun")
print(recipe["food_id"], recipe["ingredients"])

# Parse without saving, to review the matches first
preview = client.import_recipe("2 tbsp olive oil\n200g chicken", save=False)

# Get nutrition scores
scores = client.get_nutrition_scores()

License

MIT

Available Tools

19 tools
add_custom_foodA

Create a custom food in Cronometer with specified nutrition.

Nutrient amounts should be for the full serving size specified. After creation, use the returned food_id with add_food_entry to log it.

Args: name: Food name. calories: Calories per serving (kcal). protein_g: Protein per serving (g). fat_g: Fat per serving (g). carbs_g: Carbs per serving (g). fiber_g: Fiber per serving (g, default 0). sugar_g: Sugar per serving (g, default 0). sodium_mg: Sodium per serving (mg, default 0). saturated_fat_g: Saturated fat per serving (g, default 0). extra_nutrients: Additional nutrients beyond the core macros above (vitamins, minerals, amino acids, etc.), keyed by Cronometer nutrient ID (from get_daily_nutrition, which pairs each id with its name) and valued per the full serving. IDs aren't validated, so a wrong one writes the wrong nutrient; must not reuse an ID the named macro args already cover. serving_name: Name for the serving size (default "1 serving"). serving_grams: Weight of one serving in grams (default 100). barcodes: Product barcodes (EAN-13, UPC-A, EAN-8, UPC-E or GTIN-14), e.g. the digits printed under the bars on the package; spaces and dashes are ignored. Scanning one of them in the Cronometer app then finds this food (search_foods does not match barcodes). The check digit is verified, so a misread digit is rejected rather than saved.

Inputs: name (required), fat_g (required), carbs_g (required), calories (required), +9 more. Returns: result

add_food_entryA

Add a food entry to the Cronometer diary.

Use search_foods to find food_id and measure_id, then get_food_details to confirm serving sizes and gram weights.

Args: food_id: Numeric food ID from search_foods results. measure_id: Measure/unit ID from get_food_details. grams: Weight of the serving in grams. date: Date to log as YYYY-MM-DD (defaults to today). translation_id: Translation ID from search results (usually 0). diary_group: Meal slot -- one of "auto", "breakfast", "lunch", "dinner", "snacks" (case-insensitive, default "auto").

Inputs: grams (required), food_id (required), measure_id (required), date, +2 more. Returns: result

add_recipeA

Create a recipe in Cronometer from other foods in the database.

Unlike add_custom_food, which takes hand-entered nutrition, a recipe references existing foods by ID and Cronometer derives the full nutrient profile (including micronutrients) from those ingredients.

Use search_foods to find each ingredient's food_id. After creation, use the returned food_id with add_food_entry to log it.

Args: name: Recipe name. ingredients: List of {"food_id": int, "grams": float} objects, one per ingredient. An optional "measure_id" overrides the unit shown in Cronometer's UI; "grams" always drives the nutrition math. serving_name: Name of the default serving measure (default "Serving"). serving_grams: Grams in one serving. Defaults to the full batch weight (one serving = the whole recipe). comments: Free-text recipe notes.

Inputs: name (required), ingredients (required), comments, serving_name, +1 more. Returns: result

copy_dayA

Copy all diary entries from the previous day to the given date.

Additive -- does not remove existing entries on the destination date.

Args: date: Destination date as YYYY-MM-DD (defaults to today).

Inputs: date. Returns: result

delete_custom_foodA
DestructiveIdempotent

Delete a custom food (one you created) by retiring it.

The food disappears from search and from the Custom Foods list. Diary entries that already use it are kept, and get_food_details can still read it by ID. Database foods (USDA, NCCDB, CRDB, ...) and recipes cannot be deleted with this tool.

Args: food_id: ID of the custom food to delete.

Inputs: food_id (required). Returns: result

get_biometricsA
Read-onlyIdempotent

Get a biometric time series such as weight or body fat from Cronometer.

Returns the recorded values over the date range as a list of {day, value} points.

Use list_biometrics to find metric_id and unit_id (e.g. Weight is metric_id 1, with unit_id 1 for kg or 2 for lbs).

Args: metric_id: Numeric metric ID from list_biometrics. unit_id: Numeric unit ID from the metric's units in list_biometrics. start_date: Start date as YYYY-MM-DD (defaults to 30 days ago). end_date: End date as YYYY-MM-DD (defaults to today).

Inputs: unit_id (required), metric_id (required), end_date, start_date. Returns: result

get_daily_nutritionA
Read-onlyIdempotent

Get consumed macro and micronutrient totals for one or more days.

Use days=N for calories/nutrients over the last N calendar days. Prefer relative inputs over dates calculated from conversation history.

Returns the amounts actually consumed for the day, covering every nutrient the user tracks in Cronometer (i.e. has a target set for). The response has:

  • summary: flat macro totals (energy, protein, carbs, net_carbs, fat, fiber, alcohol). A value is null if that macro isn't tracked.

  • nutrients: the full list of tracked nutrients, each with id, name, amount, unit, category, and confidence.

A nutrient only appears if it's tracked in Cronometer. To surface e.g. saturated fat, cholesterol, or trans fat, set a target for it in Cronometer and it will flow through automatically.

Args: date: Inclusive end date: YYYY-MM-DD, today, yesterday, or N days ago. Defaults to today in the account timezone, resolved at call time. days: Number of calendar days, 1–31 (default 1). Includes the end date; days=3 includes today, date='yesterday', days=3 excludes today.

One day returns date, summary, and nutrients. Multiple days return start_date, end_date, and a days list of those objects, oldest first.

Inputs: date, days. Returns: result

get_fasting_historyA
Read-onlyIdempotent

Get fasting history from Cronometer.

Returns fasts within the date range including status, timestamps, and duration.

Args: start_date: Start date as YYYY-MM-DD (defaults to 30 days ago). end_date: End date as YYYY-MM-DD (defaults to today).

Inputs: end_date, start_date. Returns: result

get_fasting_statsA
Read-onlyIdempotent

Get aggregate fasting statistics.

Returns total fasting hours, longest fast, average fast duration, and completed fast count.

Inputs: no named parameters. Returns: result

get_food_detailsA
Read-onlyIdempotent

Get detailed food information including nutrition and serving sizes.

Use this after search_foods to get the full nutrient profile and available measure_ids needed for add_food_entry.

Args: food_id: Food ID from search_foods results.

Inputs: food_id (required). Returns: result

get_food_logA
Read-onlyIdempotent

Get diary entries for one day or the last N calendar days.

Prefer relative inputs for relative questions, rather than dates calculated from conversation history. For calorie/nutrient totals without individual entries, prefer get_daily_nutrition(days=N).

Returns every food entry logged for the day. Each "Serving" entry is enriched (best-effort) with the food's name, source, serving_size, servings, and that food's own nutrient profile scaled to the amount eaten. Non-food entries (exercise, biometrics) carry their own name.

serving_size defines one portion: quantity units weighing grams in total. servings is how many of those portions were consumed. For example, serving_size={quantity: 2, unit: "cookies", grams: 30} with servings=1 means two cookies eaten; servings=0.5 means one cookie eaten. The size uses the entry's selected measure, or the food's default as a fallback. For serving-based recipes, serving_size.grams is null because the API uses reference-serving counts instead of gram weights. An invalid serving_size.quantity is reported as null.

Note: the per-entry "nutrients" are each food's individual contribution, which is distinct from the day-level nutrition_summary aggregate below.

Also returns a top-level energy_summary field with pre-computed values most relevant to the user:

  • total_target_kcal: daily calorie target dynamically adjusted for expenditure and weight goal (equivalent to Cronometer's "Total Target" in the Energy Summary screen)

  • consumed_kcal: total calories consumed

  • remaining_kcal: calories remaining to stay on target (total_target_kcal - consumed_kcal). Always report this when summarizing the user's day. Prefer this over manually deriving values from the burn breakdown fields.

Also returns a nutrition_summary field with consumed totals for every nutrient the user tracks in Cronometer (macros plus any tracked micronutrients such as saturated fat, cholesterol, or omega-3/6):

  • macros: flat macro totals (energy, protein, carbs, net_carbs, fat, fiber, alcohol)

  • nutrients: the full list of tracked nutrients with amounts and units

Args: date: Inclusive end date: YYYY-MM-DD, today, yesterday, or N days ago. Defaults to today in the account timezone, resolved at call time. days: Number of calendar days, 1–31 (default 1). Includes the end date; days=3 includes today, date='yesterday', days=3 excludes today.

One day returns the usual date/diary/summaries. Multiple days return start_date, end_date, and a days list of those objects, oldest first.

Inputs: date, days. Returns: result

get_macro_targetsA
Read-onlyIdempotent

Get current macro targets including weekly schedule and templates.

Returns the weekly macro schedule (which template applies to each day) and all saved macro target templates with their values.

Inputs: no named parameters. Returns: result

get_nutrition_scoresA
Read-onlyIdempotent

Get nutrition scores with per-nutrient consumed amounts and category grades.

Returns category scores (All Targets, Vitamins, Minerals, Electrolytes, Antioxidants, Immune Support, Metabolism, Bone Health) with the actual consumed amount and confidence level for each tracked nutrient.

This is the richest nutrition endpoint -- use it when you need to know both how much of each nutrient was consumed AND how close each is to the target.

Args: date: YYYY-MM-DD, today, yesterday, or N days ago. Defaults to today in the account timezone, resolved at call time. Prefer relative inputs for relative questions over dates from conversation history.

Inputs: date. Returns: result

import_recipeA

Create a recipe from a free-text ingredient list.

Cronometer's "Import Recipe" feature: pass ingredients as plain text, one per line, and the server matches each to a food and converts the amount to grams. No need to call search_foods first.

Prefer this when the user describes ingredients in their own words. Use add_recipe instead when you have exact food_ids and gram weights -- e.g. the user confirmed specific foods from search_foods results.

Matching is fuzzy, so report the returned matches back to the user for confirmation. Unresolved lines are listed under "unmatched" and excluded from the recipe. This saves to My Foods; use add_food_entry to log it.

Args: ingredients: Ingredient lines separated by newlines, e.g. "2 tbsp olive oil\n200g chicken". Include quantities where known, since bare names can match surprising amounts. name: Recipe name. Defaults to a server-generated one.

Inputs: ingredients (required), name. Returns: result

list_biometricsA
Read-onlyIdempotent

List the biometric metrics tracked in Cronometer.

Returns every metric type the account can record (Weight, Body Fat, Heart Rate, Blood Glucose, Waist Size, Sleep, blood panels, body measurements, etc.). Use the metric_id and a unit_id from the results with get_biometrics.

Inputs: no named parameters. Returns: result

mark_day_completeA
Idempotent

Mark a diary day as complete or incomplete.

Args: date: Date to mark as YYYY-MM-DD. complete: True to mark complete, False for incomplete.

Inputs: date (required), complete. Returns: result

remove_food_entryA
DestructiveIdempotent

Remove one or more food entries from the Cronometer diary.

Use get_food_log to find entry IDs.

Args: entry_ids: List of serving/entry IDs to remove. date: Date the entries belong to as YYYY-MM-DD (defaults to today).

Inputs: entry_ids (required), date. Returns: result

search_foodsA
Read-onlyIdempotent

Search Cronometer's food database by name.

Returns matching foods with their IDs and source information. Use the food_id and measure_id from results with add_food_entry, or pass food_id to get_food_details for full nutrition info.

Args: query: Food name or keyword (e.g. "eggs", "chicken breast").

Inputs: query (required). Returns: result

update_custom_foodA
DestructiveIdempotent

Edit an existing custom food (one you created) in place.

Only the arguments you pass change; everything else keeps its current value. Find the food_id with search_foods (source "Custom") or get_food_details. Diary entries that already use the food pick up the new values. Recipes cannot be edited with this tool, even though they also show as source "Custom".

Nutrient amounts are per serving: the food's default serving, or serving_grams when you pass it. To change the serving weight without re-entering nutrition, pass serving_grams alone; the stored per-100g values stay put, so the per-serving numbers scale with the new weight.

Args: food_id: ID of the custom food to edit. name: New food name. calories: Calories per serving (kcal). protein_g: Protein per serving (g). fat_g: Fat per serving (g). carbs_g: Carbs per serving (g). fiber_g: Fiber per serving (g). sugar_g: Sugar per serving (g). sodium_mg: Sodium per serving (mg). saturated_fat_g: Saturated fat per serving (g). extra_nutrients: Additional nutrients keyed by Cronometer nutrient ID (from get_daily_nutrition) and valued per serving; must not reuse an ID the named args already cover. serving_name: New name for the default serving. The app shows the serving as " "; a leading number ("2 cookies") is taken as the quantity (see serving_quantity). serving_grams: New total weight of the default serving in grams. Also resets the quantity to serving_quantity (or 1). serving_quantity: How many units make up the default serving (default 1 whenever serving_grams is passed). Without serving_grams the serving's total weight stays the same, so each unit gets lighter or heavier: changing "2 cookies = 30 g" to 3 gives "3 cookies = 30 g". To keep the per-unit weight, also pass serving_grams (45 here). Check the result with get_food_details, which lists each measure's quantity. barcodes: Replaces the food's barcodes (see add_custom_food for the accepted formats); pass [] to remove them all. To add one, pass the current barcodes from get_food_details plus the new one.

Inputs: food_id (required), name, fat_g, carbs_g, +11 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 19 tools

    Disambiguation4/5

    Most tools target distinct resources/actions (search vs details, list vs get for biometrics, history vs stats for fasting, custom-food CRUD). The main overlaps are add_recipe vs import_recipe and the trio get_food_log/get_daily_nutrition/get_nutrition_scores, but their descriptions clearly delineate entries-vs-totals-vs-grades so an agent can still pick correctly.

    Naming Consistency5/5

    Nearly every tool follows a clean snake_case verb_noun pattern (add_custom_food, get_food_log, remove_food_entry, search_foods, list_biometrics). Even exceptions like copy_day and mark_day_complete read as verb_noun and fit the convention smoothly.

    Tool Count4/5

    19 tools is on the heavier side for the 16-25 band, but the server legitimately spans several sub-domains (food logging, custom foods, recipes, diary management, nutrition analysis, biometrics, fasting, targets). Each tool maps to a real operation, so the count is justified rather than padded.

    Completeness4/5

    Food logging, custom-food CRUD, recipe creation, diary management, nutrition reads, biometrics reads, and fasting reads are all covered. Gaps exist on the write side — no way to set/update macro targets, add biometric measurements, or start/stop a fast — but core logging and reporting workflows are intact.

    Maintenance

    ActivityActive
    ResponsivenessUsually handled

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      An MCP server that provides access to Cronometer nutrition data, enabling users to pull food logs, macro and micronutrient summaries, and biometric data into Claude or Cursor. It supports daily nutrition tracking and raw CSV exports by interfacing with the Cronometer web protocol.
      27
      739 PyPI
      28
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for personal nutrition tracking, enabling users to log meals with calories and macros, water intake, body weight, set goals, and import food diaries from other apps through natural language.
      MIT