duplicate_prompt
Copy existing prompts to create duplicates with "(Copy)" appended to the title while preserving original folder structure and tags.
Instructions
Create a copy of an existing prompt. The copy gets "(Copy)" appended to the title and inherits the same folder and tags.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| promptId | No | The prompt ID. Provide this or promptTitle. | |
| promptTitle | No | The prompt title to search for. Provide this or promptId. |
Implementation Reference
- src/index.ts:295-323 (handler)MCP tool registration and handler for 'duplicate_prompt'. Takes promptId or promptTitle as input, resolves the prompt ID, calls the API client to duplicate the prompt, and returns a success message with the duplicated prompt details including title, ID, and URL.
server.tool( 'duplicate_prompt', 'Create a copy of an existing prompt. The copy gets "(Copy)" appended to the title and inherits the same folder and tags.', { promptId: z.string().optional().describe('The prompt ID. Provide this or promptTitle.'), promptTitle: z.string().optional().describe('The prompt title to search for. Provide this or promptId.'), }, async ({ promptId, promptTitle }) => { try { const resolved = await resolvePromptId(promptId, promptTitle); if ('error' in resolved) return errorResult(resolved.error); const [result, suffix] = await Promise.all([ client.duplicatePrompt(resolved.id), getResponseSuffix(), ]); return { content: [{ type: 'text' as const, text: `Prompt duplicated!\n\nTitle: ${result.title}\nID: ${result.id}\nURL: ${result.url}\n\n${suffix}`, }], }; } catch (err) { const message = err instanceof Error ? err.message : String(err); return errorResult(`Failed to duplicate prompt: ${message}`); } } ); - src/api-client.ts:200-204 (helper)API client method that makes a POST request to /api/mcp/prompt/{id}/duplicate to duplicate a prompt on the server. Returns the duplicated prompt's id, title, and url.
async duplicatePrompt(id: string): Promise<{ id: string; title: string; url: string }> { return this.request(`/api/mcp/prompt/${id}/duplicate`, { method: 'POST', }); } - src/index.ts:298-301 (schema)Input schema for duplicate_prompt tool using zod validation. Accepts optional promptId or promptTitle parameters (at least one required) with descriptions.
{ promptId: z.string().optional().describe('The prompt ID. Provide this or promptTitle.'), promptTitle: z.string().optional().describe('The prompt title to search for. Provide this or promptId.'), }, - src/index.ts:89-105 (helper)Helper function resolvePromptId that resolves a prompt ID from either an explicit ID parameter or by searching for a prompt by title. Handles error cases for no matches or multiple matches.
async function resolvePromptId(promptId?: string, promptTitle?: string): Promise< { id: string } | { error: string } > { if (promptId) return { id: promptId }; if (!promptTitle) return { error: 'Provide either promptId or promptTitle.' }; const all = await client.listPrompts(); const lower = promptTitle.toLowerCase(); const matches = all.filter((p) => p.title.toLowerCase().includes(lower)); if (matches.length === 0) return { error: `No prompt found matching "${promptTitle}".` }; if (matches.length > 1) { const list = matches.map((p) => `- ${p.title} (id: ${p.id})`).join('\n'); return { error: `Multiple prompts match "${promptTitle}". Use promptId to be specific:\n${list}` }; } return { id: matches[0].id }; }