关于 Health Information API
Health Information API 是面向健康与营养应用开发者的 FastAPI 应用,提供身体指标、每日宏量营养素及食物营养计算器。
主要功能
- 01BMI 计算
- 02体型估算
- 03美国海军法体脂率计算
- 04每日热量和宏量营养素目标
- 05通过 USDA FoodData Central 查询食物营养
适用场景
- 01根据身高和体重计算 BMI
- 02根据身体围度估算体脂率
- 03制定每日热量和宏量营养素目标
- 04汇总食谱食材的营养值
MCP 相关
该应用通过 FastAPI-MCP 向 MCP 客户端提供健康和营养计算器。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
暂未收录安装方式
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
健康信息 API
一个使用 FastAPI-MCP 提供各种健康和营养计算器的 FastAPI 应用。
功能
- BMI 计算器
- 体型框架尺寸计算器
- 体脂百分比计算器(美国海军方法)
- 常量营养素计算器
- 食物营养计算器(使用 USDA FoodData Central API)
安装
- 克隆仓库:
git clone https://github.com/yourusername/bmi_calc.git
cd bmi_calc
- 安装依赖:
pip install -r requirements.txt
- 设置环境变量:
# For the USDA FoodData Central API
# Get your API key from https://fdc.nal.usda.gov/api-key-signup.html
export USDA_API_KEY="your_api_key_here"
# (Optional) For the OpenAI API
export OPENAI_API_KEY="your_api_key_here"
运行应用
uvicorn main:app --reload
API 将在 http://localhost:8000 上提供服务。
API 文档
应用运行后,可通过以下地址访问交互式 API 文档:
- Swagger UI:http://localhost:8000/docs
- ReDoc:http://localhost:8000/redoc
API 端点
BMI 计算器
端点: POST /bmi
根据体重和身高计算身体质量指数(BMI)。
请求正文:
{
"weight_kg": 70,
"height_cm": 175
}
响应:
{
"bmi": 22.86,
"category": "Normal weight"
}
体型框架尺寸计算器
端点: POST /body-frame
根据腕围和身高确定体型框架尺寸。
请求正文:
{
"wrist_circumference_cm": 18,
"height_cm": 180,
"gender": "male"
}
响应:
{
"frame_size": "MEDIUM"
}
体脂百分比计算器
端点: POST /body-fat
使用美国海军方法计算体脂百分比。
请求正文(男性):
{
"gender": "male",
"age": 30,
"weight_kg": 80,
"height_cm": 180,
"neck_circumference_cm": 38,
"waist_circumference_cm": 85
}
请求正文(女性):
{
"gender": "female",
"age": 30,
"weight_kg": 65,
"height_cm": 165,
"neck_circumference_cm": 32,
"waist_circumference_cm": 70,
"hip_circumference_cm": 95
}
响应:
{
"body_fat_percentage": 15.3,
"category": "Fitness"
}
常量营养素计算器
端点: POST /macros
计算每日热量和常量营养素目标。
请求正文:
{
"gender": "male",
"age": 30,
"weight_kg": 80,
"height_cm": 180,
"activity_level": "moderate",
"goal": "maintain",
"body_fat_percentage": 15
}
响应:
{
"calories": 2800,
"protein_g": 122,
"carbs_g": 350,
"fat_g": 78
}
食物营养计算器
端点: GET /food-nutrition
计算一份食材清单及其用量的营养成分。
查询参数:
ingredients:食材列表(例如,'apple'、'chicken breast')amounts:以克为单位的用量列表,与各食材一一对应
请求示例:
GET /food-nutrition?ingredients=apple&ingredients=chicken%20breast&amounts=100&amounts=150
响应:
{
"total_calories": 278.5,
"total_protein_g": 31.45,
"total_carbs_g": 14.8,
"total_fat_g": 8.7,
"total_fiber_g": 2.4,
"total_sugar_g": 10.4,
"foods": [
{
"name": "Apple, raw",
"amount_g": 100,
"calories": 52,
"protein_g": 0.3,
"carbs_g": 13.8,
"fat_g": 0.2,
"fiber_g": 2.4,
"sugar_g": 10.4
},
{
"name": "Chicken, breast, meat only, cooked, roasted",
"amount_g": 150,
"calories": 226.5,
"protein_g": 31.15,
"carbs_g": 1,
"fat_g": 8.5,
"fiber_g": 0,
"sugar_g": 0
}
]
}
运行测试
pytest -v
许可证
MIT
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。