add_prompt
Add new prompts to Promptopia MCP by specifying name, content with variables, and optional description for system integration.
Instructions
Adds a new prompt to the system (single content format)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the prompt | |
| content | Yes | Content of the prompt with variables in {{variable}} format | |
| description | No | Description of the prompt |
Implementation Reference
- src/handlers/tools.handler.ts:206-215 (handler)Executes the 'add_prompt' tool by destructuring arguments, calling promptsService.addPrompt, and returning the result as MCP content.case 'add_prompt': { const { name, content, description } = args const result = await this.promptsService.addPrompt({ name, content, description }) return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] } }
- src/handlers/tools.handler.ts:15-36 (registration)Registers the 'add_prompt' MCP tool with its name, description, and input schema in the listTools method.{ name: 'add_prompt', description: 'Adds a new prompt to the system (single content format)', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the prompt' }, content: { type: 'string', description: 'Content of the prompt with variables in {{variable}} format' }, description: { type: 'string', description: 'Description of the prompt' } }, required: ['name', 'content'] } },
- src/types/index.ts:49-53 (schema)Defines the TypeScript interface AddPromptParams matching the tool's input schema for type safety.export interface AddPromptParams { name: string content: string description?: string }
- Core implementation of adding a prompt: validates params, generates ID and variables, creates SingleContentPrompt, and persists to filesystem.async addPrompt(params: AddPromptParams): Promise<Prompt> { if (!params.name || !params.name.trim()) { throw new ValidationError('Prompt name is required') } if (!params.content || !params.content.trim()) { throw new ValidationError('Prompt content is required') } const id = `prompt-${uuidv4().slice(0, 8)}` const variables = this.extractVariables(params.content) const now = new Date().toISOString() const prompt: SingleContentPrompt = { id, name: params.name.trim(), content: params.content, description: params.description?.trim() || '', variables, createdAt: now, updatedAt: now } try { await this.fileSystemService.writeJSONFile( path.join(this.promptsDir, `${id}.json`), prompt ) return prompt } catch (error) { console.error('Failed to save prompt:', error) throw error } }