resolve_supported_strength_exercise
Look up supported strength exercises by query. Returns matching Garmin exercises for building strength workouts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The MCP tool handler function that exposes 'resolve_supported_strength_exercise' as a @mcp.tool. It delegates to resolve_strength_exercise from payloads.py.
def resolve_supported_strength_exercise(query: str) -> dict: return resolve_strength_exercise(query) - The core resolve_strength_exercise function that performs alias lookup and fuzzy matching. First tries an exact normalized match against EXERCISE_ALIAS_MAP, then falls back to difflib.get_close_matches for suggestions.
def resolve_strength_exercise(value: str) -> dict[str, Any]: normalized = _normalize_text(value) direct = EXERCISE_ALIAS_MAP.get(normalized) if direct: return { "query": value, "normalizedQuery": normalized, "matched": True, "mapping": direct, "suggestions": [], } suggestions = difflib.get_close_matches(normalized, EXERCISE_ALIAS_MAP.keys(), n=5, cutoff=0.5) return { "query": value, "normalizedQuery": normalized, "matched": False, "mapping": None, "suggestions": [ {"alias": alias, "mapping": EXERCISE_ALIAS_MAP[alias]} for alias in suggestions ], } - Helper that normalizes a string by lowercasing, stripping, replacing hyphens/underscores with spaces, and collapsing whitespace.
def _normalize_text(value: str) -> str: return " ".join(value.strip().lower().replace("-", " ").replace("_", " ").split()) - The EXERCISE_ALIAS_MAP dictionary that maps normalized user-friendly names to Garmin exercise categories and exercise names.
EXERCISE_ALIAS_MAP = { "bench press": {"category": "BENCH_PRESS", "exerciseName": "BENCH_PRESS"}, "flat db press": {"category": "BENCH_PRESS", "exerciseName": "DUMBBELL_BENCH_PRESS"}, "dumbbell bench press": {"category": "BENCH_PRESS", "exerciseName": "DUMBBELL_BENCH_PRESS"}, "incline db press": {"category": "BENCH_PRESS", "exerciseName": "INCLINE_DUMBBELL_BENCH_PRESS"}, "incline dumbbell bench press": {"category": "BENCH_PRESS", "exerciseName": "INCLINE_DUMBBELL_BENCH_PRESS"}, "hack squat": {"category": "SQUAT", "exerciseName": "BARBELL_HACK_SQUAT"}, "leg press": {"category": "SQUAT", "exerciseName": "LEG_PRESS"}, "romanian deadlift": {"category": "DEADLIFT", "exerciseName": "BARBELL_STRAIGHT_LEG_DEADLIFT"}, "rdl": {"category": "DEADLIFT", "exerciseName": "BARBELL_STRAIGHT_LEG_DEADLIFT"}, "seated hamstring curl": {"category": "LEG_CURL", "exerciseName": "LEG_CURL"}, "leg curl": {"category": "LEG_CURL", "exerciseName": "LEG_CURL"}, "leg extension": {"category": "CRUNCH", "exerciseName": "LEG_EXTENSIONS"}, "leg extensions": {"category": "CRUNCH", "exerciseName": "LEG_EXTENSIONS"}, "t bar row": {"category": "ROW", "exerciseName": "T_BAR_ROW"}, "seated cable row": {"category": "ROW", "exerciseName": "SEATED_CABLE_ROW"}, "row": {"category": "ROW", "exerciseName": "ROW"}, "lat pulldown": {"category": "PULL_UP", "exerciseName": "LAT_PULLDOWN"}, "wide grip lat pulldown": {"category": "PULL_UP", "exerciseName": "WIDE_GRIP_LAT_PULLDOWN"}, "pull up": {"category": "PULL_UP", "exerciseName": "PULL_UP"}, "seated db shoulder press": {"category": "SHOULDER_PRESS", "exerciseName": "SEATED_DUMBBELL_SHOULDER_PRESS"}, "shoulder press": {"category": "SHOULDER_PRESS", "exerciseName": "SHOULDER_PRESS"}, "ez bar skull crusher": {"category": "TRICEPS_EXTENSION", "exerciseName": "LYING_EZ_BAR_TRICEPS_EXTENSION"}, "skull crusher": {"category": "TRICEPS_EXTENSION", "exerciseName": "LYING_EZ_BAR_TRICEPS_EXTENSION"}, "ez bar curl": {"category": "CURL", "exerciseName": "STANDING_EZ_BAR_BICEPS_CURL"}, "db bicep curl": {"category": "CURL", "exerciseName": "STANDING_ALTERNATING_DUMBBELL_CURLS"}, "dumbbell curl": {"category": "CURL", "exerciseName": "STANDING_ALTERNATING_DUMBBELL_CURLS"}, "db lateral raise": {"category": "LATERAL_RAISE", "exerciseName": "LEANING_DUMBBELL_LATERAL_RAISE"}, "dumbbell lateral raise": {"category": "LATERAL_RAISE", "exerciseName": "LEANING_DUMBBELL_LATERAL_RAISE"}, "seated calf raise": {"category": "CALF_RAISE", "exerciseName": "SEATED_CALF_RAISE"}, "cable crunch": {"category": "CRUNCH", "exerciseName": "KNEELING_CABLE_CRUNCH"}, "crunch": {"category": "CRUNCH", "exerciseName": "CRUNCH"}, } - src/garmin_workouts_mcp/server.py:130-131 (registration)Registration of the tool via the @mcp.tool decorator, which registers it with the FastMCP server (same as the handler location).
@mcp.tool def resolve_supported_strength_exercise(query: str) -> dict: