add_multi_message_prompt
Create role-based multi-message prompts with structured inputs like text or image content for interactive dialogues in Promptopia MCP.
Instructions
Adds a new multi-message prompt with role-based messages
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | Description of the prompt | |
| messages | Yes | Array of messages with roles | |
| name | Yes | Name of the prompt |
Implementation Reference
- src/services/prompts.service.ts:96-132 (handler)Core implementation of the addMultiMessagePrompt tool: validates parameters, generates unique ID, extracts variables from messages, constructs MultiMessagePrompt object, persists to JSON file via FileSystemService, and returns the created prompt.async addMultiMessagePrompt(params: AddMultiMessagePromptParams): Promise<MultiMessagePrompt> { if (!params.name || !params.name.trim()) { throw new ValidationError('Prompt name is required') } if (!params.messages || !Array.isArray(params.messages) || params.messages.length === 0) { throw new ValidationError('At least one message is required') } if (!PromptValidationUtils.validateMessages(params.messages)) { throw new ValidationError('Invalid message structure') } const id = `prompt-${uuidv4().slice(0, 8)}` const variables = this.extractVariablesFromMessages(params.messages) const prompt: MultiMessagePrompt = { id, name: params.name.trim(), description: params.description?.trim() || '', variables, createdAt: new Date().toISOString(), version: '2.0', messages: params.messages } try { await this.fileSystemService.writeJSONFile( path.join(this.promptsDir, `${id}.json`), prompt ) return prompt } catch (error) { console.error('Failed to save multi-message prompt:', error) throw error } }
- src/handlers/tools.handler.ts:273-286 (handler)MCP tool dispatch handler in callTool method: extracts arguments, calls PromptsService.addMultiMessagePrompt, formats result as MCP content response (JSON stringified).case 'add_multi_message_prompt': { const { name, description, messages } = args const result = await this.promptsService.addMultiMessagePrompt({ name, description, messages }) return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] } }
- src/handlers/tools.handler.ts:147-198 (registration)Tool registration in listTools(): defines name, description, and detailed inputSchema matching AddMultiMessagePromptParams.{ name: 'add_multi_message_prompt', description: 'Adds a new multi-message prompt with role-based messages', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the prompt' }, description: { type: 'string', description: 'Description of the prompt' }, messages: { type: 'array', description: 'Array of messages with roles', items: { type: 'object', properties: { role: { type: 'string', enum: ['user', 'assistant'], description: 'Role of the message sender' }, content: { type: 'object', properties: { type: { type: 'string', enum: ['text', 'image'], description: 'Type of content' }, text: { type: 'string', description: 'Text content (required for text type)' }, image: { type: 'string', description: 'Image data (required for image type)' } }, required: ['type'] } }, required: ['role', 'content'] } } }, required: ['name', 'messages'] } }
- src/types/index.ts:56-60 (schema)TypeScript interface defining input parameters for addMultiMessagePrompt, used by PromptsService and matching the tool's inputSchema.export interface AddMultiMessagePromptParams { name: string description?: string messages: PromptMessage[] }