FatSecret

Go में FatSecret MCP सर्वर — stdio और Streamable HTTP पर भोजन खोज, बारकोड, NLP, छवि पहचान, रेसिपी, भोजन/व्यायाम/वज़न डायरी विषय

दस्तावेज़

FatSecret MCP Server (Go) FatSecret Logo

Go MCP License: MIT Tools Glama Listed on mcpservers.org

[!IMPORTANT] This is not an official MCP server by FatSecret. It uses the FatSecret Platform API which requires a free developer account.

An MCP (Model Context Protocol) server that connects Claude/Cursor to the FatSecret Platform API. Search foods, track your diet, manage recipes, and monitor weight directly from your AI assistant.

56 tools, config in ~/.fatsecret-mcp/config.json.

Built on the official modelcontextprotocol/go-sdk.

✨ Features

  • 🔐 Authentication — Interactive credential setup and OAuth authorization
  • 👨‍👩‍👧 Multi-user — X-MCP-User header over HTTP selects the household member; each authorizes separately, tokens stored per user in the config file
  • ✋ Draft → confirm — Stage any write with prepare_call (validated + human-readable preview), execute with confirm_draft. Set FATSECRET_REQUIRE_CONFIRM=1 to block direct writes entirely
  • 🔍 Food Search — Search FatSecret's extensive food database with detailed nutrition data
  • 📷 Barcode Lookup — Find foods by GTIN-13 barcode
  • 🍳 Recipe Search — Browse and filter recipes by calories, macros, and prep time
  • 📝 Food Diary — Add, edit, copy, and delete food diary entries
  • 🍽️ Saved Meals — Create and manage reusable meal templates
  • ⚖️ Weight Tracking — Record and view weight history
  • 🏃‍♂️ Exercise Tracking — View exercises and manage activity entries
  • ⭐ Favorites — Manage favorite foods and recipes

🏆 Why this server

Comparison as of November 2026, based on public Glama listings. The official server is described in FatSecret's own docs.

This serverOfficial mcp.fatsecret.comStrongest community alternatives
Tools56444 / 39 / 28 (best three)
Diary / weight / exercise writes✅ full❌ read-only✅ (all three)
Write confirmation✅ draft→confirm + strict mode—✅ two of them (prepare/commit style)
Multi-user household✅ X-MCP-User header❌ one seat per person✅ one of them
Works on a free API key✅ (v6 → v1 fallback)❌ Premier onlyvaries by server
Single binary, no runtime✅ Go, ~14 MB, ~10 MB RAM❌ hosted seats❌ Python/JS runtimes
stdio + Streamable HTTP✅remote only✅ one of them, varies otherwise

Endpoints covered here that neither the official server nor — to our knowledge — any community server exposes: create_food_feedback, get_food_classification_levels, commit_exercise_day, create_profile / get_profile_auth.

🚀 Quick Start

Build the binary (Go 1.27+):

go build -o fatsecret-mcp ./cmd/fatsecret-mcp

Or grab a ready binary / Docker image from Releases:

docker run -i --rm \
  -e FATSECRET_CLIENT_ID=... \
  -e FATSECRET_CLIENT_SECRET=... \
  ghcr.io/kondratjev/fatsecret-mcp-go:latest

Add to your MCP client configuration:

{
  "mcpServers": {
    "fatsecret": {
      "command": "/absolute/path/to/fatsecret-mcp"
    }
  }
}

That's it! On first use, the AI will guide you through setup:

  1. check_auth_status — detects missing credentials and tells you what to do
  2. setup_credentials — you provide your API keys (saved to ~/.fatsecret-mcp/config.json)
  3. start_auth → complete_auth — authorize your FatSecret account for diary/weight tools

Alternatively, you can pass credentials as environment variables:

{
  "mcpServers": {
    "fatsecret": {
      "command": "/absolute/path/to/fatsecret-mcp",
      "env": {
        "FATSECRET_CLIENT_ID": "your_client_id",
        "FATSECRET_CLIENT_SECRET": "your_client_secret",
        "FATSECRET_CONSUMER_SECRET": "your_consumer_secret"
      }
    }
  }
}

🔑 Where to Get Credentials

  1. Create a free account at platform.fatsecret.com
  2. Navigate to My Account → API Keys
  3. You'll see three values:
    • Client ID (used for both OAuth 2.0 and OAuth 1.0)
    • Client Secret (OAuth 2.0 - for public food/recipe search)
    • Consumer Secret (OAuth 1.0 - for user profile/diary access)

📖 Step-by-step guide: Getting Started with FatSecret API

💎 Premier Keys

Premier keys work out of the box. FatSecret grants OAuth 2.0 scopes per key, so the server asks for basic premier barcode nlp image-recognition localization feedback and, if FatSecret refuses any of them, keeps just the ones your key is entitled to (free keys end up with basic). Premier keys get Premier-only data such as branded foods and search_foods v6; free keys get search_foods v1. Barcode lookup needs the barcode scope; parse_food_text and recognize_food_image need the paid NLP and image recognition add-ons.

