Cover image
食品数据中心MCP-Server
Public

食品数据中心MCP-Server

Try Now
2025-04-07

3 years

Works with Finder

1

Github Watches

0

Github Forks

1

Github Stars

Food Data Central MCP Server

This is a Model Context Protocol (MCP) server for exposing API access to the USDA's FoodData Central API.

Features

  • Search for foods in the USDA FoodData Central database
  • Access food nutrient information
  • Paginated results
  • Support for multiple data types (Foundation, SR Legacy, Survey, Branded)

Setup

  1. Clone the repository
  2. Install dependencies:
    npm install
    
  3. Build the project:
    npm run build
    

Running the Server

The server uses stdio transport, which means 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

Using with Claude Desktop

To use this MCP server with Claude Desktop:

  1. Open the Claude Desktop settings:

    • On macOS: Click on the Claude menu and select "Settings..."
    • On Windows: Click on the Claude menu and select "Settings..."
  2. In the Settings pane, click on "Developer" in the left-hand bar, and then click on "Edit Config"

  3. This will create or open a configuration file at:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  4. 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>"
          }
        }
      }
    }
    

    Replace /path/to/food-data-central-mcp-server with the absolute path to this repository, and <INSERT KEY HERE> with your actual USDA API key.

    Note: If you're on Windows, you may need to adjust the PATH value to include your npm global installation directory.

  5. Save the configuration file and restart Claude Desktop

  6. After restarting, you should see a hammer icon in the bottom right corner of the input box. Click on it to see the available tools.

Now Claude will be able to access the Food Data Central API through this MCP server. You can ask Claude to search for foods, get nutrient information, or retrieve detailed food data.

MCP Resources and Tools

Resources

  • food://details - Get detailed information about a specific food by ID

    • Query parameters:
      • fdcId: Food Data Central ID (required)
      • format: Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default)
      • nutrients: Optional. List of up to 25 nutrient numbers (comma-separated)
  • food://foods - Get details for multiple food items using input FDC IDs

    • Query parameters:
      • fdcIds: List of multiple FDC IDs (required, comma-separated)
      • format: Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default)
      • nutrients: Optional. List of up to 25 nutrient numbers (comma-separated)
  • food://list - Get a paged list of foods

    • Query parameters:
      • dataType: Optional. Filter on a specific data type (comma-separated list)
      • pageSize: Optional. Maximum number of results to return (default: 50)
      • pageNumber: Optional. Page number to retrieve (default: 1)
      • sortBy: Optional. Field to sort by
      • sortOrder: Optional. Sort order, "asc" or "desc"

Tools

  • search-foods - Search for foods using keywords
    • Parameters:
      • query: Search terms to find foods (required)
      • dataType: Optional. Filter on a specific data type (array of strings)
      • pageSize: Optional. Maximum number of results to return (default: 50)
      • pageNumber: Optional. Page number to retrieve (default: 1)
      • sortBy: Optional. Field to sort by
      • sortOrder: Optional. Sort order, "asc" or "desc"
      • brandOwner: Optional. Filter results based on the brand owner of the food (only for Branded Foods)
      • tradeChannel: Optional. Filter foods containing any of the specified trade channels
      • startDate: Optional. Filter foods published on or after this date (format: YYYY-MM-DD)
      • endDate: Optional. Filter foods published on or before this date (format: YYYY-MM-DD)

Example Usage

Get food details using the MCP resource:

food://details?fdcId=2345678&format=full

Get multiple foods using the MCP resource:

food://foods?fdcIds=534358,373052,616350

Get a list of foods using the MCP resource:

food://list?dataType=Foundation,SR Legacy&pageSize=10&pageNumber=1

Search for foods using the MCP tool:

{
  "name": "search-foods",
  "arguments": {
    "query": "apple",
    "dataType": ["Foundation", "SR Legacy"],
    "pageSize": 10,
    "pageNumber": 1
  }
}

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Lists Tailwind CSS classes in monospaced font

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • modelcontextprotocol
  • 模型上下文协议服务器

    Reviews

    4 (1)
    Avatar
    user_QNHxwCfg
    2025-04-17

    I've been using the food-data-central-mcp-server by jlfwong, and it has significantly simplified the way I handle food data. The server is robust and user-friendly, making it easy to integrate with other applications. Highly recommend to anyone looking to streamline their food data processes! Check it out on GitHub!