alepha@docs:~/docs/reference/primitives$
cat $prompt.md
1 min read

#$prompt

#Import

typescript
1import { $prompt } from "alepha/mcp";

#Overview

Creates an MCP prompt primitive for defining reusable prompt templates.

Prompts allow you to define templated messages that can be filled in with arguments at runtime. They're useful for creating consistent interaction patterns.

#Options

Option Type Required Description
name string No The name of the prompt
description string No Description of what this prompt does
args T No TypeBox schema defining the prompt arguments
handler Object Yes Handler function that generates the prompt messages

#Examples

ts
 1class Prompts { 2  greeting = $prompt({ 3    description: "Generate a personalized greeting", 4    args: t.object({ 5      name: t.text({ description: "Name of the person to greet" }), 6      style: t.optional(t.enum(["formal", "casual"])), 7    }), 8    handler: async ({ args }) => [ 9      {10        role: "user",11        content: args.style === "formal"12          ? `Please greet ${args.name} in a formal manner.`13          : `Say hi to ${args.name}!`,14      },15    ],16  });17 18  codeReview = $prompt({19    description: "Request a code review",20    args: t.object({21      code: t.text({ description: "The code to review" }),22      language: t.text({ description: "Programming language" }),23    }),24    handler: async ({ args }) => [25      {26        role: "user",27        content: `Please review this ${args.language} code:

${args.code}`,28      },29    ],30  });31}