Register Your First Prompt
Decorate a function to publish a prompt.
Register Your First Prompt is a free MCP Academy lesson on CoddyKit — lesson 1 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.
Your First Prompt
Time to publish a prompt: a reusable, user-triggered template that starts a task with well-crafted wording every time. 💬
The Decorator
You turn a plain Python function into a prompt with the @mcp.prompt() decorator, just like you marked tools with @mcp.tool().
@mcp.prompt()
def greet() -> str:
return "Say hello warmly."Name Comes from the Function
By default the prompt's name is the function name. Clients show that name in a slash menu, so make it short and clear.
The Return Value
The simplest prompt returns a string. That text becomes the opening user message handed to the model when someone picks the prompt.
Add a Description
The function's docstring becomes the prompt description. It tells the user what this prompt is for before they trigger it.
@mcp.prompt()
def greet() -> str:
"""Start a friendly greeting."""
return "Say hello warmly."User-Triggered, Not Automatic
Unlike tools, a prompt only runs when the user explicitly chooses it. The model never invokes a prompt on its own.
It Lives on the Server
Your prompt is registered on the same FastMCP server instance that holds your tools and resources. One server, three primitive kinds.
mcp = FastMCP("my-server")
@mcp.prompt()
def greet() -> str:
return "Say hello warmly."Clients Can List It
Once registered, clients call prompts/list to discover it. That is how a host fills its slash-command or template menu.
Pick It, Get the Message
When the user selects your prompt, the host fetches it and seeds the chat with your returned text. They start from a polished opener.
Keep the Text Focused
A good prompt body gives the model clear instructions, not a wall of options. State the goal and the tone, then stop.
Why Bother
A registered prompt saves everyone from retyping the same request and keeps phrasing consistent across a whole team. ✨
Quick Check
Let's confirm how prompts get registered.
Recap: First Prompt
Nice work! The @mcp.prompt() decorator publishes a function as a user-triggered template, with its name and docstring shown to users. ✅
Frequently asked questions
Is the “Register Your First Prompt” lesson free?
Yes — the full text of “Register Your First 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 “Register Your First Prompt”?
Decorate a function to publish a prompt. 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 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Register Your First 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