Building an AI Training Coach with MCP and Intervals.icu

2 min read

I recently discovered Intervals.icu, a training platform that's popular with cyclists and triathletes - think Strava but with serious analytics... and they have an API. I've also been playing with the Model Context Protocol (MCP) recently - it's a way to give AI services like Claude access to external data sources.

Instead of asking “Should I do intervals today?” and getting textbook responses, I could ask Claude to look at my actual training load, recovery metrics, and upcoming schedule. That way, the advice is context-aware—just like a real coach.

Looking through the Intervals.icu forum, I found that Miguel had already built a Python MCP server for this exact purpose. It's an excellent implementation, but I decided to build my own TypeScript version. Partly because I wanted to tweak some of the data and experiment with MCP, partly because I prefer TypeScript for API integrations.

What I Built

The result is an MCP server that gives Claude access to your Intervals.icu data through several tools:

Activity Tools:

  • getActivities - List your recent training sessions
  • getActivityDetails - Deep dive into specific workouts

Event Management (pre-planned workouts):

  • createEvent - Schedule new workouts
  • createBulkEvents - Set up training blocks
  • getEvents - See what's planned
  • deleteEvent / deleteBulkEvents - Clean up your calendar

Profile & Wellness:

  • getAthleteDetails - Your stats and settings
  • getWellnessData - Recovery metrics, sleep, stress levels

How It Works

Once configured, Claude can actually see your training data. You can ask questions like "How's my training load this week?" and it'll check your actual sessions. Ask "Should I do that brick workout tomorrow?" and it can see your recent bike and run sessions, recovery status, and what you have planned. It's like having a coach who never forgets a workout and can instantly recall every metric you've ever recorded.

You can even do some fun stuff like ask it to act like a certain coach or ... David Goggins 😳

David Goggins

Technical Implementation

The core tech stack:

  • TypeScript with the MCP SDK
  • Auto-generated API client from Intervals.icu's OpenAPI spec
  • Zod for input validation
  • Basic error handling and logging

Since Intervals.icu publishes an OpenAPI spec, generating a full Axios API client with hey-api was trivial - a real time saver! Using Cursor, it was fairly straightforward to prompt it to create the MCP tools from the available client methods.

Setup

If you want to try it, full instructions are in the GitHub repo readme. It takes a bit of setup if you're new to coding, but it's well documented. I might look into hosting the server somewhere at some point so it's available online rather than just locally.

What's Next

It's worth noting that this is in no way replacing human coaches - my best results have always come from learning from and working with humans. But it is democratising access to data-driven training advice, and I'm excited to see how this technology develops. If you’re curious or want to contribute, feel free to fork the repo or open an issue.

I'll be using this "coach" in my build to Valencia Marathon in December and will report back on how useful it actually is in practice.