Labsco
FelipeAdachi logo

FoodData Central

โ˜… 3

from FelipeAdachi

Access the USDA's FoodData Central database for comprehensive food and nutrient information.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredNeeds API keys

Food Data Central MCP Server

A Model Context Protocol (MCP) server for accessing the USDA's FoodData Central database. This server provides AI agents with the ability to search for foods, get detailed nutritional information, and access comprehensive food data from the USDA's database.

Overview

This project demonstrates how to build an MCP server that enables AI agents to access the USDA FoodData Central API. It allows searching for foods, retrieving detailed nutritional information, and accessing comprehensive food data through keyword search and structured queries.

This project is based on Cole Medin's excellent MCP-Mem0 project and jlfwong's Food Data Central MCP Server.

Features

The server provides three essential food data access tools:

  1. search_foods: Search for foods using keywords with optional filters for data type, brand, date range, etc.
  2. get_food_details: Get comprehensive nutritional and ingredient information for a specific food item by FDC ID
  3. get_multiple_foods: Retrieve detailed information for multiple foods at once (up to 20 items)

Getting Your API Key

  1. Visit the USDA FoodData Central API Guide
  2. Sign up for a free API key
  3. Add the key to your .env file as USDA_API_KEY

Integration with MCP Clients

SSE Configuration

Once you have the server running with SSE transport, you can connect to it using this configuration:

{
  "mcpServers": {
    "food-data-central": {
      "transport": "sse",
      "url": "http://localhost:8050/sse"
    }
  }
}

Note for Windsurf users: Use serverUrl instead of url in your configuration:

{
  "mcpServers": {
    "food-data-central": {
      "transport": "sse",
      "serverUrl": "http://localhost:8050/sse"
    }
  }
}

Note for n8n users: Use host.docker.internal instead of localhost since n8n has to reach outside of its own container to the host machine:

So the full URL in the MCP node would be: http://host.docker.internal:8050/sse

Make sure to update the port if you are using a value other than the default 8050.

Python with Stdio Configuration

Add this server to your MCP configuration for Claude Desktop, Windsurf, or any other MCP client:

{
  "mcpServers": {
    "food-data-central": {
      "command": "your/path/to/food-data-central-mcp/.venv/Scripts/python.exe",
      "args": ["your/path/to/food-data-central-mcp/src/main.py"],
      "env": {
        "TRANSPORT": "stdio",
        "USDA_API_KEY": "YOUR-API-KEY"
      }
    }
  }
}

Docker with Stdio Configuration

{
  "mcpServers": {
    "food-data-central": {
      "command": "docker",
      "args": ["run", "--rm", "-i", 
               "-e", "TRANSPORT", 
               "-e", "USDA_API_KEY", 
               "food-data-central-mcp"],
      "env": {
        "TRANSPORT": "stdio",
        "USDA_API_KEY": "YOUR-API-KEY"
      }
    }
  }
}

API Reference

The server provides access to the USDA FoodData Central API endpoints:

  • Search Foods (/v1/foods/search)
  • Food Details (/v1/food/{fdcId})
  • Multiple Foods (/v1/foods)

All data returned follows the official USDA FoodData Central API schema and includes comprehensive nutritional information, ingredients, serving sizes, and more.