mcpField
F
fitness-nutrition

fitness-nutrition

github.com/nousresearch其他258.1k42 次安装今天更新
代码仓库

关于 fitness-nutrition

面向健身者的运动与营养技能,结合 wger 和 USDA 食物数据查询,以及无需联网的身体指标与训练计算器。

主要功能

  1. 01按肌群、器械或名称查找动作
  2. 02查询食物营养成分
  3. 03计算 BMI、TDEE 和体脂率
  4. 04估算一次最大重复重量与宏量营养素

适用场景

  1. 01按训练器械筛选可做动作
  2. 02查询食物每 100 克的营养数据
  3. 03估算热量需求或体脂率
  4. 04规划宏量营养素比例

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/nousresearch/hermes-agent --skill fitness-nutrition

安装后在 Claude Code 中输入/fitness-nutrition确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
FORMULAS.md
scripts/
body_calc.py
nutrition_search.py

详细介绍

健身与营养

健身教练与运动营养专家技能。包含两个数据源 和离线计算器——健身爱好者所需的一切,尽在一处。

数据源(全部免费,无需 pip 依赖):

离线计算器(纯 Python 标准库):

  • BMI、TDEE(Mifflin-St Jeor)、单次最大重量(Epley/Brzycki/Lombardi)、宏量营养素比例、体脂率(美国海军方法)

使用场景

当用户询问以下内容时,使用此技能:

  • 运动、训练、健身房训练计划、肌群、训练分化
  • 食物宏量营养素、热量、蛋白质含量、膳食计划、热量计算
  • 身体成分:BMI、体脂率、TDEE、热量盈余/缺口
  • 单次最大重量估算、训练百分比、渐进超负荷
  • 减脂、增肌或维持体重时的宏量营养素比例

流程

查询运动(wger API)

所有 wger 公共端点均返回 JSON,且无需身份验证。查询运动时始终添加 format=json 和 language=2(英语)。

步骤 1 — 确定用户的需求:

  • 按肌肉查询 → 使用 /api/v2/exercise/?muscles={id}&language=2&status=2&format=json
  • 按类别查询 → 使用 /api/v2/exercise/?category={id}&language=2&status=2&format=json
  • 按器械查询 → 使用 /api/v2/exercise/?equipment={id}&language=2&status=2&format=json
  • 按名称查询 → 使用 /api/v2/exercise/search/?term={query}&language=english&format=json
  • 查询完整详情 → 使用 /api/v2/exerciseinfo/{exercise_id}/?format=json

步骤 2 — 参考 ID(无需额外调用 API):

运动类别:

ID类别
8手臂
9腿部
10腹部
11胸部
12背部
13肩部
14小腿
15有氧运动

肌肉:

ID肌肉ID肌肉
1肱二头肌2三角肌前束
3前锯肌4胸大肌
5腹外斜肌6腓肠肌
7腹直肌8臀大肌
9斜方肌10股四头肌
11股二头肌12背阔肌
13肱肌14肱三头肌
15比目鱼肌

器械:

ID器械
1杠铃
3哑铃
4健身垫
5瑞士球
6引体向上杆
7无(自重)
8长凳
9上斜凳
10壶铃

步骤 3 — 获取并展示结果:

# Search exercises by name
QUERY="$1"
ENCODED=$(python -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))" "$QUERY")
curl -s "https://wger.de/api/v2/exercise/search/?term=${ENCODED}&language=english&format=json" \
  | python -c "
import json,sys
data=json.load(sys.stdin)
for s in data.get('suggestions',[])[:10]:
    d=s.get('data',{})
    print(f\"  ID {d.get('id','?'):>4} | {d.get('name','N/A'):<35} | Category: {d.get('category','N/A')}\")
"
# Get full details for a specific exercise
EXERCISE_ID="$1"
curl -s "https://wger.de/api/v2/exerciseinfo/${EXERCISE_ID}/?format=json" \
  | python -c "
import json,sys,html,re
data=json.load(sys.stdin)
trans=[t for t in data.get('translations',[]) if t.get('language')==2]
t=trans[0] if trans else data.get('translations',[{}])[0]
desc=re.sub('<[^>]+>','',html.unescape(t.get('description','N/A')))
print(f\"Exercise  : {t.get('name','N/A')}\")
print(f\"Category  : {data.get('category',{}).get('name','N/A')}\")
print(f\"Primary   : {', '.join(m.get('name_en','') for m in data.get('muscles',[])) or 'N/A'}\")
print(f\"Secondary : {', '.join(m.get('name_en','') for m in data.get('muscles_secondary',[])) or 'none'}\")
print(f\"Equipment : {', '.join(e.get('name','') for e in data.get('equipment',[])) or 'bodyweight'}\")
print(f\"How to    : {desc[:500]}\")
imgs=data.get('images',[])
if imgs: print(f\"Image     : {imgs[0].get('image','')}\")
"
# List exercises filtering by muscle, category, or equipment
# Combine filters as needed: ?muscles=4&equipment=1&language=2&status=2
FILTER="$1"  # e.g. "muscles=4" or "category=11" or "equipment=3"
curl -s "https://wger.de/api/v2/exercise/?${FILTER}&language=2&status=2&limit=20&format=json" \
  | python -c "
import json,sys
data=json.load(sys.stdin)
print(f'Found {data.get(\"count\",0)} exercises.')
for ex in data.get('results',[]):
    print(f\"  ID {ex['id']:>4} | muscles: {ex.get('muscles',[])} | equipment: {ex.get('equipment',[])}\")
"
查询营养信息(USDA FoodData Central)

如果设置了 USDA_API_KEY 环境变量,则使用该密钥;否则回退到 DEMO_KEY。 DEMO_KEY = 每小时 30 次请求。免费注册获得的密钥 = 每小时 1,000 次请求。

# Search foods by name
FOOD="$1"
API_KEY="${USDA_API_KEY:-DEMO_KEY}"
ENCODED=$(python -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))" "$FOOD")
curl -s "https://api.nal.usda.gov/fdc/v1/foods/search?api_key=${API_KEY}&query=${ENCODED}&pageSize=5&dataType=Foundation,SR%20Legacy" \
  | python -c "
import json,sys
data=json.load(sys.stdin)
foods=data.get('foods',[])
if not foods: print('No foods found.'); sys.exit()
for f in foods:
    n={x['nutrientName']:x.get('value','?') for x in f.get('foodNutrients',[])}
    cal=n.get('Energy','?'); prot=n.get('Protein','?')
    fat=n.get('Total lipid (fat)','?'); carb=n.get('Carbohydrate, by difference','?')
    print(f\"{f.get('description','N/A')}\")
    print(f\"  Per 100g: {cal} kcal | {prot}g protein | {fat}g fat | {carb}g carbs\")
    print(f\"  FDC ID: {f.get('fdcId','N/A')}\")
    print()
"
# Detailed nutrient profile by FDC ID
FDC_ID="$1"
API_KEY="${USDA_API_KEY:-DEMO_KEY}"
curl -s "https://api.nal.usda.gov/fdc/v1/food/${FDC_ID}?api_key=${API_KEY}" \
  | python -c "
import json,sys
d=json.load(sys.stdin)
print(f\"Food: {d.get('description','N/A')}\")
print(f\"{'Nutrient':<40} {'Amount':>8} {'Unit'}\")
print('-'*56)
for x in sorted(d.get('foodNutrients',[]),key=lambda x:x.get('nutrient',{}).get('rank',9999)):
    nut=x.get('nutrient',{}); amt=x.get('amount',0)
    if amt and float(amt)>0:
        print(f\"  {nut.get('name',''):<38} {amt:>8} {nut.get('unitName','')}\")
"
离线计算器

批量操作请使用 scripts/ 中的辅助脚本, 单次计算则可直接运行:

  • python scripts/body_calc.py bmi <weight_kg> <height_cm>
  • python scripts/body_calc.py tdee <weight_kg> <height_cm> <age> <M|F> <activity 1-5>
  • python scripts/body_calc.py 1rm <weight> <reps>
  • python scripts/body_calc.py macros <tdee_kcal> <cut|maintain|bulk>
  • python scripts/body_calc.py bodyfat <M|F> <neck_cm> <waist_cm> [hip_cm] <height_cm>

各公式的科学依据请参阅 references/FORMULAS.md。


注意事项

  • wger 运动端点默认返回所有语言的结果 — 英文查询时务必添加 language=2
  • wger 包含未经验证的用户提交内容 — 添加 status=2,仅获取已批准的运动
  • USDA DEMO_KEY 每小时限 30 次请求 — 批量请求之间添加 sleep 2,或申请免费密钥
  • USDA 数据按 每 100g 计算 — 提醒用户根据实际食用份量换算
  • BMI 无法区分肌肉和脂肪 — 肌肉发达的人 BMI 偏高并不一定意味着不健康
  • 体脂率公式是估算值(±3-5%)— 若需精确结果,建议进行 DEXA 扫描
  • 1RM 公式在超过 10 次重复时准确度会下降 — 使用 3-5 次一组可获得最佳估算结果
  • wger 的 exercise/search 端点使用 term 而不是 query 作为参数名称

验证

运行运动搜索后:确认结果包含运动名称、肌群和器材。 查询营养信息后:确认返回每 100g 的营养素数据,包括 kcal、蛋白质、脂肪和碳水化合物。 运行计算器后:检查输出是否合理(例如,大多数成年人的 TDEE 应为 1500-3500)。


快速参考

任务来源端点
按名称搜索运动wgerGET /api/v2/exercise/search/?term=&language=english
运动详情wgerGET /api/v2/exerciseinfo/{id}/
按肌肉筛选wgerGET /api/v2/exercise/?muscles={id}&language=2&status=2
按器材筛选wgerGET /api/v2/exercise/?equipment={id}&language=2&status=2
列出类别wgerGET /api/v2/exercisecategory/
列出肌肉wgerGET /api/v2/muscle/
搜索食物USDAGET /fdc/v1/foods/search?query=&dataType=Foundation,SR Legacy
食物详情USDAGET /fdc/v1/food/{fdcId}
BMI / TDEE / 1RM / 营养素离线python scripts/body_calc.py

评论

支持 Markdown