Claude Desktop (Manual)

~/Library/Application Support/Claude/claude_desktop_config.json — same JSON as above.

Claude Code (CLI)

claude mcp add fatsecret -- /absolute/path/to/fatsecret-mcp

Or with env vars:

claude mcp add fatsecret \
  -e FATSECRET_CLIENT_ID=your_client_id \
  -e FATSECRET_CLIENT_SECRET=your_client_secret \
  -e FATSECRET_CONSUMER_SECRET=your_consumer_secret \
  -- /absolute/path/to/fatsecret-mcp

Verify with claude mcp list.

Cursor

  • Settings UI — Settings → MCP → + Add new MCP server, then fill in the command and env
  • Project config — add JSON to .cursor/mcp.json in your project root
  • Global config — add JSON to ~/.cursor/mcp.json

ChatGPT

Remote only — paste your self-hosted URL (Settings → Connectors → Add):

https://<DOMAIN>/<MCP_SECRET>/fatsecret/mcp

OpenCode

~/.config/opencode/opencode.json — note the key is mcp, env is environment:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "fatsecret": {
      "type": "local",
      "command": ["/absolute/path/to/fatsecret-mcp"],
      "environment": {
        "FATSECRET_CLIENT_ID": "your_client_id",
        "FATSECRET_CLIENT_SECRET": "your_client_secret",
        "FATSECRET_CONSUMER_SECRET": "your_consumer_secret"
      },
      "enabled": true
    }
  }
}

Or point at your self-hosted server instead of a local binary:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "fatsecret": {
      "type": "remote",
      "url": "https://<DOMAIN>/<MCP_SECRET>/fatsecret/mcp",
      "enabled": true
    }
  }
}

🛠️ Available Tools

ToolDescription
🔐 Setup & Auth
check_auth_statusCheck if credentials and profile auth are configured. Call this first.
setup_credentialsSave FatSecret API credentials to persistent config
start_authStart OAuth 1.0 authorization — returns URL for user to visit
complete_authComplete OAuth with verifier PIN from authorization page
prepare_callStage a write as a single-use draft (validated + preview, nothing written)
confirm_draftExecute a draft staged by prepare_call
🔍 Food Search (public)
search_foodsSearch the food database
get_foodGet detailed nutrition info for a food
find_food_by_barcodeFind food by GTIN-13 barcode
autocomplete_foodsGet search autocomplete suggestions
🤖 Recognition (paid add-ons)
parse_food_textMatch a free-text meal description to foods and servings (NLP)
recognize_food_imageRecognize foods in a meal photo (image recognition)
create_food_feedbackReport food/barcode data issues, get upload URLs (paid feedback add-on)
🍳 Recipes (public)
search_recipesSearch recipes with filters
get_recipeGet recipe details with ingredients and directions
📚 Reference (public)
get_food_categoriesGet food categories
get_food_sub_categoriesGet food sub categories
get_food_classification_levelsGet food classification hierarchy (Premier)
get_brandsGet food brands
get_recipe_typesGet recipe types
📝 Food Diary (profile auth)
log_mealLog a whole meal in one call (grams or servings) and get day totals
get_food_entriesGet food diary entries for a date
get_food_entries_monthGet monthly nutrition summary (calories & macros per day)
create_food_entryAdd a food diary entry
edit_food_entryEdit a food diary entry
delete_food_entryDelete a food diary entry
copy_food_entriesCopy entries from one date to another
copy_saved_meal_entriesCopy a saved meal to a date
⭐ Favorites (profile auth)
get_favorite_foodsGet favorite foods
add_favorite_foodAdd food to favorites
delete_favorite_foodRemove food from favorites
get_most_eaten_foodsGet most eaten foods
get_recently_eaten_foodsGet recently eaten foods
get_favorite_recipesGet favorite recipes
add_favorite_recipeAdd recipe to favorites
delete_favorite_recipeRemove recipe from favorites
🍽️ Saved Meals (profile auth)
get_saved_mealsGet saved meals
create_saved_mealCreate a saved meal
edit_saved_mealEdit a saved meal
delete_saved_mealDelete a saved meal
get_saved_meal_itemsGet items in a saved meal
add_saved_meal_itemAdd food to a saved meal
edit_saved_meal_itemEdit saved meal item
delete_saved_meal_itemRemove item from saved meal
⚖️ Weight (profile auth)
update_weightRecord weight for a date
get_weight_monthGet weight history for a month
🏃‍♂️ Exercise (profile auth)
get_exercisesGet exercise types
get_exercise_entriesGet exercise entries for a date
edit_exercise_entriesShift exercise time between activities
get_exercise_entries_monthGet exercise data for a month
save_exercise_templateSave exercise template for weekdays
commit_exercise_dayCommit template entries for a date
👤 Profile (profile auth)
get_profileGet user profile info
create_foodCreate a custom food (Premier)
create_profileCreate a detached profile (returns tokens, no switch)
get_profile_authGet auth tokens for a detached profile

