A Model Context Protocol server for TrainingPeaks with analytics focus
Project description
TrainingPeaks MCP Server
A Model Context Protocol server for TrainingPeaks with an analytics focus — enabling real-time querying of training data, performance trends, CTL/ATL/TSB analysis, and training load optimization through Claude Desktop.
Features
13 tools organized across 5 categories:
| Category | Tools | Description |
|---|---|---|
| Auth | tp_auth_status, tp_refresh_auth |
Check/refresh authentication |
| Profile | tp_get_profile |
Athlete profile + auto-detect ID |
| Workouts | tp_get_workouts, tp_get_workout |
List and detail workouts |
| Fitness | tp_get_fitness |
CTL/ATL/TSB with computed values |
| Peaks | tp_get_peaks, tp_get_workout_prs |
Personal records by sport |
| Analytics | tp_training_load_summary |
Weekly/monthly TSS, load ramp rate |
tp_fitness_trend |
CTL trajectory, 7-day projection | |
tp_workout_analysis |
Efficiency factor, variability index | |
tp_performance_summary |
Sport-specific volume & consistency | |
tp_training_zones_distribution |
IF-based zone breakdown |
Key feature: CTL/ATL/TSB are computed from TSS using standard exponential weighted moving averages (42-day/7-day time constants), since the TP API doesn't return these values directly.
Prerequisites
- Python 3.12+
- uv (recommended) or pip
- Claude Desktop (to use the MCP server)
- A TrainingPeaks account with training data
Installation
Step 1: Clone the repository
git clone https://github.com/banananovej-chuan/tp-mcp-server.git
cd tp-mcp-server
Step 2: Create a virtual environment and install dependencies
uv venv --python 3.12
uv pip install .
Note: If you don't have
uv, install it first:curl -LsSf https://astral.sh/uv/install.sh | sh
Step 3: Get your TrainingPeaks auth cookie
This server authenticates using your browser's TrainingPeaks session cookie. Here's how to get it:
- Open your browser and go to trainingpeaks.com
- Log in to your account
- Open Developer Tools:
- Mac:
Cmd + Option + I - Windows/Linux:
F12orCtrl + Shift + I
- Mac:
- Click the Application tab (Chrome/Edge) or Storage tab (Firefox)
- In the left sidebar, expand Cookies and click on
https://www.trainingpeaks.com - Find the cookie named
Production_tpAuth - Double-click its Value column and copy the entire value (it's a long string)
Step 4: Configure the environment
cp .env.example .env
Open .env in a text editor and replace your_cookie_value_here with the cookie you copied:
TP_AUTH_COOKIE=V0014F_4tV2mrk...your_long_cookie_value...
Step 5: Verify it works
uv run python -m tp_mcp_server
If authentication is successful, the server will start and wait for MCP connections. Press Ctrl+C to stop it.
Claude Desktop Configuration
To use this server with Claude Desktop, you need to add it to Claude's MCP config file.
1. Find your config file
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
If the file doesn't exist, create it.
2. Find your absolute path to the server
Run this command in the tp-mcp-server directory to get the full path:
echo "$(pwd)/.venv/bin/python"
This will output something like:
/Users/yourname/projects/tp-mcp-server/.venv/bin/python
3. Add the server config
Open the config file and add the following. You must replace two values:
- Replace the
commandpath with the output from step 2 - Replace the
TP_AUTH_COOKIEvalue with your cookie from the installation steps
{
"mcpServers": {
"trainingpeaks": {
"command": "/Users/yourname/projects/tp-mcp-server/.venv/bin/python",
"args": ["-m", "tp_mcp_server"],
"env": {
"TP_AUTH_COOKIE": "your_Production_tpAuth_cookie_value"
}
}
}
}
Important: The
commandpath must be an absolute path (starting with/). Do not use~or relative paths — Claude Desktop won't resolve them.
Alternative — if you have uv installed globally:
{
"mcpServers": {
"trainingpeaks": {
"command": "uv",
"args": ["run", "--directory", "/Users/yourname/projects/tp-mcp-server", "python", "-m", "tp_mcp_server"],
"env": {
"TP_AUTH_COOKIE": "your_Production_tpAuth_cookie_value"
}
}
}
}
4. Restart Claude Desktop
After saving the config file, fully quit and reopen Claude Desktop. You should see "trainingpeaks" listed as a connected MCP server (look for the hammer icon).
Example Queries
Once connected in Claude Desktop, try:
- "What's my current fitness level?"
- "Show my training load trend for the last 3 months"
- "Analyze my last bike workout"
- "What are my power PRs?"
- "How is my training zone distribution this month?"
- "Compare my bike performance over the last 90 days"
Refreshing Your Auth Cookie
The TrainingPeaks auth cookie expires periodically (typically every few days to weeks). When it expires:
- You'll see authentication errors in Claude Desktop
- Re-extract the cookie from your browser (repeat Step 3 from Installation)
- Update the
TP_AUTH_COOKIEvalue in both your.envfile and Claude Desktop config - Restart Claude Desktop
Architecture
src/tp_mcp_server/
├── server.py # FastMCP entry point
├── mcp_instance.py # Shared MCP instance
├── config.py # Environment config
├── api/
│ ├── client.py # Async httpx client, token management
│ └── endpoints.py # API URL constants
├── auth/
│ ├── storage.py # Cookie storage (env/keyring)
│ └── browser.py # Browser cookie extraction
├── tools/
│ ├── auth.py # Auth status/refresh
│ ├── profile.py # Athlete profile
│ ├── workouts.py # Workout list/detail
│ ├── fitness.py # CTL/ATL/TSB data
│ ├── peaks.py # Personal records
│ └── analytics.py # Derived analytics
├── models/
│ ├── workout.py # Workout models
│ ├── fitness.py # Fitness models + CTL computation
│ ├── peaks.py # PR models
│ └── profile.py # Profile model
└── utils/
├── dates.py # Date helpers
└── formatting.py # Output formatting
Known Limitations
- Internal API: TrainingPeaks has no public API. This uses the same internal API as the web app, which could change without notice.
- Cookie auth: Requires periodic browser re-login to refresh the cookie.
- Sport-level PRs: The
/personalrecord/v2/athletes/{id}/{sport}endpoint returns 500. PRs are aggregated from individual workouts instead. - CTL/ATL/TSB: The API returns
"NaN"for these values. They are computed locally from TSS data. - Rate limiting: Requests are throttled to 150ms apart to avoid hitting TP rate limits.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tp_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: tp_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 77.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70afd4f972235c81dd25e29a01d5a98f482fab473186f1c54cf19549c8c02bd1
|
|
| MD5 |
e9e884a6ad613ac65146fce193c4a434
|
|
| BLAKE2b-256 |
3ef7454af88959e985c53214f1053886e1dedc32c9a9a32f890640f2c67a88fb
|
File details
Details for the file tp_mcp_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tp_mcp_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57a6e1d4e90606d64b19fdb8776c19040a15f8108df9c77d29d089c17aff3e2a
|
|
| MD5 |
c93f3ba93eb4b80e7a8034cc16ad47dd
|
|
| BLAKE2b-256 |
04c78e07d684a388c1248435a73f803aa2464f3f6f99c92b31914f35ac5a5477
|