Metadata-Version: 2.5
Name: intervals-icu-planner-mcp
Version: 0.1.0
Summary: MCP server and CLI to push, inspect and remove whole training plans on intervals.icu, safely
Project-URL: Homepage, https://github.com/gustavosoares/intervals-icu-planner-mcp
Project-URL: Issues, https://github.com/gustavosoares/intervals-icu-planner-mcp/issues
Project-URL: Changelog, https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/CHANGELOG.md
License-Expression: MIT
License-File: LICENSE
Keywords: cycling,intervals.icu,mcp,training-plan,zwift,zwo
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: mcp<3,>=2.3
Requires-Dist: pydantic>=2.7
Requires-Dist: pyyaml>=6.0
Requires-Dist: ruamel-yaml>=0.18
Provides-Extra: dev
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: types-pyyaml; extra == 'dev'
Description-Content-Type: text/markdown

# intervals-icu-planner-mcp

[![tests](https://github.com/gustavosoares/intervals-icu-planner-mcp/actions/workflows/tests.yml/badge.svg)](https://github.com/gustavosoares/intervals-icu-planner-mcp/actions/workflows/tests.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/LICENSE)
![Python 3.10–3.13](https://img.shields.io/badge/python-3.10%E2%80%933.13-blue.svg)
[![MCP server](https://img.shields.io/badge/MCP-server-8A2BE2.svg)](https://modelcontextprotocol.io)

**Plan a whole training block with Claude and put it on your
[intervals.icu](https://intervals.icu) calendar in one go, safely.**

![One week of the example plan on the intervals.icu calendar](https://raw.githubusercontent.com/gustavosoares/intervals-icu-planner-mcp/main/docs/images/calendar-week.png)

<!-- TODO: add a short GIF of Claude showing a dry-run diff and applying it -->

## What it's for

If you train with a plan, you know the routine: every week you open the
calendar and drag in Tuesday's intervals, Wednesday's endurance ride,
Saturday's long ride… for twelve weeks. Then you get sick, and all of it
has to move.

With this, you ask Claude in plain words:

> *"Put my 12-week winter base plan on my calendar, starting next Monday."*

Claude shows you exactly what it's going to add, and nothing changes until
you say yes. Then the whole block lands on your intervals.icu calendar, and
from there each day's workout shows up in **Zwift, MyWhoosh or on your
Garmin**, ready to ride.

Later you can just ask:

- *"I was sick this week, push the rest of the plan back a week."*
- *"Move Thursday's sprints to Friday."*
- *"How did last week go compared to the plan?"*

It only ever touches the workouts it put there. Your races, notes and
anything you added by hand are left alone.

<details>
<summary>What's an MCP server?</summary>

[MCP](https://modelcontextprotocol.io) is how apps like Claude get new
abilities. This project is a small program that runs on your computer and
gives Claude a few safe tools for your intervals.icu calendar. Claude
decides when to use them, and asks you before writing anything.
</details>

## Why plan-level

General intervals.icu MCP servers expose the API one event at a time: create
an event, delete an event, list activities. That works for a single workout.
For a 12-week block it means dozens of separate writes, with nothing tying
them together and nothing that shows you what will change first.

This server works on **whole plans**:

- **One file, one plan.** You describe the block once in a `plan.yaml`
  (week templates, per-week changes, recovery weeks) plus `.zwo` workouts.
  Edit the file and push again: events are updated in place, never duplicated.
- **Diff before write.** Every write tool is a dry run by default and returns
  a per-date diff (`+` new, `~` updated, `=` unchanged, `!` stale).
- **A plan only touches its own events.** Each event carries a uid,
  `planner-<plan_id>-w<NN>-<day>`, and the server never modifies an event
  without one.
- **Reversible.** `delete_plan` removes exactly the events a plan created, and
  `push_plan` with `prune=true` removes the ones you took out of the plan.

It also reads your fitness (CTL / ATL / Form) and completed activities, so
you can ask Claude how the block is going.

## Quick start

1. **Get an API key**: intervals.icu → **Settings** → **Developer Settings** →
   **API key**. On a Mac, keep it in the Keychain rather than in a config
   file: see [docs/setup.md](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/setup.md).
2. **Install [uv](https://docs.astral.sh/uv/)**, then add the server.

   **Claude Desktop** (Settings → Developer → Edit Config):

   ```json
   {
     "mcpServers": {
       "intervals-icu-planner": {
         "command": "uvx",
         "args": [
           "--from", "git+https://github.com/gustavosoares/intervals-icu-planner-mcp",
           "intervals-icu-planner-mcp"
         ],
         "env": { "INTERVALS_ICU_API_KEY": "your-key-here" }
       }
     }
   }
   ```

   **Claude Code**:

   ```sh
   claude mcp add -s user intervals-icu-planner -e INTERVALS_ICU_API_KEY=your-key-here -- \
     uvx --from git+https://github.com/gustavosoares/intervals-icu-planner-mcp intervals-icu-planner-mcp
   ```

3. **Restart Claude** and check the `intervals-icu-planner` tools are listed.
   If they aren't, see [docs/troubleshooting.md](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/troubleshooting.md).

## Try it

Clone the repo for the [example plan](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/examples/winter-base-12wk/) (12 weeks
of winter base, all targets in % of FTP), then paste this into Claude:

> Push `/path/to/intervals-icu-planner-mcp/examples/winter-base-12wk/plan.yaml`
> starting next Monday. Show me the dry run first and don't apply anything
> until I say so.

Claude calls `push_plan` as a dry run and shows you the diff:

```
Winter Base 12 Weeks (winterbase): 12 weeks, 2026-11-30 -> 2027-02-21

Week 1, 2026-11-30
  + 2026-12-01 Tue  WORKOUT  W09_Tempo_60_2x12.zwo
  + 2026-12-02 Wed  WORKOUT  W10_Z2_45.zwo
  + 2026-12-03 Thu  WORKOUT  W04_Z2_60_Neuromuscular_Sprints.zwo
  + 2026-12-05 Sat  WORKOUT  W12_Group_Ride_2h30_Placeholder.zwo
  + 2026-12-06 Sun  WORKOUT  W01_Recovery_Spin_45.zwo
...
60 new, 0 updated, 0 unchanged, 0 stale.
Dry run: nothing was written. Run again with dry_run=false to apply.
```

Say "apply it" and the plan lands on your calendar, as in the screenshot
above. More things to ask:

- *"What's planned for next week?"*
- *"How did last week go? Compare what was planned with what I rode."*
- *"Show my fitness, fatigue and form over the last 6 weeks."*
- *"Move week 3's Thursday session to Friday."*
- *"I was sick, push the rest of the plan back a week."*
- *"What's in my workout library?"*
- *"Remove the winterbase plan from my calendar."*

Anything that writes shows you a dry run first and waits for your OK.

## Tools

| Tool | What it does | Writes? |
|---|---|---|
| `push_plan(plan_yaml, start_date?, dry_run=true, prune=false)` | Validate a plan, diff it against the calendar, upsert new and updated events; with `prune=true` also delete the plan's stale events | only with `dry_run=false` |
| `get_planned(oldest, newest, plan_id?)` | List planned events; optionally only one plan's | no |
| `delete_plan(plan_id, dry_run=true, oldest?, newest?)` | Remove every event the plan created, nothing else | only with `dry_run=false` |
| `get_fitness(oldest, newest)` | CTL, ATL, Form (TSB = CTL − ATL) and Form as % of CTL, per day | no |
| `get_activities(oldest, newest)` | Completed activities: time, distance, load, avg/normalized power, IF, HR | no |
| `move_workout(plan_yaml, week, day, to_day, to_week?, swap=false, dry_run=true)` | Move one session to another day: edits plan.yaml, then syncs with prune | only with `dry_run=false` |
| `shift_plan(plan_yaml, weeks=1, from_week?, dry_run=true)` | Push the rest of the plan back N weeks (illness, travel); past weeks stay | only with `dry_run=false` |
| `list_library(folder?)` | Your intervals.icu workout library: folders and plans with their workouts | no |

`plan_yaml` is a path to the file. Everything also works from the
command line: see [docs/cli.md](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/cli.md).

## Writing your own plan

```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/gustavosoares/intervals-icu-planner-mcp/main/schemas/plan.schema.json
id: myblock
name: My 3-week block
start: 2026-11-30            # a Monday
templates:
  build:
    tue: W09_Tempo_60_2x12.zwo
    thu: W04_Z2_60_Neuromuscular_Sprints.zwo
    sat: { note: Long outdoor ride }
weeks:
  - { template: build }
  - { template: build, overrides: { thu: W06_Tempo_3x10.zwo } }
  - { template: build, overrides: { thu: null }, recovery: true }
```

Workouts are `.zwo` files in a `workouts/` folder next to the plan. The first
line gives you validation and autocomplete in editors with the YAML language
server. The full reference (overrides, notes, re-pushing, pruning, moving and
shifting) is in [docs/plan-reference.md](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/plan-reference.md).

## Safety

This writes to your real training calendar, so it's built to be hard to misuse:

- **Dry run first**: every write returns a diff and waits for your OK.
- **Only its own events**: nothing without the plan's exact uid is touched or even shown.
- **Validate before upload**: the plan and every `.zwo` are checked, and one error means nothing is sent.
- **The API key stays private**: never logged, printed or put in error messages.
- **Careful file edits**: moves and shifts are previewed, never touch the past, and are written atomically.

Details in [docs/safety.md](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/safety.md).

## Documentation

- [Setup](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/setup.md): API key, the macOS Keychain, Claude Desktop and Claude Code
- [plan.yaml reference](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/plan-reference.md): fields, uids, pruning, moving and shifting, the example plan
- [Training apps and activities](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/training-apps.md): Zwift, MyWhoosh, Garmin, ERG mode, Strava limits
- [CLI](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/cli.md): every command
- [Safety design](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/safety.md)
- [How it works](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/how-it-works.md): architecture and intervals.icu API notes
- [Troubleshooting](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/docs/troubleshooting.md)
- [Contributing](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/CONTRIBUTING.md) and [Changelog](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/CHANGELOG.md)

## Roadmap

- Activity analysis: planned vs completed, compliance per week
- OAuth and the streamable HTTP transport, for claude.ai custom connectors
- Writing to the workout library (import or remove workouts in one dedicated folder)
- PyPI release

## A note on AI assistance

This project is built with help from AI coding tools, which speed up writing code, tests
and documentation. Every change is reviewed and tested by a human maintainer before it's
merged, and the maintainer is responsible for what ships, including the safety rules above.

## License

MIT, see [LICENSE](https://github.com/gustavosoares/intervals-icu-planner-mcp/blob/main/LICENSE).