API reference: FatSecret Postman Collection

🧪 Test Connection

List tools over stdio (keep stdin open — the server exits on EOF):

{ printf '%s\n' \
 '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"t","version":"1"}}}' \
 '{"jsonrpc":"2.0","method":"notifications/initialized"}' \
 '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'; sleep 4; } | ./fatsecret-mcp

Or serve HTTP and probe it:

PORT=8000 ./fatsecret-mcp &
curl localhost:8000/healthz  # → ok

With credentials:

FATSECRET_CLIENT_ID='...' FATSECRET_CLIENT_SECRET='...' FATSECRET_CONSUMER_SECRET='...' ./fatsecret-mcp

📋 Requirements

  • Go 1.27+ to build (or just the binary — no runtime needed)
  • FatSecret Platform API account (platform.fatsecret.com)
  • MCP-compatible client (Claude Desktop, Cursor, etc.)

🌍 Self-Hosted Server (Docker)

HTTPS is handled by the shared mcp-edge repository. This repo has no Caddy config: the container joins the mcp-edge network and advertises /<MCP_SECRET>/fatsecret/* through Docker labels.

One-time edge setup from this machine (point DNS at the VPS first):

git clone https://github.com/kondratjev/mcp-edge.git
cd mcp-edge
cp .env.example .env   # set DOMAIN and MCP_SECRET
SYNC_ENV=1 VPS_SSH=user@host VPS_DIR=/opt/mcp-edge ./scripts/deploy.sh

Then set this server's credentials and deploy it:

cp .env.example .env   # FATSECRET_* and TZ
SYNC_ENV=1 VPS_SSH=user@host VPS_DIR=/opt/fatsecret-mcp-go ./scripts/deploy.sh

Connect remote clients to https://<DOMAIN>/<MCP_SECRET>/fatsecret/mcp. Every other path returns 404; remote MCP connectors cannot send auth headers, so guard the secret URL like a password. Profile tokens persist in ./data, so setup_credentials and favorites survive restarts and rebuilds.

The image is a static Go binary serving stateless Streamable HTTP natively (no gateway, no per-session processes), so memory stays flat no matter how many prompts hit it.

👨‍👩‍👧 Multi-user (household)

One server can serve several people: over HTTP, the X-MCP-User header selects the member (any string, e.g. anna). Each member authorizes separately — start_auth → complete_auth under their own header — and tokens are stored per user in the config file. check_auth_status reports the current user. Requests without the header (and all stdio clients) use the default member.

Note: remote connectors that can't send custom headers (ChatGPT) only reach the default member — multi-user needs a client with header support (Claude, OpenCode, direct HTTP).

🚀 Deploy to VPS

Single source of truth is this repo — never edit code on the server. The server copy is a clean mirror (git reset --hard; .env and ./data are git-ignored and survive).

VPS_SSH=user@host VPS_DIR=/opt/fatsecret-mcp-go ./scripts/deploy.sh

This pushes the current branch, then on the server pulls it, rebuilds and restarts (docker compose, or legacy docker-compose if v2 is missing). SYNC_ENV=1 copies .env on the first deploy. Export VPS_SSH/VPS_DIR in your shell rc to run bare ./scripts/deploy.sh. On a tiny VPS: docker builder prune -af if a build runs out of disk, add swap if the build OOMs.

🔧 Development

.
├── cmd/fatsecret-mcp/  # entrypoint: stdio vs stateless HTTP, tool registration
├── internal/
│   ├── api/            # Server state, OAuth2 token cache, public/profile requests
│   ├── auth/           # OAuth 2.0 (scopes, detection) + OAuth 1.0 (HMAC-SHA1)
│   ├── config/         # ~/.fatsecret-mcp/config.json + env overrides
│   ├── httpx/          # resilientFetch: timeouts + GET-only retries
│   ├── platform/       # dates, servings, scope-14 detection, search trimming
│   └── tools/          # 56 tool definitions + handlers
├── Dockerfile
└── docker-compose.yml  # MCP on the shared mcp-edge network
go build ./...   # build
go vet ./...     # lint
go test ./...    # tests (OAuth1 RFC 5849 vector, dates, servings)

Debugging with MCP Inspector:

FATSECRET_CLIENT_ID=X FATSECRET_CLIENT_SECRET=X FATSECRET_CONSUMER_SECRET=X npx -y @modelcontextprotocol/inspector /absolute/path/to/fatsecret-mcp

📄 License

MIT License - see LICENSE file for details.