MacroFactor MCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MacroFactor MCP
Vercel fork. This branch runs on Vercel + Turso instead of Cloudflare Workers + D1. See DEPLOY-VERCEL.md. The Cloudflare steps below are kept for reference.
A personal Model Context Protocol server that lets an AI agent (Claude, ChatGPT, Codex, Cursor, …) search food macros, read your MacroFactor data, and log food, water and weight back into MacroFactor — including requests like "add a Jersey Mike's giant turkey sub, no toppings", where the agent works out the numbers and logs the result.
Fork of chaotix345/macrofactor-mcp (MIT). This fork adds
external food search (USDA + Open Food Facts), the full official Log by JSON schema, one consolidated
iPhone Shortcut, live today-totals from every sync, and OpenAI-connector compatibility.
MacroFactor has no public API and its private Firestore API has been App Check–locked since May 2026, so this uses only official mechanisms:
Reads come from MacroFactor's built-in Data Export (
.xlsx+.csv), parsed on the server, plus a live today feed that every sync refreshes.Writes go through MacroFactor's official Apple Shortcuts actions (
Log by JSON,Log Water,Log Weight) on your iPhone. The agent queues entries; you tap one notification (or ask Siri) and the MF Sync Shortcut logs everything queued.
Architecture
Claude.ai / Claude mobile / Claude Code / ChatGPT / Codex
│ remote MCP (Streamable HTTP) https://macrofactor-mcp.<you>.workers.dev/mcp/<MCP_TOKEN>
▼
Cloudflare Worker (McpAgent Durable Object) + D1
├─ reads D1 tables from your export + today_summary (live)
├─ search your saved foods + USDA FoodData Central + Open Food Facts
└─ writes queue rows in D1 ──▶ Pushcut push ──▶ iPhone
│ tap / Siri / automation
iPhone Shortcut "MF Sync": GET /pending-all
→ Log by JSON ×N, Log Water ×N, Log Weight ×N
→ POST /sync-ack (+ MacroFactor's Today Summary)Related MCP server: MyFitnessPal MCP Server
How a request flows
"add jersey mike giant turkey sub no toppings"
The agent checks your own foods first (
search_my_foods— everything you've eaten, from the phone feed). No match, so it web-searches Jersey Mike's official nutrition calculator, reads the Giant #7 build (bread, turkey, provolone) and drops the Mike's Way toppings using the published component values. Official figures beat third-party calculators and guesses; it says which it used.It calls
log_foodwith an exact name, brand, icon, serving ({amount:1, label:"giant sub", weight:…}), the nutrients,notes(source URL + breakdown) andllm_prompt(your words). Generic and packaged foods go throughsearch_food/get_food_nutrients(USDA + Open Food Facts) instead.The Worker validates the payload against MacroFactor's official schema, queues it, and pings your phone. You tap → MF Sync logs it → MacroFactor's returned today summary lands on the server.
get_todaynow shows the entry in your live totals;get_pending_logsshowslanded:true.
The server ships MCP instructions with this playbook, so any client that supports them (Claude, ChatGPT,
Codex) follows it without extra prompting. Reads and writes are separate on purpose: the agent can request a
refresh (refresh_from_phone → "MacroFactor Refresh" notification → MF Nightly) but never a write.
Tools (42, plus 2 optional)
Every tool declares an MCP output schema and returns structured content (array results are wrapped as {items, count}), so clients like Claude and ChatGPT can reason about result shapes.
Food search
Tool | What it does |
| Name search across your saved foods + USDA FoodData Central + Open Food Facts; per‑100 g and per‑serving macros, ids for |
| Full MacroFactor nutrient dictionary for a hit, scaled to grams / servings / a named portion, plus a ready |
| UPC/EAN → product with label nutrients (Open Food Facts, then USDA Branded) |
| Your Favorites / Custom Foods / history from the export |
| Connector‑style wrappers of the above with the result shapes ChatGPT expects |
Logging (all land at the current time via MF Sync)
Tool | What it does |
| One entry — flat macros or a full |
| Up to 30 separate entries in one tap |
| One entry whose nutrients are the sum of its |
| A saved Favorite/Custom food by name × servings |
| Re‑log a past day's meal (optional hour window) as one entry |
| Via MacroFactor's dedicated actions — off by default ( |
| See what's queued or claimed by the phone; "never mind" |
| Ping the phone's read-only "MacroFactor Refresh" notification → MF Nightly re-posts today's totals, recent foods and the saved-foods library (never logs) |
Reads & analytics (from the upstream project, unchanged)
get_today (live), get_daily_nutrition, get_micronutrients, get_food_log, get_weight_history,
get_expenditure, get_steps, data_status, get_day, get_targets, get_goal_history,
get_adherence, weekly_summary, weekly_review, get_training_volume, get_exercise_progress,
get_workouts, get_prs, get_body_metrics, get_program, forecast_weight,
reconcile_energy_balance, day_of_week_patterns, get_nutrient_timing, detect_stall,
micro_gap_analysis, get_training_day_nutrition, get_pr_alerts.
Prerequisites
Node.js ≥ 22 and a Cloudflare account (the Workers free plan is enough; paid works too).
The MacroFactor iOS app, the Shortcuts app, and (optional) Pushcut — its free tier covers the one notification this needs.
Optional: a free USDA FoodData Central API key (without it the shared
DEMO_KEYallows ~30 requests/hour).
Setup
1. Install + log in
npm install
npx wrangler login2. Create the database
npx wrangler d1 create macrofactorPaste the printed database_id into wrangler.jsonc, then create the tables:
npm run db:initSet USER_TZ in wrangler.jsonc to your IANA timezone (it decides what "today" means).
3. Secrets
npx wrangler secret put INGEST_SECRET # openssl rand -hex 32 — used by your phone/PC endpoints
npx wrangler secret put MCP_TOKEN # openssl rand -hex 32 — makes the MCP URL unguessable
npx wrangler secret put USDA_API_KEY # optional but recommended
npx wrangler secret put PUSHCUT_WEBHOOK_URL # "MacroFactor" notification → MF Sync (writes)
npx wrangler secret put PUSHCUT_REFRESH_WEBHOOK_URL # "MacroFactor Refresh" notification → MF Nightly (reads)4. Deploy
npm run deployNote the URL it prints, e.g. https://macrofactor-mcp.<you>.workers.dev. GET /health should return {"ok":true,…}.
5. iPhone Shortcut
Follow ios-setup.md — "MF Sync" (writes) and "MF Nightly" (reads), each with its own Pushcut notification.
6. (Optional) Load an export
Only MacroFactor's expenditure (TDEE), trend weight and workout data need an export; everything else comes from the MF Nightly Shortcut. If you want those: MacroFactor → More → Data Management → Data Export, then share the files to the "Update MF" Shortcut (ios-setup.md) or, from a computer:
cp ingest.config.example.json ingest.config.json # fill in workerUrl + ingestSecret
npm run ingest -- path/to/workbook.xlsx path/to/foodlog.csv path/to/workoutlog.csv7. Connect an agent
The connector URL is https://macrofactor-mcp.<you>.workers.dev/mcp/<MCP_TOKEN> — treat it as a secret.
Claude.ai / Claude mobile: Settings → Connectors → Add custom connector → paste the URL, Authentication: None.
Claude Code:
claude mcp add --transport http macrofactor "https://macrofactor-mcp.<you>.workers.dev/mcp/<MCP_TOKEN>"Claude Desktop: Settings → Connectors → Add custom connector (same URL).
ChatGPT: Settings → Connectors → Create (needs Developer Mode on Pro/Team/Enterprise) → URL, Authentication None. The
search/fetchtools satisfy ChatGPT's connector requirements; in Developer Mode all tools are available.OpenAI API (Responses):
tools: [{ type: "mcp", server_label: "macrofactor", server_url: "https://…/mcp/<MCP_TOKEN>", require_approval: "never" }]Codex CLI:
codex mcp add macrofactor --url "https://…/mcp/<MCP_TOKEN>"Cursor / Windsurf / anything with Streamable HTTP MCP: same URL.
Local development
cp .dev.vars.example .dev.vars # INGEST_SECRET / MCP_TOKEN for local dev
npm run db:init:local
npm run dev # http://localhost:8787
node scripts/local-e2e.mjs # search → nutrients → log → claim → ack, no phone needed
npm test # schema tests against MacroFactor's official sample payloadsEndpoints
Path | Who calls it | Purpose |
| the agent | MCP (Streamable HTTP) |
| MF Sync | claim everything queued: |
| MF Sync | delete the claimed rows; body = Today Summary (Macros Remaining) → live today, day rows, targets |
| Update MF / | parse an export into D1 |
| MF Nightly | a Today Summary body (Macros Remaining) or nutrient query params for a date; gap-fills |
| MF Nightly | MacroFactor's Find Recent Food list → today's |
| you | D1 check |
| legacy Shortcuts | per‑type queues from upstream |
Risk
Export → reads: your own data via a feature built for it.
Shortcuts → writes: MacroFactor publishes the Shortcuts actions and their JSON schema; the write path always requires the Shortcut to run on your phone. Every payload carries a stable
sourceidentifier (MF_SOURCEinwrangler.jsonc) as MacroFactor asks.No private API. Optional: email
support@macrofactor.comto confirm automation use in writing.
Apple Health
MacroFactor syncs daily calories, macros, body weight and measurements to Apple Health. The server tells
agents (in its MCP instructions and in data_status) that an Apple Health tool in the client, when
available, is the place for raw weight and body measurements. This server stays the source for totals,
targets, foods and all logging.
Known limits
Entries land at sync time — MacroFactor's actions have no date field. Pass
intended_timeto any food-write tool; the server matches it against the food log on the next feed or export.The food log from the phone feed is per distinct food (MacroFactor's "recent foods" list): a food eaten twice in a day shows once. Day totals come from the today summary, so they are exact.
Only MacroFactor's expenditure (TDEE) and trend weight need an export; raw weight and measurements are in Apple Health. Water/weight logging is off unless
ENABLE_WATER_WEIGHTis "true".USDA and Open Food Facts don't have chain-restaurant menus; the agent is instructed to use the chain's official nutrition calculator/PDF via web search and to cite it in
notes.Weights are stored in kg (MacroFactor exports normalise to kg even if the app shows pounds).
Make it yours
USER_TZ,MF_SOURCE—wrangler.jsoncvars.Bottleneck KPI (
squatBottleneck()insrc/db/prs.ts) and micronutrient RDAs (MICRO_RDAinsrc/db/analytics.ts) — inherited from upstream; adjust for your lifts / demographic.Icon guesses for foods without an explicit icon:
ICON_GUESSESinsrc/nutrients.ts.
License
MIT — see LICENSE. Upstream © chaotix345; fork changes © jamesj64.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Calorie tracker app for ChatGPT and Claude: read meals, macros, weight and log meals from chat.
Your Apple Health data, food diary and lifts, for ChatGPT, Claude and Gemini. Approved on iPhone.
Calorie, workout and body-weight log inside ChatGPT and Claude. Log meals by text, photo or voice.
Read your Gymie meals, workouts and weight; log meals and weigh-ins from your AI assistant.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to read and write MyFitnessPal data, including food diary, exercises, body measurements, nutrition goals, and water intake.MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to read and log MyFitnessPal nutrition data, including tracking calories, macros, searching foods, and adding meals through natural conversation.7MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to interact with MyFitnessPal data including food diary, exercises, body measurements, nutrition goals, and water intake through natural language.2073MIT
- AlicenseNot gradedqualityDmaintenanceEnables nutrition tracking via AI, allowing users to read food logs with macros, goals, and profile, log meals by text or photo, and access diary, subscription, diabetes, and wearable/glucose data.MIT