agentleFS
TheDigitalNinjaTheDigitalNinja/mcp-fitbit/.github/copilot-instructions.md

mcp-fitbit

Copilot instructions34 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_profile, get_heart_rate, get_heart_rate_by_date_range, get_food_log, get_nutrition, get_nutrition_by_date_range When working on this codebase: 1. Follow the…

  • Reads credentials
  • In this repositoryOne other file it gives its agents.

The file

We split this copilot-instructions.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
  1. Distinctive:

    All tools return raw JSON from Fitbit API

    line 32
  2. Distinctive:

    Use makeFitbitRequest utility for API calls

    line 34
  3. Very specific:

    No Abstraction: If Fitbit API only supports afterDate, the tool should only accept afterDate (not startDate/endDate)

    line 36
  4. Distinctive:

    Documentation First: Always check the official Fitbit API documentation at https://dev.fitbit.com/build/reference/ when adding new …

    line 37
  5. Distinctive:

    Test tools interactively at http://localhost:5173

    line 43
  6. Distinctive:

    All dates in YYYY-MM-DD format

    line 61
  7. Distinctive:

    When working on this codebase:

    line 67
  8. Distinctive:

    Follow the existing code style and patterns

    line 68
  9. Distinctive:

    Test changes thoroughly with the MCP inspector

    line 70
  10. Distinctive:

    Ensure backward compatibility with existing tools

    line 71
  11. Very specific:

    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 …

    line 72
  12. Distinctive:

    Update documentation when making changes

    line 73

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

GitHub Copilot Instructions

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/ directory
  • npm run start - Run the built MCP server
  • npm run dev - Build and run with MCP inspector for testing/debugging
  • npm run lint - Check code quality and style issues
  • npm run format - Auto-fix code formatting
  • npm test - No tests configured yet

Project Structure

  • src/index.ts - Main MCP server entry point, registers all tools
  • src/auth.ts - OAuth2 flow with token persistence
  • src/utils.ts - Shared Fitbit API request utilities
  • src/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 tool
  • src/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)
  • build/ - 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 accept afterDate (not startDate/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 makeFitbitRequest utility automatically adds /user/-/ to all endpoint paths. When constructing endpoints, DO NOT include user/-/ in the path - start directly with the resource path (e.g., foods/log/caloriesIn/date/today/1d.json NOT user/-/foods/log/caloriesIn/date/today/1d.json)

Testing the Server

Development mode (with inspector):

  1. npm run dev - Builds and opens MCP inspector web UI
  2. Test tools interactively at http://localhost:5173
  3. OAuth flow - server opens browser for authorization

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_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_secret

API 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:

  1. Follow the existing code style and patterns
  2. Update relevant documentation
  3. Test changes thoroughly with the MCP inspector
  4. Ensure backward compatibility with existing tools
  5. 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 then npm run lint) to ensure your code is correct
  6. 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.