Skip to main content
Glama
lumile

Promptopia MCP

by lumile

add_multi_message_prompt

Create structured prompts with role-based messages for AI interactions. Define user and assistant messages with text or image content to build multi-turn conversation templates.

Instructions

Adds a new multi-message prompt with role-based messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the prompt
descriptionNoDescription of the prompt
messagesYesArray of messages with roles

Implementation Reference

  • Handler logic for the 'add_multi_message_prompt' tool: extracts arguments from input, calls PromptsService.addMultiMessagePrompt, and returns JSON stringified result as text content.
    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)
        }]
      }
    }
  • Tool registration in listTools(): defines name, description, and detailed inputSchema for 'add_multi_message_prompt'.
    {
      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']
      }
    }
  • TypeScript interface defining the input parameters for addMultiMessagePrompt: name (required), optional description, and array of messages.
    export interface AddMultiMessagePromptParams {
      name: string
      description?: string
      messages: PromptMessage[]
    }
  • Core service method: validates parameters, generates unique ID, extracts variables from messages, constructs MultiMessagePrompt object, persists to JSON file in prompts directory, 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
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lumile/promptopia-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server