Whatever message this page gives is out now! Go check it out!

Arguments and Templates

Last update:
May 18, 2026
Prompts become truly reusable when they accept arguments and use them as template placeholders inside the prompt text.

Overview

Prompts become truly reusable when they accept arguments and use them as template placeholders inside the prompt text.

Arguments: Named Inputs to Prompts

Each argument has:
  • A name – used as a placeholder in the template (e.g., {{document_text}}).
  • A description – explains what you should pass.
  • A required flag – whether you must provide it for the prompt to work.
Users should expect:
  • A clear list of arguments when viewing the prompt definition.
  • Meaningful argument names (no arg1, arg2 where possible).
  • Client-side validation if required arguments are missing.
Example: Arguments for a “Code Explanation” Prompt

"arguments": [
  {
    "name": "code",
    "description": "The code snippet to explain.",
    "required": true
  },
  {
    "name": "language",
    "description": "Programming language of the code (e.g., 'JavaScript').",
    "required": false
  },
  {
    "name": "level",
    "description": "Target skill level (e.g., 'beginner', 'advanced').",
    "required": false
  }
]
      

Templates: Placing Arguments into Prompt Text

Templates are plain text (or structured messages) containing placeholders such as {{code}}, {{language}}, or {{level}}. When you call the prompt:
  • The MCP server replaces these placeholders with the values you pass.
  • Missing optional arguments may be:
    • Left blank, or
    • Replaced with default wording, depending on the server’s template logic.
Example template text:

You are a helpful programming tutor.

Explain the following {{language}} code to a {{level}} programmer:

{{code}}

Provide a step-by-step explanation and examples when appropriate.
      
With arguments:

{
  "code": "for (let i = 0; i < items.length; i++) { console.log(items[i]); }",
  "language": "JavaScript",
  "level": "beginner"
}
      
The rendered prompt the model sees will be fully concrete—no curly braces, only your code and values.

Best Practices for Users of Argumented Prompts

When you use prompts:
  • Always provide all required arguments. Your MCP client should warn you if something is missing.
  • Use the descriptions as guidance for what to pass (full text vs ID vs short label).
  • For optional arguments:
    • Leave them out when they don’t apply (the template should handle it), or
    • Provide sensible defaults (“general audience”, “neutral tone”) in your calling code.
When you define prompts (if you manage the server):
  • Keep argument names stable; renaming them is effectively a breaking change for anyone calling the prompt.
  • Avoid overloading a single argument with multiple responsibilities (e.g., config that holds unrelated settings).
  • Make templates clear about where arguments appear, so outputs are predictable.

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page