Skip to main content
Glama
README.md
# garmin-mcp

**English** | [Tiếng Việt](./README.vi.md) | [简体中文](./README.zh-CN.md)

[![npm version](https://img.shields.io/npm/v/@duongtungls/garmin-mcp.svg)](https://www.npmjs.com/package/@duongtungls/garmin-mcp)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
[![Node.js >= 20](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen.svg)](https://nodejs.org/)
[![MCP](https://img.shields.io/badge/MCP-Model%20Context%20Protocol-purple.svg)](https://modelcontextprotocol.io/)
[![Docs](https://img.shields.io/badge/docs-GitHub%20Pages-0ea5e9.svg)](https://duongtungls.github.io/garmin-mcp/)

Open-source **Node.js / TypeScript CLI & library** implementing a **Model Context Protocol (MCP)** server for **Garmin Connect**.

📖 **Documentation:** https://duongtungls.github.io/garmin-mcp/

Connect AI assistants (Claude Desktop, Cursor, Windsurf, Antigravity, and any MCP-compatible client) directly to your Garmin Connect data — **activities, health & wellness, sleep, weight, calendar, workouts, training metrics, courses, challenges, nutrition, women's health, devices, and gear** — via standard `stdio` transport.

---

## Features

- **103 MCP Tools across 11 domains** — full coverage of Garmin Connect read & management endpoints.
- **Read-only safety mode** — pass `--read-only` or set `GARMIN_READ_ONLY=true` to expose only **81 read-only tools** (disables all write/delete operations).
- **Interactive CLI login with 2FA / MFA support** — sign in once via `garmin-mcp login` and cache OAuth1/OAuth2 tokens locally at `~/.garmin-mcp/tokens`.
- **Automatic session refresh & re-authentication** — persists refreshed tokens and automatically re-authenticates on `401/403` when credentials are provided.
- **Dual-purpose package** — run directly as a CLI MCP server (`garmin-mcp`) or import programmatically in your own Node.js / TypeScript project.
- **Global & China domains** — supports both `garmin.com` (default) and `garmin.cn`.

---

## Requirements

- **Node.js >= 20.0.0**
- A Garmin Connect account

---

## Installation

### From source

```bash
git clone https://github.com/duongtungls/garmin-mcp.git
cd garmin-mcp
npm install
npm run build
```

Optional global CLI link:

```bash
npm link
```

### As a dependency or via `npx` (Recommended)

```bash
# Run directly without cloning:
npx -y @duongtungls/garmin-mcp --help
npx -y @duongtungls/garmin-mcp login

# Or install globally / as a library:
npm install -g @duongtungls/garmin-mcp
npm install @duongtungls/garmin-mcp
```

---

## Authentication

### Option 1: Interactive CLI Login (Recommended — supports 2FA / MFA)

```bash
garmin-mcp login
# or from source:
npm run login
```

Enter your Garmin email, password, and MFA code (if enabled). OAuth1 & OAuth2 tokens are cached in `~/.garmin-mcp/tokens` (mode `0700`).

Manage your session anytime:

```bash
garmin-mcp status   # Verify cached session
garmin-mcp logout   # Remove cached OAuth tokens
```

### Option 2: Environment Variables (for non-2FA accounts)

Copy `.env.example` to `.env` or set env vars in your MCP client config:

```env
GARMIN_EMAIL=your-email@example.com
GARMIN_PASSWORD=your-password
GARMIN_DOMAIN=garmin.com
# GARMIN_TOKEN_DIR=/custom/path/to/tokens
# GARMIN_READ_ONLY=false
```

---

## MCP Client Configuration

Add the following to your MCP client configuration (Claude Desktop, Cursor, Antigravity, etc.):

```json
{
  "mcpServers": {
    "garmin": {
      "command": "npx",
      "args": ["-y", "@duongtungls/garmin-mcp"],
      "env": {
        "GARMIN_DOMAIN": "garmin.com"
      }
    }
  }
}
```

### Read-Only Mode

To prevent any write or delete operations (exposes 81 read-only tools):

```json
{
  "mcpServers": {
    "garmin": {
      "command": "npx",
      "args": ["-y", "@duongtungls/garmin-mcp", "--read-only"],
      "env": {
        "GARMIN_DOMAIN": "garmin.com"
      }
    }
  }
}
```

---

## Agent Use Cases & Example Prompts

Once connected to Claude Desktop, Cursor, Windsurf, or Antigravity, you can use natural language to turn your AI assistant into a personal Garmin data analyst and training assistant:

### 1. Morning Health & Readiness Briefing
- **Prompt:** *"Give me a morning readiness check: summarize last night's sleep score, HRV, Body Battery, resting HR, and Training Readiness. Should I push hard today or do an easy recovery session?"*
- **Tools used:** `get_sleep_data`, `get_hrv`, `get_body_battery`, `get_heart_rate`, `get_training_readiness`

### 2. Running / Cycling Training & Race Prep Coach
- **Prompt:** *"Analyze my last 10 runs, my VO2 max trend over the past 30 days, and my current race predictions. How is my aerobic base progressing and what pace should I target for my next 10K?"*
- **Tools used:** `get_activities`, `get_activity_splits`, `get_activity_hr_in_timezones`, `get_vo2_max`, `get_training_status`, `get_race_predictions`

### 3. Sleep & Recovery Deep Dive
- **Prompt:** *"Compare my sleep duration, sleep stages, and stress levels over the past 14 days. Which days had the worst recovery and did they follow high-intensity workouts?"*
- **Tools used:** `get_sleep_range`, `get_stress`, `get_activities_by_date`

### 4. Workout & Calendar Planning
- **Prompt:** *"Check my Garmin calendar for this week and upcoming races. Reschedule Thursday's interval workout to Friday and add a calendar note for Sunday's long run."*
- **Tools used:** `get_calendar_week`, `get_scheduled_workouts`, `get_upcoming_events`, `reschedule_workout`, `create_calendar_note`

### 5. Weight, Hydration & Nutrition Tracking
- **Prompt:** *"Show my weight trend over the last 30 days against my weight goal, check today's calories and hydration, and log 500 ml of water."*
- **Tools used:** `get_weight_range`, `get_weight_goals`, `get_daily_summary`, `get_nutrition_daily_food_log`, `add_hydration_data`

### 6. Gear & Equipment Mileage Check
- **Prompt:** *"List all my running shoes with their total mileage and tell me which pair is close to 600 km and needs replacing."*
- **Tools used:** `get_gear`, `get_activity_gear`

---

## Programmatic Library Usage

You can embed the MCP server or reuse `GarminClientManager` in your own Node.js / TypeScript application:

```ts
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { createGarminMcpServer, GarminClientManager } from '@duongtungls/garmin-mcp';

const garminManager = new GarminClientManager({
  domain: 'garmin.com',
  tokenDir: '~/.garmin-mcp/tokens',
});

const server = createGarminMcpServer({
  garminManager,
  readOnly: true, // optional
});

const transport = new StdioServerTransport();
await server.connect(transport);
```

You can also register individual tool groups (`registerActivityTools`, `registerHealthTools`, `registerSleepTools`, `registerWeightTools`, `registerCalendarTools`, `registerMetricsTools`, `registerCourseTools`, `registerChallengeTools`, `registerNutritionTools`, `registerWomensHealthTools`, `registerProfileTools`) onto an existing `McpServer`.

---

## Available MCP Tools (103 Tools)

### 1. Activities (20)
- **Read:** `get_activities`, `get_activities_by_date`, `get_activity`, `get_activity_details`, `get_activity_splits`, `get_activity_typed_splits`, `get_activity_split_summaries`, `get_activity_hr_in_timezones`, `get_activity_power_in_timezones`, `get_activity_exercise_sets`, `get_activity_weather`, `get_activity_types`, `get_power_duration_curve`, `get_progress_summary_between_dates`, `count_activities`
- **Write / Download:** `download_activity_file`, `create_manual_activity`, `set_activity_name`, `update_activity`, `delete_activity`

### 2. Health & Wellness (17)
- **Read:** `get_daily_summary`, `get_heart_rate`, `get_steps`, `get_stress`, `get_body_battery`, `get_hrv`, `get_spo2`, `get_respiration`, `get_hydration`, `get_intensity_minutes`, `get_floors`, `get_all_day_events`, `get_lifestyle_logging_data`, `get_blood_pressure`, `get_glucose`
- **Write:** `add_hydration_data`, `set_blood_pressure`

### 3. Sleep (3)
- `get_sleep_data`, `get_sleep_range`, `get_naps`

### 4. Weight & Body Composition (6)
- **Read:** `get_daily_weight`, `get_weight_range`, `get_latest_weight`, `get_weight_goals`
- **Write:** `add_weigh_in`, `delete_weigh_in`

### 5. Calendar & Workouts (15)
- **Read:** `get_calendar_month`, `get_calendar_year`, `get_calendar_week`, `get_scheduled_workouts`, `get_upcoming_events`, `get_workouts`, `get_workout_by_id`
- **Write / Download:** `schedule_workout`, `reschedule_workout`, `unschedule_workout`, `delete_workout`, `push_workout_to_device`, `download_workout`, `create_calendar_note`, `delete_calendar_note`

### 6. Training Metrics & Performance (15)
- `get_training_readiness`, `get_training_status`, `get_vo2_max`, `get_race_predictions`, `get_fitness_age`, `get_endurance_score`, `get_hill_score`, `get_acclimation`, `get_running_tolerance`, `get_lactate_threshold`, `get_cycling_ftp`, `get_heart_rate_zones`, `get_power_zones`, `get_critical_swim_speed`, `get_personal_records`

### 7. Courses (4)
- **Read:** `get_courses`, `get_course_details`, `download_course_gpx`
- **Write:** `delete_course`

### 8. Challenges, Goals & Badges (5)
- `get_goals`, `get_earned_badges`, `get_badge_challenges`, `get_virtual_challenges`, `get_adhoc_challenges`

### 9. Nutrition (7)
- **Read:** `get_nutrition_daily_food_log`, `get_nutrition_daily_meals`, `get_nutrition_daily_settings`, `search_foods`, `get_custom_foods`
- **Write:** `quick_add_foods`, `delete_food_logs`

### 10. Women's Health (2)
- `get_menstrual_data_for_date`, `get_menstrual_calendar_data`

### 11. Profile, Devices & Gear (9)
- **Read:** `get_user_profile`, `get_user_statistics`, `get_devices`, `get_device_settings`, `get_device_solar_data`, `get_gear`, `get_activity_gear`
- **Write:** `add_gear_to_activity`, `remove_gear_from_activity`

---

## Acknowledgments & Inspiration

- Tool design and domain coverage were inspired by and referenced from [Taxuspt/garmin_mcp](https://github.com/Taxuspt/garmin_mcp) (Python Garmin Connect MCP server).
- Garmin Connect SSO / OAuth1 / OAuth2 client powered by [@flow-js/garmin-connect](https://github.com/florianpasteur/garmin-connect).
- Built with the official [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk).

---

## Disclaimer

This is an **unofficial**, community-built open-source project and is not affiliated with, endorsed by, or supported by Garmin Ltd. It interacts with private Garmin Connect endpoints via `@flow-js/garmin-connect`. Use responsibly with your own account.

---

## Contributing

Contributions are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) before submitting a Pull Request.

---

## License

Licensed under the [MIT License](./LICENSE).

TDQS

B3/5.0

Scored across 103 tools

Disambiguation3/5

The set covers many clearly distinct Garmin domains, but several clusters overlap: get_activity_splits/get_activity_typed_splits/get_activity_split_summaries, nutrition food-log vs meal-summary tools, and calendar-week/month/year vs scheduled-workout tools. Descriptions help, but these clusters still create meaningful misselection risk.

Naming Consistency4/5

Nearly all tools use a predictable snake_case verb_noun pattern such as get_, add_, delete_, set_, schedule_, and download_. A few outliers like quick_add_foods and count_activities are minor deviations, but the overall convention is clear and readable.

Tool Count2/5

103 tools is far beyond a practical MCP tool surface and will make discovery and selection difficult for an agent. The broad Garmin domain explains many operations, but this set would benefit heavily from consolidation into grouped endpoints.

Completeness3/5

Read coverage is extensive across activities, health metrics, workouts, nutrition, devices, calendar, and gear. However, write/lifecycle coverage is uneven: there is no create/update workout, no create/update course, no create/update/delete goal, and only limited calendar-event creation beyond notes.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues