0Pricing
MCP Academy · Lección

Añadir argumentos a un prompt

Permita que los usuarios completen los campos antes de ejecutar el prompt.

Añadir argumentos a un prompt es una lección gratuita de MCP Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de MCP Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de MCP Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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

Preguntas frecuentes

¿La lección «Añadir argumentos a un prompt» es gratis?

Sí — el texto completo de «Añadir argumentos a un prompt» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de MCP Academy, actualiza a CoddyKit PRO. El curso de MCP Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Añadir argumentos a un prompt»?

Permita que los usuarios completen los campos antes de ejecutar el prompt. Practicas MCP Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar MCP Academy?

No se requiere experiencia previa. MCP Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.

¿Cuánto tiempo toma la lección «Añadir argumentos a un prompt»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de MCP Academy?

Sí. Cada lección de MCP Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Registrar su primer prompt
  2. Añadir argumentos a un prompt
  3. Devolver mensajes, no solo texto
  4. Una plantilla de prompt para revisar código
← Volver a MCP Academy