MCP ExplorerExplorer

Nutrient Db Mcp

@LoggerAppon 3 days ago
0Β MIT
FreeCommunity
AI Systems

Overview

What is Nutrient Db Mcp

The USDA MCP Server is a high-performance implementation of the Message Control Protocol designed to provide access to USDA nutritional data. It allows users to perform complex searches and analyses of food and nutrient information through compatible clients such as Claude Desktop.

Use cases

Users can engage with the USDA MCP Server for various purposes, including creating meal plans for specific nutrient deficiencies, comparing the nutritional content of different foods, and finding nutrient-dense foods to enhance diet quality. It is also suitable for research related to nutrition and dietetics.

How to use

To use the USDA MCP Server, users need to clone the repository, set up a Python environment, download USDA data, and initialize the SQLite database. Once configured, users can integrate with Claude Desktop to interact with the server and execute nutritional queries through the MCP protocol.

Key features

Key features of the USDA MCP Server include an optimized SQLite database for storing nutritional data, advanced search capabilities for food and nutrients, nutrient density scoring and analysis, built-in caching for enhanced performance, and support for integration with Claude Desktop.

Where to use

The server can be used in various settings, including home kitchens for meal planning, academic research in nutrition, and professional dietary consultations. It is ideal for anyone looking to analyze and improve dietary habits based on USDA nutritional data.

Content

USDA MCP Server

A high-performance Message Control Protocol (MCP) server implementation for accessing USDA nutritional data through Claude Desktop or other MCP-compatible clients.

Python Version
License: MIT

Features

  • πŸš€ Fast, optimized SQLite database for USDA nutritional data
  • πŸ” Advanced food and nutrient search capabilities
  • πŸ“Š Nutrient density scoring and analysis
  • πŸ’ͺ Support for complex nutritional queries
  • πŸ”„ Built-in caching for improved performance
  • πŸ“± Claude Desktop integration

Prerequisites

  • Python 3.10 or higher
  • SQLite 3.x
  • Claude Desktop (latest version)
  • uv package manager (recommended)

Quick Start

  1. Clone the repository:

    git clone https://github.com/yourusername/usda-mcp-server.git
    cd usda-mcp-server
    
  2. Set up environment:

    # Create and activate virtual environment
    python -m venv venv
    source venv/bin/activate  # Unix
    # OR
    venv\Scripts\activate     # Windows
    
    # Install dependencies
    pip install -r requirements.txt
    
  3. Download USDA data:

    • Visit FoodData Central
    • Download β€œFull Download of All Data Types” (CSV format)
    • Extract files to data/FoodData_Central_csv directory
  4. Initialize database:

    python setup_nutrient_db.py
    
  5. Configure Claude Desktop:

    Edit claude_desktop_config.json:

    {
      "mcpServers": {
        "usda": {
          "command": "usda-mcp-server",
          "args": [
            "--db-path",
            "/path/to/usda.db"
          ]
        }
      }
    }
  6. Start using with Claude Desktop!

Database Setup Details

The database initialization process:

  1. Downloads and processes USDA nutritional data
  2. Creates optimized SQLite schema
  3. Builds indexes for common query patterns
  4. Calculates nutrient density scores
  5. Generates summary statistics
  6. Expect it to compile for multiple hours on most hardware

See Setup Guide: USDA Nutrient Database.md for detailed instructions.

Usage Examples

Ask Claude about nutrition:

Make a full day of recipies based around a vitamin D deficiency.

Compare foods:

Recomend meals that minimize carbohydrates and maximize protien

Find nutrient-dense foods:

Give me a nutrient breakdown for this recipie: [xyz]

Available Resources

The server exposes several resources:

  • usda://foods/list - Searchable food database
  • usda://nutrients/list - Available nutrients
  • usda://foods/{food_id} - Detailed food information
  • usda://foods/nutrient_dense - Foods ranked by nutrient density

Development

Project Structure

usda-mcp-server/
β”œβ”€β”€ src/
β”‚   └── usda_mcp_server/
β”‚       β”œβ”€β”€ server.py      # MCP server implementation
β”‚       β”œβ”€β”€ schema.sql     # Database schema
β”‚       └── tools/         # Utility scripts
β”œβ”€β”€ tests/                 # Test suite
β”œβ”€β”€ docs/                  # Documentation
└── data/                  # Data directory

Running Tests

pytest tests/

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Performance Optimization

The server includes several optimizations:

  • Efficient SQLite schema design
  • Strategic indexing
  • Query result caching
  • Materialized views for common queries
  • WAL journal mode

Troubleshooting

See Troubleshooting Guide for common issues and solutions.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • USDA FoodData Central for the comprehensive nutrient database
  • Claude Desktop team for the MCP protocol specification
  • Contributors and maintainers

Citation

If you use this project in your research, please cite:

@software{usda_mcp_server,
  title = {USDA MCP Server},
  url = {https://github.com/LoggerApp/Nutrient_db_MCP},
  version = {0.1.0},
  year = {2024}
}

Tools

No tools

Comments