0Pricing
MCP Academy · Aula

Adicionar argumentos a um prompt

Permita que os usuários preencham os campos antes da execução do prompt.

Adicionar argumentos a um prompt é uma aula grátis de MCP Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de MCP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de MCP Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em 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. ✅

Perguntas Frequentes

A aula “Adicionar argumentos a um prompt” é grátis?

Sim — o texto completo de “Adicionar argumentos a um prompt” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de MCP Academy, atualize para CoddyKit PRO. O curso de MCP Academy inclui 4 aulas no total.

O que vou aprender em “Adicionar argumentos a um prompt”?

Permita que os usuários preencham os campos antes da execução do prompt. Você pratica MCP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar MCP Academy?

Nenhuma experiência prévia é necessária. MCP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Adicionar argumentos a um prompt”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de MCP Academy?

Sim. Cada aula de MCP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Registrar seu primeiro prompt
  2. Adicionar argumentos a um prompt
  3. Retornar mensagens, não apenas texto
  4. Um modelo de prompt para revisão de código
← Voltar para MCP Academy