FatSecret MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FatSecret MCP Server search for grilled chicken breast and show me its nutrition info"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FatSecret MCP Server
A Model Context Protocol (MCP) server that provides access to the FatSecret nutrition database API with full 3-Legged OAuth authentication support.
Features
Complete OAuth 1.0a Implementation: Full 3-legged OAuth flow for user authentication
Food Database Access: Search and retrieve detailed nutrition information
Recipe Database: Search for recipes and get detailed cooking instructions
User Data Management: Access user food diaries and add food entries
Secure Credential Storage: Encrypted storage of API credentials and tokens
Related MCP server: fitatu-wrapper
Getting Started
Prerequisites
Node.js (v14 or higher)
npm or yarn
A FatSecret developer account
Installation
# Clone the repository
git clone https://github.com/your-username/fatsecret-mcp.git
cd fatsecret-mcp
# Install dependencies
npm install
# Build the TypeScript
npm run buildSetup
1. Get FatSecret API Credentials
Visit the FatSecret Platform
Create a developer account and register your application
Note down your Client ID and Client Secret
2. Configure the MCP Server
The server needs to be configured in your MCP client (like Claude Desktop). Add this to your MCP configuration:
{
"mcpServers": {
"fatsecret": {
"command": "node",
"args": ["path/to/fatsecret-mcp-server/dist/index.js"]
}
}
}3. Authentication Process
Option 1: Using the OAuth Console Utility (Recommended)
The easiest way to authenticate is using the included OAuth console utility:
# Make sure you've built the project first
npm run build
# Run the OAuth console utility
node dist/cli.jsThis interactive utility will:
Ask for your Client ID and Client Secret
Save them securely in
~/.fatsecret-mcp-config.jsonGuide you through the OAuth flow:
Opens your browser to the FatSecret authorization page
Prompts you to paste the verifier code after authorization
Saves the access tokens for future use
Option 2: Manual Authentication via MCP Tools
If you prefer to authenticate through the MCP interface (e.g., in Claude):
Set your API credentials:
Use tool: set_credentials Parameters: - clientId: "your_client_id_here" - clientSecret: "your_client_secret_here"Start the OAuth flow:
Use tool: start_oauth_flow Parameters: - callbackUrl: "oob" (for out-of-band authentication)Visit the authorization URL provided in the response:
Log in to your FatSecret account (or create one)
Click "Allow" to authorize the application
Copy the verifier code shown on the page
Complete the OAuth flow:
Use tool: complete_oauth_flow Parameters: - requestToken: [from step 2 response] - requestTokenSecret: [from step 2 response] - verifier: [the code you copied from the authorization page]
Option 3: Using Environment Variables
You can also provide credentials via environment variables:
# Create a .env file in the project root
CLIENT_ID=your_client_id_here
CLIENT_SECRET=your_client_secret_here
# The server will automatically load these on startupNote: You'll still need to complete the OAuth flow for user-specific operations.
Usage
1. Set API Credentials
First, set your FatSecret API credentials:
Use the set_credentials tool with your Client ID and Client Secret2. Authenticate a User (3-Legged OAuth)
For user-specific operations, you need to complete the OAuth flow:
1. Use start_oauth_flow tool (with callback URL or "oob" for out-of-band)
2. Visit the provided authorization URL
3. Authorize the application and get the verifier code
4. Use complete_oauth_flow tool with the request token, secret, and verifier3. Use the API
Once authenticated, you can use all available tools:
Food Search and Information
search_foods: Search for foods in the databaseget_food: Get detailed nutrition information for a specific food
Recipe Search and Information
search_recipes: Search for recipesget_recipe: Get detailed recipe information including ingredients and instructions
User Data (Requires Authentication)
get_user_profile: Get the authenticated user's profileget_user_food_entries: Get food diary entries for a specific dateadd_food_entry: Add a food entry to the user's diary
Utility
check_auth_status: Check current authentication status
Available Tools
Authentication Tools
set_credentials
Set your FatSecret API credentials.
Parameters:
clientId(string, required): Your FatSecret Client IDclientSecret(string, required): Your FatSecret Client Secret
start_oauth_flow
Start the 3-legged OAuth flow.
Parameters:
callbackUrl(string, optional): OAuth callback URL (default: "oob")
complete_oauth_flow
Complete the OAuth flow with authorization.
Parameters:
requestToken(string, required): Request token from start_oauth_flowrequestTokenSecret(string, required): Request token secret from start_oauth_flowverifier(string, required): OAuth verifier from authorization
check_auth_status
Check current authentication status.
Food Database Tools
search_foods
Search for foods in the FatSecret database.
Parameters:
searchExpression(string, required): Search termpageNumber(number, optional): Page number (default: 0)maxResults(number, optional): Max results per page (default: 20)
get_food
Get detailed information about a specific food.
Parameters:
foodId(string, required): FatSecret food ID
Recipe Database Tools
search_recipes
Search for recipes in the FatSecret database.
Parameters:
searchExpression(string, required): Search termpageNumber(number, optional): Page number (default: 0)maxResults(number, optional): Max results per page (default: 20)
get_recipe
Get detailed information about a specific recipe.
Parameters:
recipeId(string, required): FatSecret recipe ID
User Data Tools (Requires Authentication)
get_user_profile
Get the authenticated user's profile information.
get_user_food_entries
Get user's food diary entries for a specific date.
Parameters:
date(string, optional): Date in YYYY-MM-DD format (default: today)
add_food_entry
Add a food entry to the user's diary.
Parameters:
foodId(string, required): FatSecret food IDservingId(string, required): Serving ID for the foodquantity(number, required): Quantity of the servingmealType(string, required): Meal type (breakfast, lunch, dinner, snack)date(string, optional): Date in YYYY-MM-DD format (default: today)
Example Workflow
Setup Credentials:
Tool: set_credentials - clientId: "your_client_id" - clientSecret: "your_client_secret"Search for Foods:
Tool: search_foods - searchExpression: "chicken breast"Get Food Details:
Tool: get_food - foodId: "12345"Authenticate User (if needed):
Tool: start_oauth_flow - callbackUrl: "oob" # Follow the authorization URL, then: Tool: complete_oauth_flow - requestToken: "from_start_oauth_flow" - requestTokenSecret: "from_start_oauth_flow" - verifier: "from_authorization_page"Add Food to Diary:
Tool: add_food_entry - foodId: "12345" - servingId: "67890" - quantity: 1 - mealType: "lunch"
Configuration Storage
The server stores configuration (credentials and tokens) in ~/.fatsecret-mcp-config.json. This file contains:
API credentials (Client ID and Secret)
OAuth access tokens (when authenticated)
User ID (when authenticated)
Security Notes
Credentials are stored locally in your home directory
OAuth tokens are securely managed using proper HMAC-SHA1 signing
All API communications use HTTPS
The server implements proper OAuth 1.0a security measures
API Reference
This server implements the FatSecret Platform API. For detailed API documentation, visit:
Error Handling
The server provides detailed error messages for common issues:
Missing or invalid credentials
OAuth flow errors
API rate limiting
Network connectivity issues
Invalid parameters
Testing
Testing from the Command Line
The project includes several test utilities:
1. Interactive Test Tool
# Run the interactive test menu
node test-interactive.jsThis provides a menu-driven interface to test all MCP tools.
2. Date Conversion Test
# Test the date conversion logic
node test-date-conversion.jsVerifies that dates are correctly converted to FatSecret's "days since epoch" format.
3. Direct JSON-RPC Testing
# Send test messages via pipe
node test-mcp.js | node dist/index.jsTesting in Claude Desktop
Restart Claude Desktop after configuring the MCP server
Look for "fatsecret" in the available tools
Start by using
check_auth_statusto verify the connection
Troubleshooting
Common Issues
"Invalid integer value: date"
The FatSecret API expects dates as days since epoch (1970-01-01)
The server automatically converts YYYY-MM-DD format dates
If you get this error, ensure you're using the latest version
OAuth Authentication Fails
Verify your Client ID and Client Secret are correct
Ensure you're using the correct URLs (authentication.fatsecret.com for OAuth)
Check that you're copying the entire verifier code from the authorization page
Server Not Found in Claude
Ensure the path in your MCP configuration is absolute, not relative
Verify the server was built successfully (
npm run build)Check Claude's logs for any error messages
"User authentication required"
Complete the OAuth flow using either the CLI utility or MCP tools
Check authentication status with
check_auth_statustoolTokens are saved in
~/.fatsecret-mcp-config.json
Development
To modify or extend the server:
# Install dependencies
npm install
# Build and run
npm run build
npm start
# Development mode with auto-rebuild
npm run devProject Structure
fatsecret-mcp/
├── src/
│ ├── index.ts # Main MCP server implementation
│ └── cli.ts # OAuth console utility
├── dist/ # Compiled JavaScript files
├── test-*.js # Test utilities
├── package.json
├── tsconfig.json
└── README.mdLicense
MIT License - see LICENSE file for details.
Available Tools
12 toolsadd_food_entryC
Add a food entry to the user's diary
Inputs: foodId (required), mealType (required), quantity (required), servingId (required), +1 more.
check_auth_statusB
Check if the user is authenticated with FatSecret
Inputs: no named parameters.
complete_oauth_flowB
Complete the OAuth flow with the authorization code/verifier
Inputs: verifier (required), requestToken (required), requestTokenSecret (required).
get_foodB
Get detailed information about a specific food item
Inputs: foodId (required).
get_recipeB
Get detailed information about a specific recipe
Inputs: recipeId (required).
get_user_food_entriesC
Get user's food diary entries for a specific date
Inputs: date.
get_user_profileB
Get the authenticated user's profile information
Inputs: no named parameters.
get_weight_monthC
Get user's weight entries for a specific month
Inputs: date.
search_foodsC
Search for foods in the FatSecret database
Inputs: searchExpression (required), maxResults, pageNumber.
search_recipesC
Search for recipes in the FatSecret database
Inputs: searchExpression (required), maxResults, pageNumber.
set_credentialsC
Set FatSecret API credentials (Client ID and Client Secret)
Inputs: clientId (required), clientSecret (required).
start_oauth_flowB
Start the 3-legged OAuth flow to get user authorization
Inputs: callbackUrl.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools form clear search/get pairs (search_foods/get_food, search_recipes/get_recipe) with distinct resources and actions. The auth tools (set_credentials, start_oauth_flow, complete_oauth_flow, check_auth_status) could be slightly confusable for an agent setting up auth, but their descriptions differentiate them well.
All tool names use consistent snake_case with a verb_noun structure (search_foods, get_recipe, add_food_entry, check_auth_status). No mixed conventions or vague verbs; the pattern is predictable throughout.
12 tools is well within a reasonable range and each tool targets a distinct operation (auth, food/recipe lookup, diary, profile, weight). No filler tools; the count fits the server's scope.
Core read and create paths for food diary entries exist, plus food/recipe search and profile retrieval, but there is no update/delete for food entries and no way to add weight entries (only get_weight_month). These gaps limit the diary and weight lifecycle coverage.
Maintenance
Related MCP Connectors
Read your private Enshape diary and log meals through scoped account authorization.
Log meals, check calories and macros, set up a nutrition plan, and search foods.
Discover, preview, and save recipes and meal plans with RecipeBee; private actions require OAuth.
Food nutrition lookup via natural language, barcode, and image. Database of 1,000,000+ foods.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables tracking food intake and nutrition using the USDA FoodData Central database. Supports logging meals, setting daily nutrition goals, viewing food diaries, and analyzing nutrition trends over time with local SQLite storage.9 npm1MIT
- AlicenseCqualityDmaintenanceEnables programmatic access to Fitatu nutrition tracking via MCP tools for login, food search, product lookup, daily nutrition read, and adding entries.9MIT
- AlicenseNot gradedqualityDmaintenanceEnables searching and retrieving nutrition data, recipes, and managing food diary entries through the FatSecret API.MIT
- AlicenseBqualityCmaintenanceEnables searching FatSecret's food and recipe database, and managing personal food diary, weight, exercise, saved meals, and favorites, with multi-user support and secure OAuth authentication.28Functional Source , Version 1.1, ALv2 Future