Skip to main content
Glama
lumile

Promptopia MCP

by lumile

update_prompt

Modify existing prompts by updating their name, description, or messages, converting single content to multi-message format when needed. Ensures prompt content remains accurate and adaptable.

Instructions

Updates an existing prompt (supports both single content and multi-message formats)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNoNew description for the prompt
idYesID of the prompt to update
messagesNoNew messages (converts single content to multi-message format)
nameNoNew name for the prompt

Implementation Reference

  • Core implementation of the update_prompt tool logic: validates parameters, retrieves existing prompt, merges updates, handles conversion between single-content and multi-message formats, extracts variables, and persists changes to the filesystem.
    async updatePrompt(params: UpdatePromptParams): Promise<UpdatePromptResult> { if (!params.id || !params.id.trim()) { throw new ValidationError('Prompt ID is required') } // At least one field to update must be provided if (!params.name && !params.description && !params.messages) { throw new ValidationError('At least one field to update must be provided') } try { // First get the existing prompt const existingPrompt = await this.getPrompt(params.id) let updatedPrompt: Prompt if (isMultiMessagePrompt(existingPrompt)) { // Update existing multi-message prompt updatedPrompt = { ...existingPrompt, ...(params.name && { name: params.name.trim() }), ...(params.description !== undefined && { description: params.description.trim() || '' }), ...(params.messages && { messages: params.messages, variables: this.extractVariablesFromMessages(params.messages) }), updatedAt: new Date().toISOString() } } else { // Convert single content prompt to multi-message if messages are provided if (params.messages) { updatedPrompt = { id: existingPrompt.id, name: params.name?.trim() || existingPrompt.name, description: params.description !== undefined ? (params.description.trim() || '') : existingPrompt.description, variables: this.extractVariablesFromMessages(params.messages), createdAt: existingPrompt.createdAt, updatedAt: new Date().toISOString(), version: '2.0', messages: params.messages } } else { // Keep as single content format updatedPrompt = { ...existingPrompt, ...(params.name && { name: params.name.trim() }), ...(params.description !== undefined && { description: params.description.trim() || '' }), updatedAt: new Date().toISOString() } } } // Save the updated prompt const filePath = path.join(this.promptsDir, `${params.id}.json`) await this.fileSystemService.writeJSONFile(filePath, updatedPrompt) return { success: true, message: `Prompt ${params.id} updated successfully`, prompt: updatedPrompt } } catch (error) { if (error instanceof Error && error.message.includes('not found')) { throw new NotFoundError(`Prompt not found: ${params.id}`) } console.error('Failed to update prompt:', error) throw error } }
  • MCP tool handler for 'update_prompt': extracts arguments, calls PromptsService.updatePrompt, and returns JSON-formatted result as MCP content.
    case 'update_prompt': { const { id, name, description, messages } = args const result = await this.promptsService.updatePrompt({ id, name, description, messages }) return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] } }
  • Registers the 'update_prompt' tool in listTools() with detailed inputSchema matching UpdatePromptParams.
    { name: 'update_prompt', description: 'Updates an existing prompt (supports both single content and multi-message formats)', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'ID of the prompt to update' }, name: { type: 'string', description: 'New name for the prompt' }, description: { type: 'string', description: 'New description for the prompt' }, messages: { type: 'array', description: 'New messages (converts single content to multi-message format)', 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: ['id'] } },
  • TypeScript interface defining input parameters for updatePrompt.
    export interface UpdatePromptParams { id: string name?: string description?: string messages?: PromptMessage[] }
  • TypeScript interface defining output result for updatePrompt.
    export interface UpdatePromptResult { success: boolean message: string prompt: Prompt }

Other Tools

Related Tools

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