Add Arguments to a Prompt
Let users fill in slots before the prompt runs.
Add Arguments to a Prompt is a free MCP Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MCP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Fillable Slots
A static prompt is fine, but real power comes from arguments: blanks the user fills in before the prompt runs. 🧩
Parameters Become Arguments
Each function parameter becomes a prompt argument. The host shows an input field for every one and collects the values.
@mcp.prompt()
def summarize(text: str) -> str:
return f"Summarize this:\n{text}"Slot Values into the Text
Inside the function you weave the arguments into the returned message, usually with an f-string, so the final text is personalized.
Type Hints Describe Inputs
A type hint like str or int tells the client what kind of value to expect, so it can guide and validate the user's entry.
@mcp.prompt()
def plan(topic: str, days: int) -> str:
return f"Plan {days} days about {topic}."Required by Default
An argument with no default is required: the user must supply it before the prompt can be invoked. No value, no run.
Optional with Defaults
Give a parameter a default value to make it optional. If the user skips it, your default fills in automatically.
@mcp.prompt()
def summarize(text: str, style: str = "brief") -> str:
return f"{style} summary:\n{text}"Document Each Field
Describing arguments well helps the user enter the right thing. Clear field names and a tidy docstring make the form obvious.
Validation at the Edge
The host collects and passes argument values to your function. You can still check them and raise a clear error if something is off.
More Slots, More Reuse
Several arguments turn one prompt into a flexible template. The same review prompt can target bugs, style, or security on demand.
@mcp.prompt()
def review(code: str, focus: str = "bugs") -> str:
return f"Review this for {focus}:\n{code}"Keep the Form Short
Ask only for what you truly need. Too many arguments turns a quick template into a tedious form nobody wants to fill.
From Generic to Specific
Arguments let one prompt serve many situations. You write the wording once and the user steers it with a few inputs. 🎯
Quick Check
Let's check how an argument becomes optional.
Recap: Prompt Arguments
You've got it! Function parameters become fillable arguments, type hints describe them, and defaults make them optional. ✅
Frequently asked questions
Is the “Add Arguments to a Prompt” lesson free?
Yes — the full text of “Add Arguments to a Prompt” is free to read here on the web, and the MCP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MCP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Add Arguments to a Prompt”?
Let users fill in slots before the prompt runs. You practise MCP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start MCP Academy?
No prior experience is required. MCP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Add Arguments to a Prompt” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this MCP Academy lesson?
Yes. Every MCP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Register Your First Prompt
- Add Arguments to a Prompt
- Return Messages, Not Just Text
- A Code-Review Prompt Template