jlwainwright/garmin-connect-mcp-server
If you are the rightful owner of garmin-connect-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Garmin Connect MCP Server is a comprehensive Model Context Protocol server that connects to Garmin Connect, providing access to fitness and health data for MCP-compatible clients.
Garmin Connect MCP Server
A comprehensive Model Context Protocol (MCP) server that connects to Garmin Connect and exposes your fitness and health data to Claude and other MCP-compatible clients. This server provides access to activities, health metrics, devices, training data, and much more.
🚀 Features
Core Data Access
- Activities: List recent activities, get detailed activity information, export data
- Health Metrics: Steps, heart rate, sleep data, stress levels, body battery
- Body Composition: Weight, BMI, body fat percentage, muscle mass
- User Profile: Personal information, preferences, device settings
Advanced Features
- Device Management: List connected devices, sync status, device details
- Training Data: Training plans, workouts, performance metrics
- Gear Management: Track equipment usage and maintenance
- Challenges: View active challenges and achievements
- Women's Health: Menstrual cycle tracking and health insights
Authentication & Security
- Headless 2FA Support: Multiple authentication strategies for automated deployments
- Token Management: Automatic token refresh and validation
- Notification System: Real-time alerts via ntfy for authentication events
- Rate Limiting: Built-in protection against API rate limits
- Security Logging: Comprehensive authentication attempt logging
📋 Requirements
- Python 3.7+
- Garmin Connect account
- Valid email/phone for 2FA verification
🛠️ Installation
- Clone and setup virtual environment:
git clone <repository-url>
cd garmin_mcp
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
- Configure environment variables:
Create a .env
file in the project root:
# Garmin Connect Credentials (Required)
GARMIN_EMAIL=your.email@example.com
GARMIN_PASSWORD=your-password
# 2FA Authentication (Choose one method)
GARMIN_MFA_CODE=123456 # Manual MFA code entry
# GARMIN_MFA_WEBHOOK=https://api.com/mfa # Webhook for automated MFA
# Or use temporary file: echo "123456" > /tmp/garmin_mfa.txt
# Notification Settings (Optional)
NTFY_SERVER=https://ntfy.sh
NTFY_TOPIC=garmin-notifications
NTFY_TOKEN=your-ntfy-token
# Token Storage (Optional)
GARMINTOKENS=~/.garminconnect
GARMINTOKENS_BASE64=~/.garminconnect_base64
🔐 Authentication Setup
The server supports multiple authentication strategies for different deployment scenarios:
Method 1: Interactive Authentication (Recommended for first-time setup)
# Activate virtual environment
source venv/bin/activate
# Run interactive authentication
python authenticate.py
This will:
- Prompt for 2FA code when needed
- Save tokens for future headless operation
- Verify authentication works properly
Method 2: Headless Authentication
For automated deployments, use one of these methods:
Environment Variable:
export GARMIN_MFA_CODE="123456"
Temporary File:
echo "123456" > /tmp/garmin_mfa.txt
Webhook API:
export GARMIN_MFA_WEBHOOK="https://your-api.com/mfa"
🖥️ Running the Server
With Claude Desktop (Recommended)
- Configure Claude Desktop:
Edit your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add this server configuration:
{
"mcpServers": {
"garmin-connect": {
"command": "/full/path/to/garmin_mcp/venv/bin/python",
"args": [
"/full/path/to/garmin_mcp/garmin_mcp_server_fixed.py"
],
"env": {
"GARMIN_EMAIL": "your.email@example.com",
"GARMIN_PASSWORD": "your-password",
"GARMIN_MFA_CODE": "123456",
"NTFY_SERVER": "https://ntfy.sh",
"NTFY_TOPIC": "garmin-notifications",
"NTFY_TOKEN": "your-token"
}
}
}
}
- Restart Claude Desktop
The server will automatically authenticate and be available for use.
With MCP Inspector (For Testing)
# Test the server
npx @modelcontextprotocol/inspector venv/bin/python garmin_mcp_server_fixed.py
Open the provided URL to test tools interactively.
📊 Available Tools
Activity Management
list_activities(limit)
- List recent activitiesget_activity_details(activity_id)
- Get detailed activity informationget_activity_splits(activity_id)
- Get activity lap/split dataexport_activity(activity_id, format)
- Export activity data
Health & Wellness
get_user_profile()
- Get user profile informationget_steps(date)
- Get daily step countget_heart_rate(date)
- Get heart rate dataget_sleep_data(date)
- Get sleep informationget_stress_data(date)
- Get stress levelsget_body_battery(date)
- Get body battery data
Device Management
list_devices()
- List connected devicesget_device_info(device_id)
- Get device detailssync_device(device_id)
- Trigger device sync
Training & Workouts
list_workouts()
- List saved workoutsget_training_plan()
- Get current training planget_performance_stats()
- Get performance metrics
Body Composition
get_weight_data(date)
- Get weight measurementsget_body_composition(date)
- Get body composition data
💬 Usage Examples
Once connected in Claude, you can ask questions like:
Activities:
- "Show me my recent activities"
- "What was my latest run like?"
- "Export my last cycling activity as GPX"
Health Data:
- "How many steps did I take yesterday?"
- "What was my sleep like last night?"
- "Show me my heart rate trends this week"
Training:
- "What workouts do I have planned?"
- "How is my fitness progress?"
- "Show me my training load"
Devices:
- "What devices do I have connected?"
- "When was my watch last synced?"
🔧 Advanced Features
Headless Authentication System
The server includes a sophisticated headless authentication system (headless_auth.py
) that:
- Auto-validates existing tokens before attempting fresh authentication
- Supports multiple MFA strategies for different deployment scenarios
- Provides clear instructions when manual intervention is needed
- Logs all authentication attempts for monitoring and debugging
- Handles rate limiting gracefully with automatic retry logic
Notification System
Integrated ntfy notifications keep you informed about:
- Authentication success/failure
- Rate limiting events
- MFA requirements
- Server status changes
Monitoring & Logging
- Authentication logs stored in
auth_log.json
- Performance tracking for optimization
- Error handling with detailed logging
- Rate limit monitoring and alerting
🛡️ Security Considerations
- Never commit your
.env
file to version control - Use environment variables for production deployments
- Rotate MFA codes regularly when using static codes
- Monitor authentication logs for suspicious activity
- Use webhook authentication for enhanced security in automated systems
🐛 Troubleshooting
Authentication Issues
Problem: "Authentication failed: No MFA code available" Solution:
- Check your email/phone for Garmin 2FA code
- Set
GARMIN_MFA_CODE
in.env
file - Or use interactive authentication:
python authenticate.py
Problem: "Rate limited (429 error)" Solution:
- Wait 5-10 minutes before retrying
- Server will automatically retry after rate limit expires
- Monitor
auth_log.json
for retry status
Problem: "Token validation failed" Solution:
- Delete existing token files:
rm ~/.garminconnect*
- Run fresh authentication:
python authenticate.py
- Restart the MCP server
Connection Issues
Problem: "spawn venv/bin/python ENOENT" Solution: Use absolute paths in Claude Desktop configuration
Problem: "Server disconnected" Solution:
- Check Claude Desktop logs
- Verify Python virtual environment is activated
- Test server manually with MCP Inspector
Debugging Steps
-
Test authentication manually:
source venv/bin/activate python headless_auth.py
-
Check server startup:
npx @modelcontextprotocol/inspector venv/bin/python garmin_mcp_server_fixed.py
-
Review logs:
- Authentication:
auth_log.json
- Claude Desktop:
~/Library/Logs/Claude/
- Server output: Check terminal/console output
- Authentication:
📝 Logging
The server maintains detailed logs:
- Authentication attempts with timestamps and outcomes
- API call performance metrics
- Error conditions with stack traces
- Rate limiting events and recovery
Check auth_log.json
for authentication history and troubleshooting information.
🤝 Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all authentication methods work
- Update documentation
- Submit a pull request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built on garminconnect library
- Uses FastMCP for MCP server implementation
- Notification system powered by ntfy
Note: This server requires a valid Garmin Connect account and handles sensitive authentication data. Always follow security best practices when deploying.