0Pricing
MCP Academy · レッスン

プロンプトに引数を追加する

プロンプトを実行する前に、ユーザーが値を入力できるようにします。

「プロンプトに引数を追加する」はCoddyKit上の無料MCP Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMCP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MCP Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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. ✅

よくある質問

「プロンプトに引数を追加する」レッスンは無料ですか?

はい。「プロンプトに引数を追加する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MCP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MCP Academyコースには全4レッスンが含まれています。

「プロンプトに引数を追加する」で何を学びますか?

プロンプトを実行する前に、ユーザーが値を入力できるようにします。 ブラウザで直接実行するハンズオンコードでMCP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

MCP Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのMCP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「プロンプトに引数を追加する」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このMCP Academyレッスンでコードを書いて実行できますか?

はい。すべてのMCP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 最初のプロンプトを登録する
  2. プロンプトに引数を追加する
  3. テキストだけでなくメッセージを返す
  4. コードレビュー用プロンプトテンプレート
← MCP Academyに戻る