prompt-design
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate xmcp Prompt
创建xmcp提示词
You are helping the user create a new xmcp prompt. Follow this interactive workflow.
你正在协助用户创建新的xmcp提示词,请遵循以下交互式工作流程。
Step 1: Gather Information
步骤1:收集信息
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:
- Simple - Static prompt text without parameters
- Parameterized - Prompt with user-provided parameters (most common)
- Multi-content - Returns multiple content blocks (text, images, etc.)
-
Parameters (if parameterized): What inputs should the prompt accept?
- Parameter name
- Type (string, number, enum)
- Description
- Whether it's optional
- Any validation or default values
-
Role: What role should the prompt assume?
- user - Prompt from user perspective (most common)
- assistant - Prompt as assistant response template
-
Use case: What is the prompt designed for?
- Code review
- Documentation generation
- Data analysis
- Content creation
- Other specific task
在生成任何代码之前,使用AskUserQuestion向用户询问以下问题:
-
提示词名称(若未提供):提示词应命名为什么?(使用短横线分隔式命名kebab-case)
-
提示词类型:询问用户需要哪种类型的提示词:
- 简单型 - 无参数的静态提示词文本
- 参数化型 - 包含用户提供参数的提示词(最常见)
- 多内容型 - 返回多个内容块(文本、图片等)
-
参数(若为参数化型):提示词应接受哪些输入?
- 参数名称
- 类型(字符串、数字、枚举)
- 描述
- 是否为可选参数
- 任何验证规则或默认值
-
角色:提示词应扮演什么角色?
- user - 从用户视角出发的提示词(最常见)
- assistant - 作为助手回复模板的提示词
-
使用场景:该提示词的设计用途是什么?
- 代码评审
- 文档生成
- 数据分析
- 内容创作
- 其他特定任务
Step 2: Generate the Prompt
步骤2:生成提示词
Create the prompt file in :
src/prompts/在目录下创建提示词文件:
src/prompts/File Location
文件路径
src/prompts/{prompt-name}.tssrc/prompts/{prompt-name}.tsPrompt Structure Reference
提示词结构参考
Every xmcp prompt has three main exports:
typescript
// 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?) { /* ... */ }每个xmcp提示词包含三个主要导出项:
typescript
// 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?) { /* ... */ }Quick Reference
快速参考
Essential Imports
必要导入
typescript
import { type PromptMetadata } from "xmcp";
// For parameterized prompts
import { z } from "zod";
import { type InferSchema, type PromptMetadata } from "xmcp";typescript
import { type PromptMetadata } from "xmcp";
// For parameterized prompts
import { z } from "zod";
import { type InferSchema, type PromptMetadata } from "xmcp";Metadata Fields
元数据字段
| Field | Type | Required | Description |
|---|---|---|---|
| string | No* | Unique prompt identifier |
| string | No | Human-readable title |
| string | No | What this prompt does |
| string | No | "user" or "assistant" (default: user) |
*When metadata is omitted, xmcp uses the filename as the prompt name.
| 字段 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| string | 否* | 唯一的提示词标识符 |
| string | 否 | 易读的标题 |
| string | 否 | 该提示词的功能说明 |
| string | 否 | "user"或"assistant"(默认值:user) |
*当省略元数据时,xmcp会将文件名作为提示词名称。
Handler Return Types
处理器返回类型
| Return Type | Use Case |
|---|---|
| Simple text prompt |
| Explicit text content |
| Image content |
| Multiple content blocks |
| 返回类型 | 应用场景 |
|---|---|
| 纯文本提示词 |
| 显式文本内容 |
| 图片内容 |
| 多个内容块 |
Use Cases for Server-Exposed Prompts
服务器端可访问提示词的应用场景
MCP prompts are useful for:
- Standardized workflows - Consistent code review, documentation patterns
- Complex templates - Multi-step analysis prompts with structure
- Domain expertise - Specialized prompts for specific domains
- Reusable patterns - Common tasks that benefit from parameterization
- Client integration - Prompts that MCP clients can discover and use
MCP提示词适用于:
- 标准化工作流程 - 统一的代码评审、文档生成模式
- 复杂模板 - 具有结构化的多步骤分析提示词
- 领域专业能力 - 针对特定领域的专用提示词
- 可复用模式 - 可从参数化中获益的常见任务
- 客户端集成 - MCP客户端可发现并使用的提示词
Detailed Templates
详细模板
For complete code templates including:
- Simple prompt patterns
- Parameterized prompts with Zod schemas
- Multi-role conversation prompts
- Autocompletion support
- Code review and documentation examples
Read:
references/patterns.md完整的代码模板包括:
- 简单提示词模式
- 结合Zod schema的参数化提示词
- 多角色对话提示词
- 自动补全支持
- 代码评审和文档生成示例
查看:
references/patterns.mdChecklist After Generation
生成后的检查清单
- File created in
src/prompts/{prompt-name}.ts - If using metadata, ensure it has ,
name, andtitledescription - Schema uses for all parameters (if parameterized)
.describe() - Handler returns appropriate content format
- Role is set appropriately for the use case
Suggest running to verify the prompt compiles correctly.
pnpm build- 文件已创建在路径下
src/prompts/{prompt-name}.ts - 若使用元数据,确保包含、
name和title字段description - 若为参数化提示词,Schema中所有参数均使用添加描述
.describe() - 处理器返回了合适的内容格式
- 已根据使用场景正确设置角色
建议运行来验证提示词是否能正确编译。
pnpm build