最初のプロンプトを登録する
関数にデコレーターを付けてプロンプトを公開します。
「最初のプロンプトを登録する」はCoddyKit上の無料MCP Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMCP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MCP Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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. ✅
よくある質問
「最初のプロンプトを登録する」レッスンは無料ですか?
はい。「最初のプロンプトを登録する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MCP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MCP Academyコースには全4レッスンが含まれています。
「最初のプロンプトを登録する」で何を学びますか?
関数にデコレーターを付けてプロンプトを公開します。 ブラウザで直接実行するハンズオンコードでMCP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
MCP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMCP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「最初のプロンプトを登録する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMCP Academyレッスンでコードを書いて実行できますか?
はい。すべてのMCP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 最初のプロンプトを登録する
- プロンプトに引数を追加する
- テキストだけでなくメッセージを返す
- コードレビュー用プロンプトテンプレート