mcp-fitbit
CLAUDE.md34 starsChanged 18 months agoMITView on GitHub
Design Philosophy: This MCP server acts as a 1:1 JSON proxy to the Fitbit API. Tools should match the underlying API parameters and limitations exactly, without adding abstraction layers or client-side data manipulation. Return raw JSON responses from Fitbit API calls. Production mode: 1. npm run build - Compile TypeScript 2. npm run start - Run server directly 3. Tools available after auth: get_weight, get_sleep_by_date_range, get_exercises, get_daily_activity_summary, get_activity_goals, get_activity_timeseries, get_azm_timeseries, get_profile, get_heart_rate, get_heart_rate_by_date_range, get_food_log, get_nutrition, get_nutrition_by_date_range
- Reads credentials
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
The file
We split this CLAUDE.md into the rules it gives an agent
12 rules. About 0 are common, 10 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 41
All tools return raw JSON from Fitbit API
- Distinctive: line 43
Use makeFitbitRequest utility for API calls
- Very specific: line 45
No Abstraction: If Fitbit API only supports afterDate, the tool should only accept afterDate (not startDate/endDate)
- Distinctive: line 46
Documentation First: Always check the official Fitbit API documentation at https://dev.fitbit.com/build/reference/ when adding new …
- Distinctive: line 52
Test tools interactively at http://localhost:5173
- Distinctive: line 70
All dates in YYYY-MM-DD format
- Distinctive: line 76
When working on this codebase:
- Distinctive: line 77
Follow the existing code style and patterns
- Distinctive: line 79
Test changes thoroughly with the MCP inspector
- Distinctive: line 80
Ensure backward compatibility with existing tools
- Very specific: line 81
VERY IMPORTANT: When you have completed a task, you MUST run both build, test, and lint commands (npm run build then npm run test:coverage …
- Distinctive: line 82
Update documentation when making changes
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Claude Development Guide
Project Overview
MCP server for Fitbit API integration providing health data access (weight, sleep, activities, profile).
Design Philosophy: This MCP server acts as a 1:1 JSON proxy to the Fitbit API. Tools should match the underlying API parameters and limitations exactly, without adding abstraction layers or client-side data manipulation. Return raw JSON responses from Fitbit API calls.
Development Commands
npm run build- Compile TypeScript to build/ directorynpm run start- Run the built MCP servernpm run dev- Build and run with MCP inspector for testing/debuggingnpm run lint- Check code quality and style issuesnpm run format- Auto-fix code formattingnpm test- Run tests with Vitestnpm run test:coverage- Run tests with coverage report
CI/CD
- GitHub Actions workflow runs tests, lint checks, and build on push/PR to main branch
- Located at
.github/workflows/ci.yml
Project Structure
src/index.ts- Main MCP server entry point, registers all toolssrc/auth.ts- OAuth2 flow with token persistencesrc/utils.ts- Shared Fitbit API request utilitiessrc/weight.ts- Weight data tool (time series)src/sleep.ts- Sleep data tool (date range)src/activities.ts- Exercise/activity data tool (date range)src/profile.ts- User profile toolsrc/heart-rate.ts- Heart rate data tools (time series and date range)src/nutrition.ts- Nutrition data tools (comprehensive food log with macros, plus time series for individual nutrients)src/daily-activity.ts- Daily activity summary tool (steps, calories, goals, heart rate zones)src/activity-goals.ts- Activity goals tool (daily/weekly goals)src/activity-timeseries.ts- Activity time series tool (steps, distance, calories over time)src/azm-timeseries.ts- Active Zone Minutes time series toolbuild/- Compiled JavaScript output.env- Environment variables (FITBIT_CLIENT_ID, FITBIT_CLIENT_SECRET)
Code Conventions
- TypeScript with ES modules
- Zod for parameter validation
- All tools return raw JSON from Fitbit API
- Error handling with console.error for debugging
- Use makeFitbitRequest utility for API calls
- API Fidelity: Tool parameters must exactly match Fitbit API requirements - no client-side workarounds or data filtering
- No Abstraction: If Fitbit API only supports
afterDate, the tool should only acceptafterDate(notstartDate/endDate) - Documentation First: Always check the official Fitbit API documentation at https://dev.fitbit.com/build/reference/ when adding new endpoints to ensure proper parameters, authentication scopes, and response formats
- CRITICAL: Endpoint URL Construction: The
makeFitbitRequestutility automatically adds/user/-/to all endpoint paths. When constructing endpoints, DO NOT includeuser/-/in the path - start directly with the resource path (e.g.,foods/log/caloriesIn/date/today/1d.jsonNOTuser/-/foods/log/caloriesIn/date/today/1d.json)
Testing the Server
Development mode (with inspector):
npm run dev- Builds and opens MCP inspector web UI- Test tools interactively at http://localhost:5173
- OAuth flow - server opens browser for authorization
Production mode:
npm run build- Compile TypeScriptnpm run start- Run server directly- Tools available after auth: get_weight, get_sleep_by_date_range, get_exercises, get_daily_activity_summary, get_activity_goals, get_activity_timeseries, get_azm_timeseries, get_profile, get_heart_rate, get_heart_rate_by_date_range, get_food_log, get_nutrition, get_nutrition_by_date_range
Environment Setup
Requires .env file with:
FITBIT_CLIENT_ID=your_client_id
FITBIT_CLIENT_SECRET=your_client_secretAPI Notes
- Fitbit API uses different base URLs per endpoint (v1, v1.2)
- Activities tool has custom request handler due to different URL structure
- All dates in YYYY-MM-DD format
- Token persisted to
.fitbit-token.json - OAuth scopes: weight, sleep, profile, activity, heartrate, nutrition
Contributing & Improvements
When working on this codebase:
- Follow the existing code style and patterns
- Update relevant documentation
- Test changes thoroughly with the MCP inspector
- Ensure backward compatibility with existing tools
- VERY IMPORTANT: When you have completed a task, you MUST run both build, test, and lint commands (
npm run buildthennpm run test:coveragethennpm run lint) to ensure your code is correct - Update documentation when making changes
For identified improvement opportunities, see TASKS.md - this file contains a comprehensive analysis of refactoring opportunities, code quality improvements, and architectural enhancements prioritized by impact and effort.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

