返回市场
MCP-健康追踪服务器

MCP-健康追踪服务器

作者:TheDigitalNinja17 星标更新:2025-05-27

项目介绍

Fitbit MCP 连接器用于AI

Fitbit API CI Coverage Status License: MIT npm version npm downloads

将AI助手连接到您的Fitbit健康数据

让您的AI助手访问您的Fitbit数据,以获得个性化的健康洞察、趋势分析和自动化跟踪。适用于Claude Desktop和其他兼容MCP的AI工具。

功能概述

🏃 运动与活动 - 获取详细的锻炼日志和活动数据
😴 睡眠分析 - 检索睡眠模式和质量指标
⚖️ 体重追踪 - 访问随时间变化的体重趋势
❤️ 心率数据 - 监控心率模式和区域
🍎 营养日志 - 查看食物摄入量、卡路里和宏量营养素
👤 个人资料信息 - 访问基本的Fitbit个人资料详情

您可以向AI询问诸如:“显示我本周的睡眠模式”或“我的平均心率是多少?”等问题

快速开始

🚀 想立即测试这些工具吗?

方案1:从npm安装(推荐)

  1. 获取Fitbit API凭证

    • 创建一个应用,OAuth 2.0 应用类型:Personal
    • 设置回调URL:http://localhost:3000/callback
    • 记录您的客户端ID客户端密钥
  2. 全局安装该包:

npm install -g mcp-fitbit
  1. 添加到您的Claude Desktop配置文件中:
{
  "mcpServers": {
    "fitbit": {
      "command": "mcp-fitbit",
      "args": [],
      "env": {
        "FITBIT_CLIENT_ID": "your_client_id_here",
        "FITBIT_CLIENT_SECRET": "your_client_secret_here"
      }
    }
  }
}
  • 配置文件位置:
    • Windows: %AppData%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  1. 重启Claude Desktop并询问有关您的Fitbit数据的问题!

方案2:开发环境设置

  1. 获取Fitbit API凭证(见安装步骤)
  2. 然后运行:
git clone https://github.com/TheDigitalNinja/mcp-fitbit
cd mcp-fitbit
npm install
# 使用您的Fitbit凭证创建.env文件
npm run dev

两种方案都会在http://localhost:5173打开MCP Inspector,您可以在其中交互式地测试所有工具并处理OAuth流程。

安装

终端用户(npm包)

  1. dev.fitbit.com获取Fitbit API凭证

    • OAuth 2.0 应用类型设置为Personal
    • 回调URL设置为http://localhost:3000/callback
  2. 安装包:

    npm install -g mcp-fitbit
    
  3. 在包目录中创建.env文件:

    当您第一次运行mcp-fitbit时,它会告诉您在哪里创建.env文件。它看起来像这样:

    C:\Users\YourName\AppData\Roaming\npm\node_modules\mcp-fitbit\.env
    
  4. 将您的凭证添加到.env文件中:

    FITBIT_CLIENT_ID=your_client_id_here
    FITBIT_CLIENT_SECRET=your_client_secret_here
    
  5. 运行服务器:

    mcp-fitbit
    

开发者(从源码)

  1. dev.fitbit.com获取Fitbit API凭证

    • OAuth 2.0 应用类型设置为Personal
    • 回调URL设置为http://localhost:3000/callback
  2. 克隆并设置:

    git clone https://github.com/TheDigitalNinja/mcp-fitbit
    cd mcp-fitbit
    npm install
    
  3. 创建.env文件:

    FITBIT_CLIENT_ID=your_client_id_here
    FITBIT_CLIENT_SECRET=your_client_secret_here
    
  4. 构建服务器:

    npm run build
    

可用工具

工具描述参数
get_weight时间段内的体重数据period: 1d, 7d, 30d, 3m, 6m, 1y
get_sleep_by_date_range日期范围内的睡眠日志(最多100天)startDate, endDate (YYYY-MM-DD)
get_exercises某日期之后的活动/锻炼日志afterDate (YYYY-MM-DD), limit (1-100)
get_daily_activity_summary带有目标的每日活动总结date (YYYY-MM-DD)
get_activity_goals用户的活动目标(每日/每周)period: daily, weekly
get_activity_timeseries活动时间序列数据(最多30天)resourcePath, startDate, endDate (YYYY-MM-DD)
get_azm_timeseries活跃区域分钟时间序列(最多1095天)startDate, endDate (YYYY-MM-DD)
get_heart_rate时间段内的心率period: 1d, 7d, 30d, 1w, 1m, 可选date
get_heart_rate_by_date_range日期范围内的平均心率(最多1年)startDate, endDate (YYYY-MM-DD)
get_food_log某一天的完整营养数据date (YYYY-MM-DD 或 "today")
get_nutrition时间段内的个别营养成分resource, period, 可选date
get_nutrition_by_date_range日期范围内的个别营养成分resource, startDate, endDate
get_profile用户个人资料信息

营养资源: caloriesIn, water, protein, carbs, fat, fiber, sodium

活动时间序列资源: steps, distance, calories, activityCalories, caloriesBMR, tracker/activityCalories, tracker/calories, tracker/distance

Claude Desktop

使用npm包(推荐):

添加到claude_desktop_config.json

{
  "mcpServers": {
    "fitbit": {
      "command": "mcp-fitbit",
      "args": []
    }
  }
}

使用本地开发版本:

添加到claude_desktop_config.json

{
  "mcpServers": {
    "fitbit": {
      "command": "node",
      "args": ["C:\\path\\to\\mcp-fitbit\\build\\index.js"]
    }
  }
}

配置文件位置:

  • Windows: %AppData%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

第一次运行授权

当您首次请求AI助手使用Fitbit数据时:

  1. 服务器会在浏览器中打开http://localhost:3000/auth
  2. 登录Fitbit并授予权限
  3. 您会被重定向到成功页面
  4. 您的AI现在可以访问您的Fitbit数据!

开发

npm run lint          # 检查代码质量
npm run format        # 修复格式
npm run build         # 编译TypeScript
npm run dev           # 使用MCP inspector运行

架构: 请参阅TASKS.md了解改进机会和技术细节。