This MCP server provides access to the USDA's FoodData Central API, allowing you to search for foods and retrieve detailed nutrient information through Model Context Protocol. It's designed to be integrated with AI assistant applications like Claude Desktop.
To use this server, you'll need:
npm install
npm run build
The server uses stdio transport, meaning it's designed to be run as a subprocess by an MCP client. To run it directly:
# Set the USDA API key as an environment variable
export USDA_API_KEY=your-api-key-here
npm start
For development with hot reloading:
# Set the USDA API key as an environment variable
export USDA_API_KEY=your-api-key-here
npm run dev
Open the Claude Desktop settings:
Click on "Developer" in the left sidebar, then "Edit Config"
Add the Food Data Central MCP server to the configuration file:
{
"mcpServers": {
"food-data-central": {
"command": "npx",
"args": ["tsx", "/path/to/food-data-central-mcp-server/src/index.ts"],
"env": {
"PATH": "/opt/homebrew/bin",
"USDA_API_KEY": "<INSERT KEY HERE>"
}
}
}
}
Be sure to:
/path/to/food-data-central-mcp-server
with the absolute path to the repository<INSERT KEY HERE>
Save the configuration file and restart Claude Desktop
After restarting, you should see a hammer icon in the bottom right corner of the input box, which indicates access to the available tools.
food://details - Get detailed information about a specific food
fdcId
: Food Data Central ID (required)format
: Optional. 'abridged' or 'full' (default)nutrients
: Optional. List of up to 25 nutrient numbers (comma-separated)food://foods - Get details for multiple food items
fdcIds
: List of multiple FDC IDs (required, comma-separated)format
: Optional. 'abridged' or 'full' (default)nutrients
: Optional. List of up to 25 nutrient numbers (comma-separated)food://list - Get a paged list of foods
dataType
: Optional. Filter on specific data types (comma-separated)pageSize
: Optional. Maximum results to return (default: 50)pageNumber
: Optional. Page number to retrieve (default: 1)sortBy
: Optional. Field to sort bysortOrder
: Optional. Sort order, "asc" or "desc"query
: Search terms to find foods (required)dataType
: Optional. Filter on specific data types (array)pageSize
: Optional. Maximum results to return (default: 50)pageNumber
: Optional. Page number to retrieve (default: 1)sortBy
: Optional. Field to sort bysortOrder
: Optional. Sort order, "asc" or "desc"brandOwner
: Optional. Filter by brand owner (Branded Foods only)tradeChannel
: Optional. Filter by trade channelsstartDate
: Optional. Filter by publish date (YYYY-MM-DD)endDate
: Optional. Filter by publish date (YYYY-MM-DD)To get information for a specific food item:
food://details?fdcId=2345678&format=full
To get details for several foods at once:
food://foods?fdcIds=534358,373052,616350
To get a list of foods with pagination:
food://list?dataType=Foundation,SR Legacy&pageSize=10&pageNumber=1
To search for foods using the MCP tool:
{
"name": "search-foods",
"arguments": {
"query": "apple",
"dataType": ["Foundation", "SR Legacy"],
"pageSize": 10,
"pageNumber": 1
}
}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "food-data-central" '{"command":"npx","args":["tsx","/path/to/food-data-central-mcp-server/src/index.ts"],"env":{"PATH":"/opt/homebrew/bin","USDA_API_KEY":"<INSERT KEY HERE>"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"food-data-central": {
"command": "npx",
"args": [
"tsx",
"/path/to/food-data-central-mcp-server/src/index.ts"
],
"env": {
"PATH": "/opt/homebrew/bin",
"USDA_API_KEY": "<INSERT KEY HERE>"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"food-data-central": {
"command": "npx",
"args": [
"tsx",
"/path/to/food-data-central-mcp-server/src/index.ts"
],
"env": {
"PATH": "/opt/homebrew/bin",
"USDA_API_KEY": "<INSERT KEY HERE>"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect