This commit is contained in:
Isaac Johnson 2026-01-28 19:21:35 -06:00
commit 9a19b884ff
6 changed files with 464 additions and 0 deletions

191
.gitignore vendored Normal file
View File

@ -0,0 +1,191 @@
# Created by https://www.toptal.com/developers/gitignore/api/python,linux
# Edit at https://www.toptal.com/developers/gitignore?templates=python,linux
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml
# ruff
.ruff_cache/
# LSP config files
pyrightconfig.json
# End of https://www.toptal.com/developers/gitignore/api/python,linux

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM python:3.11-slim
WORKDIR /app
# Set environment variables
ENV PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "workout_server.py"]

36
README.md Normal file
View File

@ -0,0 +1,36 @@
# Workout Maker MCP Server
An MCP server for creating workout content, sessions, and plans.
## Features
- **Create Exercise Page**: Generates a detailed exercise page in Markdown with step-by-step instructions and optimized NanoBanana/Gemini image prompts.
- **Create Session**: Groups exercises into a balanced daily workout (Push, Pull, Legs, Core).
- **Create Workout Plan**: Generates a multi-day schedule tailored to goals and age, ensuring balanced movement patterns.
## Installation
```bash
pip install -r requirements.txt
```
## Usage
Run the server:
```bash
python workout_server.py
```
### Tools
1. `create_exercise_page(name, type, steps, visual_description)`
2. `create_session(name, difficulty, duration_minutes)`
3. `create_workout_plan(goal, age_range, length_days)`
## Integration with Gemini/NanoBanana
The `create_exercise_page` tool outputs a Markdown block containing a command like:
`/image prompt="..."`
This allows you to easily generate consistent, high-quality illustrations for your workout content using the Gemini CLI extensions.

20
gemini-extension.json Normal file
View File

@ -0,0 +1,20 @@
{
"id": "workout-maker",
"name": "WorkoutMaker",
"description": "Create workout plans, sessions, and exercise pages with visual prompts.",
"version": "1.0.1",
"mcpServers": [
{
"id": "workout-maker",
"name": "Workout Maker Server",
"transportType": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"idjohnson/workoutmcp:latest"
]
}
]
}

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
mcp

203
workout_server.py Normal file
View File

@ -0,0 +1,203 @@
from typing import List, Optional
from mcp.server.fastmcp import FastMCP
from pydantic import BaseModel, Field, ConfigDict
import random
# Initialize FastMCP server
mcp = FastMCP("workout_mcp")
# --- Data Models ---
class ExerciseType(str):
PUSH = "push"
PULL = "pull"
KNEE_HIP = "knee_hip" # Combined for simplicity or split if needed. Prompt said "knee/hip dominent".
CORE = "core"
OTHER = "other"
class Exercise(BaseModel):
name: str
type: str
steps: List[str]
image_prompt: str
# Sample Database (in-memory)
# In a real app, this might come from a DB or be generated.
EXERCISE_DB = {
"pushup": Exercise(
name="Push Up",
type=ExerciseType.PUSH,
steps=["Start in plank position", "Lower body until chest nearly touches floor", "Push back up"],
image_prompt="A fit character performing a pushup, gym background, side view, correct form"
),
"pullup": Exercise(
name="Pull Up",
type=ExerciseType.PULL,
steps=["Hang from bar", "Pull chin over bar", "Lower down"],
image_prompt="A fit character performing a pullup, gym background, back view, correct form"
),
"squat": Exercise(
name="Bodyweight Squat",
type=ExerciseType.KNEE_HIP,
steps=["Stand feet shoulder width", "Lower hips back and down", "Stand back up"],
image_prompt="A fit character performing a squat, gym background, side view, correct form"
),
"plank": Exercise(
name="Plank",
type=ExerciseType.CORE,
steps=["Forearms on ground", "Body straight", "Hold"],
image_prompt="A fit character holding a plank position, gym background, side view"
),
"lunges": Exercise(
name="Walking Lunges",
type=ExerciseType.KNEE_HIP,
steps=["Step forward with one leg", "Lower hips until both knees are bent at a 90-degree angle", "Push off with your front foot to return to starting position", "Repeat with the other leg"],
image_prompt="A fit character performing lunges, gym background, side view, correct form"
),
"overhead_press": Exercise(
name="Overhead Press",
type=ExerciseType.PUSH,
steps=["Stand with feet shoulder-width apart", "Hold dumbbells at shoulder height", "Press weights overhead until arms are fully extended", "Lower back to starting position"],
image_prompt="A fit character performing an overhead press with dumbbells, gym background, front view, correct form"
),
"dumbbell_row": Exercise(
name="Dumbbell Row",
type=ExerciseType.PULL,
steps=["Place one knee and hand on a bench", "Hold a dumbbell in the other hand", "Pull the weight up towards your hip", "Lower back down"],
image_prompt="A fit character performing a dumbbell row, gym background, side view, correct form"
),
"russian_twist": Exercise(
name="Russian Twist",
type=ExerciseType.CORE,
steps=["Sit on the floor with knees bent", "Lean back slightly", "Twist torso to one side, then the other", "Hold a weight for added resistance if desired"],
image_prompt="A fit character performing russian twists, gym background, front view, correct form"
)
}
# --- Inputs ---
class CreateExerciseInput(BaseModel):
name: str = Field(..., description="Name of the exercise")
type: str = Field(..., description="Type: push, pull, knee_hip, core")
steps: List[str] = Field(..., description="List of step-by-step instructions")
visual_description: str = Field(..., description="Visual description for image generation")
class CreateSessionInput(BaseModel):
name: str = Field(..., description="Name of the session (e.g. 'Morning Blast')")
difficulty: str = Field("beginner", description="beginner, intermediate, advanced")
duration_minutes: int = Field(30, description="Target duration in minutes")
class CreatePlanInput(BaseModel):
goal: str = Field(..., description="Goal: strength, weight_loss, endurance")
age_range: str = Field(..., description="Age range (e.g. '20-30', '50+')")
length_days: int = Field(..., description="Length of plan in days")
# --- Helpers ---
def generate_nanobanana_prompt(description: str, style: str = "photorealistic") -> str:
"""Creates a prompt optimized for NanoBanana/Gemini image generation."""
# Enforcing the requirement: 'consistent characters' and 'simple'
base_prompt = "A consistent character design, athletic wear, clean background. "
return f"{base_prompt} {description}. Style: {style}, high quality."
# --- Tools ---
@mcp.tool()
def create_exercise_page(params: CreateExerciseInput) -> str:
"""Creates a Markdown page for a single exercise with Nanobanana image prompts."""
image_prompt = generate_nanobanana_prompt(params.visual_description)
md = f"# {params.name}\n\n"
md += f"**Type:** {params.type.capitalize()}\n\n"
md += "## Steps\n"
for i, step in enumerate(params.steps, 1):
md += f"{i}. {step}\n"
md += "\n## Visual Reference\n"
md += f"> **NanoBanana Image Prompt:**\n"
md += f"> `/image prompt=\"{image_prompt}\" --count=1`\n\n"
md += "*(Use the above command with your Gemini agent to generate the visual)*\n"
return md
@mcp.tool()
def create_session(params: CreateSessionInput) -> str:
"""Creates a workout session grouping exercises. Ensures variety."""
# Logic: Select one of each type for a balanced session
selected_exercises = []
# Simple selection logic from DB
types_needed = [ExerciseType.PUSH, ExerciseType.PULL, ExerciseType.KNEE_HIP, ExerciseType.CORE]
for t in types_needed:
# Find candidates
candidates = [e for e in EXERCISE_DB.values() if e.type == t]
if candidates:
# Randomly pick one or based on difficulty (mocking logic here)
selected_exercises.append(random.choice(candidates))
md = f"# Workout Session: {params.name}\n\n"
md += f"**Difficulty:** {params.difficulty} | **Duration:** {params.duration_minutes} mins\n\n"
md += "## Warmup\n- 5 mins light cardio\n\n"
md += "## The Circuit\n"
md += "*Perform 3 rounds of the following:*\n\n"
for ex in selected_exercises:
md += f"### {ex.name}\n"
md += f"**Target:** {ex.type.capitalize()}\n"
md += f"- Instructions: {ex.steps[0]}...\n"
md += f"- [View Full Exercise Page via `create_exercise_page`]\n\n"
md += "## Cooldown\n- 5 mins stretching\n"
return md
@mcp.tool()
def create_workout_plan(params: CreatePlanInput) -> str:
"""Creates a multi-day workout plan based on goals."""
md = f"# {params.length_days}-Day Workout Plan: {params.goal.capitalize()}\n"
md += f"**Target Audience:** Age {params.age_range}\n\n"
# Logic to adjust intensity based on age/goal
rest_frequency = 3 # Default: rest every 3rd day
if "50+" in params.age_range or "beginner" in params.goal:
rest_frequency = 2
for day in range(1, params.length_days + 1):
md += f"## Day {day}\n"
if day % rest_frequency == 0:
md += "**Rest & Recovery**\n- Light walking or stretching.\n\n"
else:
session_name = f"Day {day} {params.goal} Focus"
md += f"**Session:** {session_name}\n\n"
# Select exercises for this day to meet requirements
daily_exercises = []
types_needed = [ExerciseType.PUSH, ExerciseType.PULL, ExerciseType.KNEE_HIP, ExerciseType.CORE]
for t in types_needed:
candidates = [e for e in EXERCISE_DB.values() if e.type == t]
if candidates:
daily_exercises.append(random.choice(candidates))
md += "| Type | Exercise | Sets/Reps |\n"
md += "|---|---|---|\n"
for ex in daily_exercises:
# Adjust reps based on goal
reps = "3x10"
if params.goal == "strength": reps = "5x5"
elif params.goal == "endurance": reps = "3x15+"
md += f"| {ex.type.capitalize()} | {ex.name} | {reps} |\n"
md += "\n"
return md
if __name__ == "__main__":
mcp.run()