{"slug": "your-model-is-inventing-macros-make-it-look-the-food-up", "title": "Your model is inventing macros. Make it look the food up.", "summary": "A developer built Calorie API, a 4M+ food catalog exposed both as a REST API and an MCP server for Claude Code and Cursor, so assistants look up nutrition data instead of hallucinating macros from memory. The MCP server offers eight tools including search_foods, calculate_portion, calculate_recipe, and analyze_food_photo, with personal plans at $29/month and REST plans starting at $15/month for 20,000 calls. The developer notes the MCP host is public but OAuth is not yet enabled, so Claude.ai, Claude Desktop, and Claude mobile cannot connect.", "body_md": "I build [Calorie API](https://calorieapi.com). Same food catalog, two doors. A REST API for the app you ship. An MCP server for Claude Code and Cursor.\n\nYou ask for the calories in 180 g of cooked chicken breast. The chat answers in one second. The number looks tidy. The model remembered a textbook row, picked a serving you did not weigh, and never opened a database.\n\nThat guess is fine in a chat. It is a bad base for a meal log, a recipe card, or an app a stranger will trust.\n\n**You are shipping a food app.** You need search, a stable food id, macros per 100 g, and a barcode. The model does not belong in that request.\n\n**You already live in Claude Code or Cursor.** You want the assistant to look the food up, do the math, and show its work.\n\nThe catalog is 4M+ foods: generic foods, branded products, and restaurant items. A row is macros per 100 g, so a portion is a scale. I have not published a hit-rate study, and I have not published a photo-accuracy study. If a page quotes a percent for either, that number is not ours. The requests below are things you can run yourself.\n\nThe REST API has a free tier of 1,000 calls a month. No card.\n\n```\ncurl \"https://calorieapiadmin.com/api/v1/search/foods?q=greek+yogurt&limit=5&verified_only=true\" \\\n  -H \"X-API-Key: YOUR_KEY\"\n```\n\nYou get a page of foods. Each one has an id and macros per 100 g. `verified_only=true` keeps the list to curated rows with complete macros.\n\nThree calls cover a logger:\n\n`GET /api/v1/search/suggest?q=oatm` while the user types. Debounce it. One request per pause.`GET /api/v1/foods/{id}` when they pick a row. That route adds the nutrient list and the serving data.`GET /api/v1/search/barcode/{upc}` for a UPC or EAN. A miss falls through to Open Food Facts in the same JSON shape.\nKeep the key on your server. A shipped mobile binary can be opened. Store the food id, not the name. Names collide. Ids do not.\n\nThe request list, filters, and field names are on the [food database API](https://calorieapi.com/food-database-api) page. The homepage runs a live search before you create a key. Paid plans start at $15 a month for 20,000 calls. An app other people use in production needs Plus or Enterprise, and the header `X-API-Usage-Type: commercial`.\n\n[Calorie MCP](https://calorieapi.com/mcp) is that catalog behind eight tools. Nothing to install. The assistant writes the answer from the tool result.\n\nThis plan is separate from REST. A REST key is refused by the MCP server. An MCP key gets 403 on the REST routes. Personal use is $29 a month, or $228 a year. The trial is 7 days and needs a card. You are charged when it ends unless you cancel first.\n\nThe host looks internal. It is the public URL:\n\n`https://calorieapiadmin.com/mcp/`\n\nClaude Code and Cursor connect, because they can send a header. Claude.ai, Claude Desktop, and Claude mobile stay closed until OAuth is on. It is not on.\n\n**Claude Code**\n\n```\nclaude mcp add --transport http calorie-api \\\n  https://calorieapiadmin.com/mcp/ \\\n  --header \"X-API-Key: YOUR_KEY\"\n```\n\n**Cursor**\n\n```\n{\n  \"mcpServers\": {\n    \"calorie-api\": {\n      \"url\": \"https://calorieapiadmin.com/mcp/\",\n      \"headers\": { \"X-API-Key\": \"YOUR_KEY\" }\n    }\n  }\n}\n```\n\nThe key is shown once, in the dashboard. It is not emailed. Leave it out of the repo.\n\n| Tool | What comes back | \n|---|---|\n| `search_foods` | Matches, macros per 100 g, and a `food_id` | \n| `get_food_nutrition` | The full nutrient list for that id | \n| `suggest_foods` | Short name suggestions | \n| `lookup_barcode` | A UPC or EAN, as macros per 100 g | \n| `calculate_portion` | One food, scaled to a gram weight | \n| `calculate_recipe` | Totals and per serving, up to 40 foods | \n| `calculate_macro_targets` | A daily target from age, sex, weight, height, activity, and goal | \n| `analyze_food_photo` | Foods spotted in a JPEG, PNG, or WebP | \n\nPaid limits are 20 calls a minute, 10,000 successful calls a month, 25 foods per search, and 150 photos a month. The trial is 5 calls a minute, 200 calls total, 10 results, and 10 photos.\n\n`food_id` comes from `search_foods`. The portion tool, the recipe tool, and the nutrient tool all require that id. An invented id gets an error. That error is the product. Scaling a row that does not exist is worse than a failed call.\n\n```\nHow many calories and how much protein are in 180 g of cooked chicken breast?\nSearch the catalog first, then scale it. Do not answer from memory.\n```\n\nA meal, with the banana called out so the assumed weight is visible:\n\n```\nLog this and give me the totals: 220 g plain skyr, 60 g dry oats, one medium banana.\nSearch the catalog for each item, tell me the gram weight you assumed for the banana,\nand scale each one with the portion tool.\n```\n\nA barcode. A 12-digit code often wants a leading zero.\n\n```\nLook up barcode 5000112637922. If a 12-digit code misses, try it again with a\nleading zero before you tell me it is not there.\n```\n\nA picture pasted into the chat stays with the model. The server never sees it. The bytes have to be an argument.\n\n```\nRead ./lunch.jpg, encode it as base64, and pass it to the photo tool as image_base64\nwith content_type image/jpeg. Then search each food it names and scale it to the\nweight you estimated.\n```\n\nRaw base64. No `data:` prefix. JPEG, PNG, or WebP. Up to 2 MB. A URL is refused.\n\nThere is no published accuracy figure for that photo tool. Use it as a first pass. Search and scale the foods it names. The catalog row is the number. The photo is the hint.\n\nThe server keeps no food diary. The log stays in your file or your app.\n\n`calculate_macro_targets` is a formula. It is not a lab test and it is not medical advice. A pregnancy, a medical condition, or an eating-disorder history needs a qualified person to review any plan the chat writes.\n\nAn MCP key is for your own assistant. An app other people pay for needs the REST plan and a commercial license.\n\nShipping the app: start on the free tier and use the [food database API](https://calorieapi.com/food-database-api).\n\nLogging inside Claude Code or Cursor: start the trial on [Calorie MCP](https://calorieapi.com/mcp).\n\nSame foods. The app calls HTTP. The assistant calls tools. The calorie count comes from a row.\n\nPrices and limits above are for October 2026.", "url": "https://wpnews.pro/news/your-model-is-inventing-macros-make-it-look-the-food-up", "canonical_source": "https://dev.to/busybody/your-model-is-inventing-macros-make-it-look-the-food-up-27c9", "published_at": "2026-10-07 16:37:18+00:00", "updated_at": "2026-10-07 16:47:26.187945+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "ai-products"], "entities": ["Calorie API", "Calorie MCP", "Claude Code", "Cursor", "Claude.ai", "Claude Desktop", "Open Food Facts"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/your-model-is-inventing-macros-make-it-look-the-food-up", "markdown": "https://wpnews.pro/news/your-model-is-inventing-macros-make-it-look-the-food-up.md", "text": "https://wpnews.pro/news/your-model-is-inventing-macros-make-it-look-the-food-up.txt", "jsonld": "https://wpnews.pro/news/your-model-is-inventing-macros-make-it-look-the-food-up.jsonld"}}