Skip to main content

Dynamic Arguments — Prompts

← Back to Dashboard
1. Prompt Templates2. Dynamic Arguments3. Context Assembly

Dynamic Arguments

📚 Prompts⏱ 8 min⭐ 90 XP⌨ Hands-on lab

Parametrizing Context & User Interaction Forms

MCP Prompts achieve their full potential when parameterized with strongly typed arguments. Rather than requiring users to manually paste boilerplate parameters or system rules into the chat box, an MCP server exposes argument schemas via prompts/list.

Dynamic Argument Handshake
  1. Schema Publication: The server registers a prompt using Zod validation schemas with descriptive hints.
  2. Client Form Generation: The host application (e.g., Claude Desktop, Cursor) inspects the prompt arguments and renders a native modal dialog asking the human to fill in the required fields.
  3. Message Assembly: The server executes the callback with sanitized, validated inputs, returning a synthesized array of conversation turns.
import { z } from "zod";
import { McpServer } from "@modelcontextprotocol/server";

const server = new McpServer({ name: "analytics-prompts", version: "1.0.0" });

server.registerPrompt(
  "generate_quarterly_audit",
  {
    title: "Quarterly Audit Report",
    description: "Generate a quarterly audit template for a department",
    argsSchema: {
      department: z.enum(["Engineering", "Security", "Finance"]).describe("Target business department"),
      fiscalYear: z.string().describe("Four-digit fiscal year, e.g. 2026"),
      includeRemediation: z.enum(["true", "false"]).optional().describe("Include automated remediation playbook")
    }
  },
  async ({ department, fiscalYear, includeRemediation }) => {
    return {
      description: "Executive audit report for " + department + " (FY" + fiscalYear + ")",
      messages: [{
        role: "user",
        content: {
          type: "text",
          text: "Generate a rigorous enterprise audit for " + department + " during FY" + fiscalYear + ". Include remediation plans: " + includeRemediation + "."
        }
      }]
    };
  }
);
⌨ HANDS-ON LABRender Prompts with Dynamic Arguments
⭐ +150 XP

Fetch an instantiated prompt template by passing dynamic runtime arguments.

1Call prompts/get passing argument language=python.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 1 — type "hint" if stuck
🧪 Knowledge Check
Press 1-4 to select1 of 3
How do you enforce strongly-typed arguments for a Prompt?
By using Zod schema definitions.
By using TypeScript interfaces.
It is not possible; Prompts only take raw text.
By throwing errors at runtime.