delete_prompt
Remove unwanted prompts by specifying their unique ID using this tool, ensuring clean and organized prompt management on Promptopia MCP.
Instructions
Deletes a prompt by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the prompt to delete |
Implementation Reference
- src/handlers/tools.handler.ts:249-258 (handler)The handler logic for the 'delete_prompt' tool. Extracts the 'id' from input arguments, delegates deletion to PromptsService, and returns the result formatted as MCP tool response content.case 'delete_prompt': { const { id } = args const result = await this.promptsService.deletePrompt(id) return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] } }
- src/types/index.ts:79-82 (schema)Type definition for the output of deletePrompt operation, used by the service and handler.export interface DeletePromptResult { success: boolean message: string }
- src/handlers/tools.handler.ts:115-128 (registration)Registers the 'delete_prompt' tool in the listTools() method, including its description and input schema requiring a string 'id'.{ name: 'delete_prompt', description: 'Deletes a prompt by its ID', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'ID of the prompt to delete' } }, required: ['id'] } },
- Core implementation of prompt deletion in PromptsService: validates ID, checks existence, deletes the JSON file from filesystem, handles errors, and returns success result.async deletePrompt(id: string): Promise<DeletePromptResult> { if (!id || !id.trim()) { throw new ValidationError('Prompt ID is required') } try { // First check if the prompt exists await this.getPrompt(id) // If it exists, delete it const filePath = path.join(this.promptsDir, `${id}.json`) await this.fileSystemService.deleteFile(filePath) return { success: true, message: `Prompt ${id} deleted successfully` } } catch (error) { if (error instanceof Error && error.message.includes('not found')) { throw new NotFoundError(`Prompt not found: ${id}`) } console.error('Failed to delete prompt:', error) throw error } }