{
  "name": "flow_state_endurance",
  "description": "Tools for managing training data on Flow State Endurance — workouts, events, athlete profiles, training plans, and Garmin sync.",
  "tools": [
    {
      "name": "list_workouts",
      "description": "List workouts within a date range. Returns planned and completed workouts with structured data.",
      "parameters": {
        "type": "object",
        "properties": {
          "from": { "type": "string", "description": "Start date (YYYY-MM-DD). Default: today." },
          "to": { "type": "string", "description": "End date (YYYY-MM-DD). Default: today + 14 days." },
          "sport": { "type": "string", "description": "Filter by sport (e.g. Run, Bike, Swim)" },
          "limit": { "type": "integer", "description": "Max results (1-200, default 50)" },
          "offset": { "type": "integer", "description": "Pagination offset" }
        }
      }
    },
    {
      "name": "get_workout",
      "description": "Get a single workout by ID.",
      "parameters": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Workout UUID" }
        },
        "required": ["id"]
      }
    },
    {
      "name": "create_workout",
      "description": "Create a new workout on the athlete's calendar.",
      "parameters": {
        "type": "object",
        "properties": {
          "date": { "type": "string", "description": "Date (YYYY-MM-DD)" },
          "title": { "type": "string", "description": "Workout title (e.g. 'Tempo 8K')" },
          "sport": { "type": "string", "description": "Sport type (default: Run)" },
          "description": { "type": "string", "description": "Workout description/notes" },
          "duration_minutes": { "type": "number", "description": "Planned duration in minutes" },
          "steps": { "type": "array", "items": { "type": "object" }, "description": "Structured workout steps" },
          "training_plan_id": { "type": "string", "description": "Link to a training plan" }
        },
        "required": ["date", "title"]
      }
    },
    {
      "name": "update_workout",
      "description": "Update an existing workout.",
      "parameters": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Workout UUID" },
          "date": { "type": "string" },
          "title": { "type": "string" },
          "sport": { "type": "string" },
          "description": { "type": "string" },
          "duration_minutes": { "type": "number" },
          "steps": { "type": "array", "items": { "type": "object" } }
        },
        "required": ["id"]
      }
    },
    {
      "name": "delete_workout",
      "description": "Delete a workout.",
      "parameters": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Workout UUID" }
        },
        "required": ["id"]
      }
    },
    {
      "name": "list_events",
      "description": "List races and events.",
      "parameters": {
        "type": "object",
        "properties": {
          "startDate": { "type": "string", "description": "Start date filter (YYYY-MM-DD)" },
          "endDate": { "type": "string", "description": "End date filter (YYYY-MM-DD)" },
          "priority": { "type": "string", "enum": ["A", "B", "C"], "description": "Priority filter" }
        }
      }
    },
    {
      "name": "create_event",
      "description": "Create a race or event.",
      "parameters": {
        "type": "object",
        "properties": {
          "name": { "type": "string", "description": "Event name" },
          "date": { "type": "string", "description": "Event date (YYYY-MM-DD)" },
          "event_type": { "type": "string", "description": "Type (race, training, social)" },
          "race_type": { "type": "string", "description": "Race type (5k, 10k, half, marathon, ultra)" },
          "distance_value": { "type": "number" },
          "distance_unit": { "type": "string" },
          "location": { "type": "string" },
          "priority": { "type": "string", "enum": ["A", "B", "C"] },
          "target_time_seconds": { "type": "number" }
        },
        "required": ["name", "date"]
      }
    },
    {
      "name": "get_athlete",
      "description": "Get athlete profile including pace zones, goals, and preferences. Use id='me' for the authenticated user.",
      "parameters": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Athlete user ID or 'me'" }
        },
        "required": ["id"]
      }
    },
    {
      "name": "update_athlete",
      "description": "Update athlete profile (experience level, paces, goals, etc).",
      "parameters": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Athlete user ID or 'me'" },
          "experience_level": { "type": "string" },
          "goal": { "type": "string" },
          "max_heart_rate": { "type": "integer" },
          "easy_pace_seconds": { "type": "integer", "description": "Easy pace per km in seconds" },
          "tempo_pace_seconds": { "type": "integer" },
          "threshold_pace_seconds": { "type": "integer" },
          "weekly_mileage_target": { "type": "number" }
        },
        "required": ["id"]
      }
    },
    {
      "name": "get_recovery",
      "description": "Get recovery metrics: body battery, HRV, sleep, stress (from Garmin data).",
      "parameters": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Athlete user ID or 'me'" }
        },
        "required": ["id"]
      }
    },
    {
      "name": "create_plan",
      "description": "Create a new training plan.",
      "parameters": {
        "type": "object",
        "properties": {
          "name": { "type": "string", "description": "Plan name" },
          "start_date": { "type": "string", "description": "Start date (YYYY-MM-DD)" },
          "end_date": { "type": "string", "description": "End date (YYYY-MM-DD)" },
          "race_date": { "type": "string", "description": "Goal race date" },
          "phase": { "type": "string", "enum": ["base", "build", "peak", "taper", "recovery"] },
          "goal": { "type": "string" },
          "targetTime": { "type": "string" }
        },
        "required": ["name"]
      }
    },
    {
      "name": "get_plan",
      "description": "Get training plan details including current week and workout count.",
      "parameters": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Plan UUID" }
        },
        "required": ["id"]
      }
    },
    {
      "name": "adapt_plan",
      "description": "Adapt a training plan — change phase, trigger recovery mode, or adjust dates.",
      "parameters": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Plan UUID" },
          "scope": { "type": "string", "enum": ["recovery"] },
          "phase": { "type": "string", "enum": ["base", "build", "peak", "taper", "recovery"] },
          "weeksAhead": { "type": "integer" },
          "end_date": { "type": "string" },
          "reason": { "type": "string" }
        },
        "required": ["id"]
      }
    },
    {
      "name": "sync_garmin",
      "description": "Push workouts to Garmin Connect. Defaults to next 2 weeks if no filters.",
      "parameters": {
        "type": "object",
        "properties": {
          "plan_id": { "type": "string", "description": "Sync all workouts in this plan" },
          "workout_ids": { "type": "array", "items": { "type": "string" }, "description": "Specific workout IDs to sync" },
          "start_date": { "type": "string" },
          "end_date": { "type": "string" }
        }
      }
    }
  ],
  "auth": {
    "type": "bearer",
    "header": "Authorization",
    "format": "Bearer fse_live_...",
    "description": "Generate an API key from Flow State Settings > API Keys"
  },
  "base_url": "https://reachflowstate.ai/api/v1",
  "examples": {
    "claude_mcp": {
      "description": "Example MCP tool config for Claude Desktop",
      "config": {
        "mcpServers": {
          "flowstate": {
            "command": "npx",
            "args": ["-y", "@anthropic/openapi-to-mcp", "--spec", "https://reachflowstate.ai/api/v1/openapi.json"]
          }
        }
      }
    },
    "openai_function_calling": {
      "description": "Use the tools array directly as OpenAI function definitions",
      "note": "Each tool maps to { type: 'function', function: { name, description, parameters } }"
    },
    "curl": {
      "list_workouts": "curl -H 'Authorization: Bearer fse_live_YOUR_KEY' 'https://reachflowstate.ai/api/v1/workouts?from=2026-02-01&to=2026-02-28'",
      "create_workout": "curl -X POST -H 'Authorization: Bearer fse_live_YOUR_KEY' -H 'Content-Type: application/json' -d '{\"date\":\"2026-03-01\",\"title\":\"Easy 5K\",\"sport\":\"Run\",\"duration_minutes\":30}' 'https://reachflowstate.ai/api/v1/workouts'"
    }
  }
}
