fitbit-mcp
fitbit-mcp
OAuth PKCE, 로컬 SQLite 캐시 및 추세 분석 기능을 갖춘 Fitbit Web API용 MCP 서버입니다.
Claude Code 및 기타 MCP 클라이언트를 위해 설계되었습니다. Fitbit 데이터를 로컬 데이터베이스로 동기화하여 빠르고 오프라인 상태에서도 쿼리가 가능합니다. 초기 동기화 이후에는 API 호출이 필요하지 않습니다.
주요 기능
OAuth 2.0 PKCE - 안전한 인증 흐름, 클라이언트 시크릿 불필요
로컬 SQLite 캐시 - 한 번 동기화로 즉시 쿼리
증분 동기화 - 마지막 동기화 이후의 새로운 데이터만 가져옴
9개의 MCP 도구 - 동기화, 쿼리(7개 데이터 유형) 및 추세 분석
라이브 모드 - 캐시를 우회하여 API를 직접 쿼리
CLI - 명령줄에서 인증 설정, 동기화 및 JSON 가져오기
속도 제한 처리 - 429 응답 시 자동 재시도
Related MCP server: Fitbit MCP
데이터 유형
도구 | 데이터 |
| 안정 시 심박수, 심박수 구간 |
| 걸음 수, 칼로리, 활동 시간, 거리 |
| 운동 세션 (이름, 지속 시간, 심박수, 칼로리) |
| 지속 시간, 효율성, 수면 단계 |
| 체중, BMI, 체지방률 |
| 혈중 산소 포화도 (평균/최소/최대) |
| 심박 변이도 (RMSSD) |
| 집계된 평균 (주간/월간/분기별) |
요구 사항
Python 3.13+
등록된 개인용 앱이 있는 Fitbit 개발자 계정
설정
1. 설치
pip install .또는 개발용:
pip install -e ".[dev]"2. Fitbit 앱 등록
dev.fitbit.com/apps로 이동하여 새 앱을 생성합니다.
OAuth 2.0 Application Type을 Personal로 설정합니다.
Redirect URL을
http://localhost:8080으로 설정합니다.Client ID를 기록해 둡니다 (클라이언트 시크릿은 필요하지 않습니다. PKCE는 사용하지 않음).
3. 인증
fitbit-mcp auth이 명령은 브라우저를 열어 Fitbit 로그인을 진행하고, PKCE를 통해 인증 코드를 교환하며 토큰을 로컬에 저장합니다.
토큰은 ~/.config/fitbit-mcp/fitbit_tokens.json에 0600 권한으로 저장됩니다. 액세스 토큰은 8시간 후에 만료되며 자동으로 갱신됩니다. 리프레시 토큰은 90일 동안 활동이 없으면 만료됩니다.
4. Claude Code에 등록
claude mcp add -s user fitbit -- fitbit-mcp5. 첫 동기화 (선택 사항)
쿼리 도구는 처음 사용할 때 자동으로 동기화되므로 이 단계를 건너뛸 수 있습니다. 캐시를 미리 채우거나 더 긴 기록을 동기화하려면 다음을 실행하세요:
fitbit-mcp sync --days 30CLI 사용법
fitbit-mcp Start the MCP server (stdio transport)
fitbit-mcp auth Interactive OAuth setup
fitbit-mcp sync Sync data to local cache
--days N Days of history for first sync (default: 30)
--types TYPE,... Data types to sync (default: all)
fitbit-mcp import Import existing JSON data files
--data-dir PATH Directory containing JSON filesMCP 도구 참조
쿼리 도구는 데이터 유형별로 매일 첫 번째 쿼리 시 자동으로 동기화됩니다. 캐시를 완전히 우회하고 API에서 직접 가져오려면 live=True를 사용하세요.
모든 쿼리 도구는 다음 공통 매개변수를 허용합니다:
start_date- 시작 날짜 (YYYY-MM-DD,YYYY-MM또는30d(상대적)). 기본값: 최근 30일.end_date- 종료 날짜 (YYYY-MM-DD). 기본값: 오늘.live- true인 경우, 캐시 대신 Fitbit API에서 가져옵니다 (자동 동기화 우회).
fitbit_get_exercises는 다음도 허용합니다:
exercise_type- 활동 이름으로 필터링 (대소문자 구분 없는 부분 문자열 일치), 예:"cycling","walk","run". 기본값: 모든 유형.
fitbit_sync
Fitbit API에서 로컬 SQLite 캐시로 데이터를 동기화합니다. 쿼리 도구는 하루에 처음 사용할 때 자동으로 이 작업을 호출하므로, 더 긴 기록이 필요하거나 강제로 새로 고침해야 할 때만 명시적으로 호출하면 됩니다.
data_types- 동기화할 데이터:all,heart_rate,activity,exercises,sleep,weight,spo2,hrv. 쉼표로 구분. 기본값:all.days- 첫 동기화 시 가져올 기록 일수 (기본값: 30). 이후 동기화는 증분 방식으로 진행됩니다.
fitbit_trends
캐시된 데이터에서 집계된 추세 분석을 수행합니다.
data_type- 분석할 데이터:heart_rate,activity,exercises,sleep,weight,spo2,hrv. 기본값:activity.period- 집계 단위:weekly,monthly,quarterly. 기본값:monthly.start_date- 시작 날짜. 기본값: 최근 12개월 (365일).end_date- 종료 날짜. 기본값: 오늘.compare- 두 기간 비교:last_30d vs previous_30d,2026-03 vs 2026-02,2026-Q1 vs 2025-Q4. 설정 시period/start_date/end_date는 무시됩니다.
OAuth 범위
설정 중에 다음 Fitbit API 범위가 요청됩니다:
범위 | 액세스하는 데이터 |
| 걸음 수, 칼로리, 활동 시간, 거리 |
| 안정 시 심박수 및 심박수 구간 |
| 수면 지속 시간 및 단계 |
| 체중, BMI, 체지방률 |
| SpO2 (혈중 산소) |
| 사용자 프로필 (사용자 ID, 표시 이름) |
이 범위들은 9개 도구 모두에 필요한 최소 범위입니다. 일부만 필요한 경우 설정 전에 config.py에서 FITBIT_SCOPES를 수정할 수 있습니다.
구성
경로는 환경 변수를 통해 재정의할 수 있습니다:
변수 | 기본값 | 설명 |
|
| OAuth 자격 증명 디렉토리 |
|
| SQLite 데이터베이스 경로 |
속도 제한
Fitbit API는 시간당 150회의 요청을 허용합니다. 동기화 도구는 속도 제한을 자동으로 처리하지만 다음 사항에 유의하세요:
활동 동기화는 하루에 1번의 API 호출을 사용합니다 (날짜 범위 엔드포인트 없음).
30일 초기 동기화는 시간당 150회 할당량 중 약 30회를 사용합니다.
심박수, 수면, 체중, SpO2 및 HRV는 날짜 범위 엔드포인트를 사용하므로 훨씬 효율적입니다.
캐시에서 쿼리하고 API 호출을 완전히 피하려면 live=False (기본값)를 사용하세요.
데이터 안전
이 프로젝트에는 다음 파일들이 실수로 커밋되는 것을 방지하는 사전 커밋 훅(scripts/check-no-data.sh)이 포함되어 있습니다:
데이터베이스 파일 (
*.db,*.db-journal,*.db-wal)구성/자격 증명 (
config/*.json)대용량 파일 (>100KB)
복제 후 설치하세요:
cp scripts/check-no-data.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit기존 데이터 가져오기
JSON 파일 형태의 기존 Fitbit 데이터(예: 이전 내보내기 또는 스크립트 결과물)가 있는 경우 대량으로 가져올 수 있습니다:
fitbit-mcp import --data-dir /path/to/json/files/예상 파일 이름: heart_rate.json, activity.json, exercises.json, sleep.json, weight.json, spo2.json, hrv.json. 예상되는 JSON 형식은 src/fitbit_mcp/importer.py를 참조하세요.
기여
개발 설정, 테스트 워크플로우 및 사전 커밋 훅에 대한 내용은 CONTRIBUTING.md를 참조하세요. 변경 사항은 CHANGELOG.md에 기록됩니다.
라이선스
Available Tools
18 toolsfitbit_get_activityA
Get daily activity summaries (steps, calories, active minutes, distance).
Returns data from the local cache by default. Use live=True to fetch from Fitbit API. Run fitbit_sync first to populate the cache.
Note: live=True fetches one API call per day - avoid large ranges to stay within the 150 requests/hour rate limit.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per day with steps, calories, active minutes, distance. active_minutes = very_active + fairly_active (excludes lightly active).
Inputs: live, end_date, start_date. Returns: result
fitbit_get_azmA
Get daily Active Zone Minutes (AZM) - Fitbit's headline cardio metric.
AZM counts minutes spent in heart rate zones at or above Fat Burn intensity. Cardio and Peak zone minutes count double. Returns from local cache by default, auto-syncing if stale. Use live=True to bypass the cache.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per day with total_minutes plus per-zone breakdown (fat_burn_minutes, cardio_minutes, peak_minutes). Distinct from active_minutes in fitbit_get_activity, which counts wall-clock minutes regardless of intensity.
Inputs: live, end_date, start_date. Returns: result
fitbit_get_breathing_rateA
Get nightly breathing rate (avg breaths per minute during sleep).
Sourced during sleep tracking. Useful as an illness/recovery signal: sustained increases of 2-3 bpm above personal baseline can indicate incipient infection or strain. Returns from cache by default, auto-syncing if stale.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per night with breaths_per_min. Typical adult range: 12-20 bpm at rest.
Inputs: live, end_date, start_date. Returns: result
fitbit_get_cardio_fitnessA
Get Cardio Fitness Score (VO2 Max estimate).
Fitbit estimates VO2 Max from resting HR, HR during walks/runs, and demographics. Updates roughly weekly. Returns from cache by default, auto-syncing if stale.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns entries with vo2_max_low and vo2_max_high (mL/kg/min). Fitbit reports as a range (e.g. 39-43); when a single value is given, low and high are equal. Higher = better cardiorespiratory fitness.
Inputs: live, end_date, start_date. Returns: result
fitbit_get_core_temperatureA
Get manually-logged core (body) temperature readings (degrees Celsius).
These are absolute body temperatures the user enters by hand - e.g. a forehead/thermometer reading saved to Fitbit - and are the right source for fever / body-temperature questions. They are NOT the device-derived nightly skin-temperature variation from fitbit_get_skin_temperature. A single day can hold several readings (each timestamped), useful for tracking a fever over time.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per logged reading with datetime (YYYY-MM-DDThh:mm:ss) and temp_celsius.
Inputs: live, end_date, start_date. Returns: result
fitbit_get_devicesA
List paired Fitbit devices with battery level and last sync time.
Live-only (no caching) - reflects current device state. Useful for monitoring tracker health, knowing which device produced data, and spotting sync gaps.
Returns one entry per paired device with id, type, device_version, battery (e.g. "High"), battery_level (0-100), last_sync_time, mac, and features list.
Inputs: no named parameters. Returns: result
fitbit_get_exercisesA
Get exercise log entries (individual tracked activities).
Returns exercise sessions from the local cache by default. Use live=True to fetch from Fitbit API. Run fitbit_sync first to populate the cache.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. exercise_type: Filter by activity name (case-insensitive substring match), e.g. "cycling", "walk", "run". Default: all types. live: If true, fetch directly from Fitbit API instead of cache.
Returns exercise entries with name, duration, calories, avg heart rate, distance, and source (auto-detect vs manual). Note: HR data from cycling may be unreliable (optical sensor vs handlebar grip).
Inputs: live, end_date, start_date, exercise_type. Returns: result
fitbit_get_food_logA
Get daily food and water log summary.
Returns calories consumed and water intake (in mL) per day. Only populated if the user logs food/water in the Fitbit app. Returns from cache by default, auto-syncing if stale.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API. Uses one API call per day.
Returns one entry per day with calories_in and water_ml. Days with no logging are omitted.
Inputs: live, end_date, start_date. Returns: result
fitbit_get_goalsA
Get user-set activity goals for steps, distance, calories, etc.
Live-only (no caching). Use to compare actuals (from fitbit_get_activity) against the targets the user set in the Fitbit app.
Args: period: "daily" or "weekly". Default: "daily".
Returns goals dict with keys like steps, distance, calories_out, active_minutes, active_zone_minutes, floors. Weekly omits some fields.
Inputs: period. Returns: result
fitbit_get_heart_rateA
Get daily resting heart rate and heart rate zones.
Returns resting HR and zone breakdown (Out of Range, Fat Burn, Cardio, Peak) from the local cache by default, auto-syncing if stale. Use live=True to bypass the cache entirely.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per day with resting_hr and zones array. Zone data: name, minutes, caloriesOut, max/min HR for each zone.
Inputs: live, end_date, start_date. Returns: result
fitbit_get_hrvA
Get nightly HRV (heart rate variability) data.
Returns data from the local cache by default. Use live=True to fetch from Fitbit API. Run fitbit_sync first to populate the cache.
HRV data is sparse: only nights with on-wrist sleep tracking produce readings. Requires Fitbit Premium for access to this endpoint.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per night with daily_rmssd and deep_rmssd (ms). RMSSD = root mean square of successive RR interval differences. Higher values generally indicate better recovery and parasympathetic activity.
Inputs: live, end_date, start_date. Returns: result
fitbit_get_lifetime_statsA
Get all-time activity totals and personal best records.
Live-only (no caching). Returns lifetime totals (steps, distance, floors, calories, active score) and personal bests (best day for steps, distance, floors), each with the date the record was set.
Useful for long-term context that the daily activity table can't easily answer (e.g. "what's my best step day ever?").
Inputs: no named parameters. Returns: result
fitbit_get_skin_temperatureA
Get nightly skin temperature variation (degrees Celsius from personal baseline).
This is the device-derived RELATIVE deviation recorded during sleep, NOT an absolute body temperature - for fever / body-temperature readings use fitbit_get_core_temperature instead. Fitbit needs ~3 nights to establish a baseline before values appear. Useful as an illness/cycle/recovery signal.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per night with nightly_relative (degrees C, can be negative) and log_type (e.g. "dermal").
Inputs: live, end_date, start_date. Returns: result
fitbit_get_sleepA
Get nightly sleep data (duration, stages, efficiency).
Returns sleep data from the local cache by default. Use live=True to fetch from Fitbit API. Run fitbit_sync first to populate the cache.
Sleep data is sparse: only nights with watch-tracked sleep are present. Travel, off-wrist nights, or manual logs may be missing.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per night with total_minutes, efficiency, start/end times, and stage breakdown (deep, light, REM, wake minutes).
Inputs: live, end_date, start_date. Returns: result
fitbit_get_spo2A
Get nightly SpO2 (blood oxygen saturation) data.
Returns data from the local cache by default. Use live=True to fetch from Fitbit API. Run fitbit_sync first to populate the cache.
SpO2 data is sparse: only nights with on-wrist sleep tracking produce readings. Requires Fitbit Premium for access to this endpoint.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per night with avg, min, max SpO2 percentage. Normal range: 95-100%. Below 90% may indicate sleep apnea.
Inputs: live, end_date, start_date. Returns: result
fitbit_get_weightA
Get weight log entries (weight, BMI, body fat percentage).
Returns data from the local cache by default. Use live=True to fetch from Fitbit API. Run fitbit_sync first to populate the cache.
Weight data is sparse: only days with weigh-in entries are present.
Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: last 30 days. end_date: End date as "YYYY-MM-DD". Default: today. live: If true, fetch directly from Fitbit API instead of cache.
Returns one entry per weigh-in with weight_kg, bmi, fat_pct.
Inputs: live, end_date, start_date. Returns: result
fitbit_syncA
Sync Fitbit health data to the local cache.
Fetches data from the Fitbit API and stores it in SQLite for fast offline queries. Run this before using other fitbit_get_* tools.
Syncs incrementally: only fetches data newer than the most recent entry in each table. First sync fetches the specified number of days.
Args: data_types: What to sync. Options: "all", "heart_rate", "activity", "exercises", "sleep", "weight", "spo2", "hrv", "azm", "breathing_rate", "skin_temperature", "core_temperature", "cardio_fitness", "food_log". Comma-separated for multiple, e.g. "sleep,hrv". Default: "all". days: Days of history for first sync (default: 30). Ignored on subsequent syncs (uses last synced date). since: Optional "YYYY-MM-DD" backfill date. When set, fetches from this date regardless of what is already cached - use to pull history older than the current cache. Overrides incremental resume and days. until: Optional "YYYY-MM-DD" inclusive end date; requires since. Together they re-fetch and upsert exactly the since..until window - use to repair a gap in the middle of the cache without re-pulling everything from the gap to today.
Returns summary of records synced per data type. Not for querying data - use fitbit_get_heart_rate, fitbit_get_activity, fitbit_get_sleep, etc. instead.
Inputs: days, since, until, data_types. Returns: result
fitbit_trendsA
Analyse trends in cached Fitbit data.
Computes averages and totals over time from the local cache, auto-syncing if stale.
Args: data_type: What to analyse. Options: "heart_rate", "activity", "exercises", "sleep", "weight", "spo2", "hrv", "azm", "breathing_rate", "skin_temperature", "core_temperature", "cardio_fitness", "food_log". Default: "activity". period: Aggregation period. Options: "weekly", "monthly", "quarterly". Default: "monthly". start_date: Start date as "YYYY-MM-DD" or "365d". Default: last 12 months. end_date: End date as "YYYY-MM-DD". Default: today. compare: Compare two periods. Format: "last_30d vs previous_30d", "2026-03 vs 2026-02", "2026-Q1 vs 2025-Q4". When set, period/start_date/end_date are ignored.
Returns aggregated averages per period. For activity: steps, distance, active minutes. For exercises: sessions, duration, calories. For sleep: duration, efficiency, stage breakdown. For heart_rate: resting HR min/avg/max. For weight: weight, fat%, BMI. For spo2: avg/min/max oxygen saturation. For hrv: daily and deep RMSSD. Not for raw data - use fitbit_get_* tools instead.
Inputs: period, compare, end_date, data_type, +1 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Each tool clearly targets a distinct Fitbit data type (activity, sleep, heart rate, etc.). The only potential confusion between skin and core temperature is explicitly disambiguated in the descriptions, and other similar metrics (e.g., activity vs. AZM vs. exercises) are clearly differentiated.
All tools follow a consistent `fitbit_<verb>_<noun>` pattern with snake_case throughout. Retrieval tools uniformly use `fitbit_get_*`, and the two non-retrieval tools (`fitbit_sync`, `fitbit_trends`) are named with distinct, appropriate actions that do not break the overall pattern.
With 18 tools, the server is slightly above the typical 3-15 tool range, but the count is justified by the breadth of Fitbit's health data metrics. Each tool serves a unique, non-redundant purpose, so the set feels comprehensive rather than bloated.
The tool set provides broad coverage of Fitbit's data ecosystem, including activity, sleep, heart rate, HRV, SpO2, breathing, temperature, weight, food, exercise, plus device info and goals. No obvious missing operations for a read-only health data retrieval server; the sync tool ensures offline caching is fully supported.
Maintenance
Related MCP Connectors
MCP server for Withings health data — sleep, activity, heart, and body metrics.
Remote MCP server for training, nutrition, wellness, and performance data with OAuth 2.0.
Hosted MCP server with managed OAuth for 15+ toolkits: Google Workspace, Fitbit, Oura, Kalshi, etc.
Multi-tenant hosted MCP server for Oura Ring — 21 read-only tools, OAuth per user.
Related MCP Servers
- AlicenseAqualityDmaintenanceA Model Context Protocol server that bridges LLMs (like Claude) with the Fitbit API, allowing the LLM to request and retrieve user health and fitness data through defined tools.138 npm34MIT
- AlicenseBqualityBmaintenanceLocal-first MCP server that connects AI agents to your Fitbit activity, sleep, heart-rate, HRV, SpO2 and weight data.33190 npm5MIT
- AlicenseAqualityDmaintenanceMCP server for the Oura Ring API v2, providing access to sleep, activity, readiness, heart rate, and workout data via OAuth.5152 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA local MCP server providing read-only access to WHOOP fitness data via direct OAuth, with a local SQLite cache for offline queries.99 PyPIMIT