0Pricing
MCP Academy · درس

إضافة وسيطات إلى تعليمة

اسمحوا للمستخدمين بملء القيم قبل تشغيل التعليمة.

إضافة وسيطات إلى تعليمة درس مجاني في MCP Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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/7) وفتح باقي دورة MCP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة MCP Academy 4 دروس في المجموع.

ماذا ستتعلم في «إضافة وسيطات إلى تعليمة»؟

اسمحوا للمستخدمين بملء القيم قبل تشغيل التعليمة. تتمرن على MCP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ MCP Academy؟

لا تُشترط خبرة سابقة. MCP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «إضافة وسيطات إلى تعليمة»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس MCP Academy هذا؟

نعم. كل درس في MCP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. تسجيل أول تعليمة
  2. إضافة وسيطات إلى تعليمة
  3. إرجاع رسائل لا نص فقط
  4. قالب تعليمة لمراجعة التعليمات البرمجية
← العودة إلى MCP Academy