fitbit-mcp
The fitbit-mcp server provides an MCP-compliant interface to the Fitbit Web API, enabling local caching, querying, and trend analysis of health and activity data via a local SQLite database.
Core Tools:
fitbit_sync– Sync Fitbit data to a local SQLite cache (initial or incremental). Supports specifying data types and days of history.fitbit_get_heart_rate– Daily resting HR and HR zone breakdowns.fitbit_get_activity– Steps, calories, active minutes, distance.fitbit_get_exercises– Individual workout sessions with duration, calories, HR, and distance. Supports filtering by type.fitbit_get_sleep– Sleep duration, efficiency, start/end times, and stage breakdown (deep, light, REM, wake).fitbit_get_weight– Weight (kg), BMI, and body fat percentage.fitbit_get_spo2– Nightly blood oxygen saturation (avg/min/max). Requires Fitbit Premium.fitbit_get_hrv– Nightly HRV (RMSSD) for overall and deep sleep. Requires Fitbit Premium.fitbit_trends– Aggregated trend analysis (weekly, monthly, quarterly) with optional period comparison.
Additional data available includes Active Zone Minutes, Breathing Rate, Skin Temperature, Cardio Fitness (VO2 Max), Food Log, Paired Devices, Lifetime Stats, and Goals (some live-only).
Key Features:
All query tools support date range filtering and relative dates (e.g.,
30d).Live mode (
live=True) bypasses the cache to fetch directly from the Fitbit API.Tools auto-sync on first use each day.
OAuth 2.0 PKCE authentication with automatic token refresh and rate limit handling.
CLI for OAuth setup, manual sync, and bulk import of existing JSON data.
Configurable paths for credentials and database via environment variables.
Provides tools to sync, query, and analyze Fitbit data including heart rate, activity, sleep, weight, SpO2, and HRV, with local caching for offline access and trend analysis.
fitbit-mcp
MCP server for the Fitbit Web API with OAuth PKCE, local SQLite cache, and trend analysis.
Designed for Claude Code and other MCP clients. Syncs your Fitbit data to a local database for fast, offline queries - no API calls needed after the initial sync.
Features
OAuth 2.0 PKCE - Secure auth flow, no client secret needed
Local SQLite cache - Sync once, query instantly
Incremental sync - Only fetches new data since last sync
17 MCP tools - Sync, query (12 cached data types + devices/lifetime/goals), and trend analysis
Live mode - Bypass cache and query the API directly
CLI - Auth setup, sync, and JSON import from the command line
Rate limit handling - Automatic retry on 429 responses
Data types
Tool | Data |
| Resting HR, HR zones |
| Steps, calories, active minutes, distance |
| Exercise sessions (name, duration, HR, calories) |
| Duration, efficiency, sleep stages |
| Weight, BMI, body fat % |
| Blood oxygen saturation (avg/min/max) |
| Heart rate variability (RMSSD) |
| Active Zone Minutes with per-zone breakdown |
| Nightly breaths per minute |
| Nightly skin temperature variation (degrees C from baseline) |
| VO2 Max / Cardio Fitness Score |
| Daily food calories + water intake |
| Paired devices, battery level, last sync (live) |
| All-time totals and personal best records (live) |
| User-set daily/weekly activity goals (live) |
| Aggregated averages (weekly/monthly/quarterly) |
Requirements
Python 3.13+
A Fitbit developer account with a registered personal app
Setup
1. Install
pip install .Or for development:
pip install -e ".[dev]"2. Register a Fitbit app
Go to dev.fitbit.com/apps and create a new app
Set OAuth 2.0 Application Type to Personal
Set Redirect URL to
http://localhost:8080Note your Client ID (you won't need the client secret - PKCE doesn't use one)
3. Authenticate
fitbit-mcp authThis opens your browser for Fitbit login, exchanges the auth code via PKCE, and saves tokens locally.
Tokens are stored in ~/.config/fitbit-mcp/fitbit_tokens.json with 0600 permissions. Access tokens expire in 8 hours and are refreshed automatically. Refresh tokens expire after 90 days of inactivity.
4. Register with Claude Code
claude mcp add -s user fitbit -- fitbit-mcp5. First sync (optional)
Query tools auto-sync on first use, so you can skip this step. To pre-populate the cache or sync a longer history, run:
fitbit-mcp sync --days 30CLI usage
fitbit-mcp Start the MCP server (stdio transport)
fitbit-mcp --version Print the installed package version
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 tool reference
Query tools auto-sync on the first query of each day per data type. Use live=True
to bypass the cache entirely and fetch directly from the API.
All query tools accept these common parameters:
start_date- Start date asYYYY-MM-DD,YYYY-MM, or30d(relative). Default: last 30 days.end_date- End date asYYYY-MM-DD. Default: today.live- If true, fetch from Fitbit API instead of cache (bypasses auto-sync).
fitbit_get_exercises also accepts:
exercise_type- Filter by activity name (case-insensitive substring match), e.g."cycling","walk","run". Default: all types.
fitbit_sync
Syncs data from the Fitbit API to the local SQLite cache. Query tools call this automatically on first use of the day, so explicit calls are only needed for longer history or forced refresh.
data_types- What to sync:all,heart_rate,activity,exercises,sleep,weight,spo2,hrv,azm,breathing_rate,skin_temperature,cardio_fitness,food_log. Comma-separated. Default:all.days- Days of history for first sync (default: 30). Subsequent syncs are incremental.
fitbit_trends
Aggregated trend analysis from cached data.
data_type- What to analyse:heart_rate,activity,exercises,sleep,weight,spo2,hrv,azm,breathing_rate,skin_temperature,cardio_fitness,food_log. Default:activity.period- Aggregation:weekly,monthly,quarterly. Default:monthly.start_date- Start date. Default: last 12 months (365 days).end_date- End date. Default: today.compare- Compare two periods:last_30d vs previous_30d,2026-03 vs 2026-02,2026-Q1 vs 2025-Q4. When set,period/start_date/end_dateare ignored.
OAuth scopes
The following Fitbit API scopes are requested during setup:
Scope | Data accessed |
| Steps, calories, active minutes, distance, AZM, lifetime stats, goals |
| Resting HR, HR zones, HRV |
| Sleep duration and stages |
| Weight, BMI, body fat % |
| SpO2 (blood oxygen) |
| User profile (user ID, display name) |
| Nightly breathing rate |
| Skin temperature variation |
| VO2 Max / Cardio Fitness Score |
| Daily food calorie and water log |
| GPS data on logged exercises |
| Paired devices (battery, last sync) |
These are the scopes needed for all tools. If you only need a subset, edit FITBIT_SCOPES in config.py before setup. After upgrading from a smaller scope set, re-run fitbit-mcp auth to re-authorise.
Configuration
Paths are overridable via environment variables:
Variable | Default | Description |
|
| Directory for OAuth credentials |
|
| SQLite database path |
Rate limits
The Fitbit API allows 150 requests per hour. The sync tool handles rate limits automatically, but be aware:
Activity and food log syncs use 1 API call per day (no date-range endpoint available)
A 30-day initial sync of either uses ~30 of your 150/hour quota
Heart rate, sleep, weight, SpO2, HRV, AZM, breathing rate, skin temperature, and cardio fitness use date-range endpoints and are much more efficient
Use live=False (the default) to query from cache and avoid API calls entirely.
Data safety
This project includes a pre-commit hook (scripts/check-no-data.sh) that prevents accidentally committing:
Database files (
*.db,*.db-journal,*.db-wal)Config/credentials (
config/*.json)Large files (>100KB)
Install it after cloning:
cp scripts/check-no-data.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commitImporting existing data
If you have existing Fitbit data as JSON files (e.g. from a previous export or script), you can bulk-import them:
fitbit-mcp import --data-dir /path/to/json/files/Expected file names: heart_rate.json, activity.json, exercises.json, sleep.json, weight.json, spo2.json, hrv.json. See src/fitbit_mcp/importer.py for the expected JSON format.
Contributing
See CONTRIBUTING.md for development setup, the test workflow, and the pre-commit hook. Changes are tracked in CHANGELOG.md.
License
Maintenance
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/partymola/fitbit-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server