Skip to main content
Glama
mvilanova

Intervals.icu MCP Server

by mvilanova
wellness.py2.59 kB
""" Wellness-related MCP tools for Intervals.icu. This module contains tools for retrieving athlete wellness data. """ from intervals_mcp_server.api.client import make_intervals_request from intervals_mcp_server.config import get_config from intervals_mcp_server.utils.formatting import format_wellness_entry from intervals_mcp_server.utils.validation import resolve_athlete_id, resolve_date_params # Import mcp instance from shared module for tool registration from intervals_mcp_server.mcp_instance import mcp # noqa: F401 config = get_config() @mcp.tool() async def get_wellness_data( athlete_id: str | None = None, api_key: str | None = None, start_date: str | None = None, end_date: str | None = None, ) -> str: """Get wellness data for an athlete from Intervals.icu Args: athlete_id: The Intervals.icu athlete ID (optional, will use ATHLETE_ID from .env if not provided) api_key: The Intervals.icu API key (optional, will use API_KEY from .env if not provided) start_date: Start date in YYYY-MM-DD format (optional, defaults to 30 days ago) end_date: End date in YYYY-MM-DD format (optional, defaults to today) """ # Resolve athlete ID and date parameters athlete_id_to_use, error_msg = resolve_athlete_id(athlete_id, config.athlete_id) if error_msg: return error_msg start_date, end_date = resolve_date_params(start_date, end_date) # Call the Intervals.icu API params = {"oldest": start_date, "newest": end_date} result = await make_intervals_request( url=f"/athlete/{athlete_id_to_use}/wellness", api_key=api_key, params=params ) if isinstance(result, dict) and "error" in result: return f"Error fetching wellness data: {result.get('message')}" # Format the response if not result: return ( f"No wellness data found for athlete {athlete_id_to_use} in the specified date range." ) wellness_summary = "Wellness Data:\n\n" # Handle both list and dictionary responses if isinstance(result, dict): for date_str, data in result.items(): # Add the date to the data dictionary if it's not already present if isinstance(data, dict) and "date" not in data: data["date"] = date_str wellness_summary += format_wellness_entry(data) + "\n\n" elif isinstance(result, list): for entry in result: if isinstance(entry, dict): wellness_summary += format_wellness_entry(entry) + "\n\n" return wellness_summary

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mvilanova/intervals-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server