Design MCP prompts to expose reusable prompt templates. Use when creating parameterized prompts in xmcp.
You are helping the user create a new xmcp prompt. Follow this interactive workflow.
Before generating any code, ask the user these questions using AskUserQuestion:
Prompt name (if not provided): What should the prompt be named? (Use kebab-case)
Prompt type: Ask which type of prompt they need:
Parameters (if parameterized): What inputs should the prompt accept?
Role: What role should the prompt assume?
Use case: What is the prompt designed for?
Create the prompt file in src/prompts/:
src/prompts/{prompt-name}.ts
Every xmcp prompt has three main exports:
// 1. Schema (optional) - Define parameters with Zod
export const schema = { /* ... */ };
// 2. Metadata (optional) - Prompt configuration
export const metadata: PromptMetadata = { /* ... */ };
// 3. Handler (required) - Default export function
export default function handler(params?) { /* ... */ }
import { type PromptMetadata } from "xmcp";
// For parameterized prompts
import { z } from "zod";
import { type InferSchema, type PromptMetadata } from "xmcp";
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | No* | Unique prompt identifier |
title |
string | No | Human-readable title |
description |
string | No | What this prompt does |
role |
string | No | "user" or "assistant" (default: user) |
*When metadata is omitted, xmcp uses the filename as the prompt name.
| Return Type | Use Case |
|---|---|
string |
Simple text prompt |
{ type: "text", text: string } |
Explicit text content |
{ type: "image", data: base64, mimeType: string } |
Image content |
Array<Content> |
Multiple content blocks |
MCP prompts are useful for:
For complete code templates including:
Read: references/patterns.md
src/prompts/{prompt-name}.tsname, title, and description.describe() for all parameters (if parameterized)Suggest running pnpm build to verify the prompt compiles correctly.