list_versions
Retrieve version history for AI prompts, showing saved versions with version numbers, notes, and timestamps to track changes.
Instructions
Get the version history for a prompt. Shows all saved versions with their version numbers, notes, and timestamps.
Input 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:490-520 (handler)Tool registration and handler for 'list_versions' that resolves the prompt ID, calls the API client to fetch versions, formats the output, and returns the version history as text.
server.tool( 'list_versions', 'Get the version history for a prompt. Shows all saved versions with their version numbers, notes, and timestamps.', { 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 [versions, suffix] = await Promise.all([ client.listVersions(resolved.id), getResponseSuffix(), ]); if (versions.length === 0) { return { content: [{ type: 'text' as const, text: `No versions found.\n\n${suffix}` }], }; } const lines = versions.map((v) => `- **v${v.versionNumber}** — ${v.versionNote ?? 'No note'} (${new Date(v.createdAt).toLocaleDateString()})` ); return { content: [{ type: 'text' as const, text: `Version history (${versions.length} version${versions.length === 1 ? '' : 's'}):\n\n${lines.join('\n')}\n\n${suffix}`, - src/api-client.ts:61-68 (schema)PromptVersion interface defining the structure of version objects returned by the listVersions API call, including id, versionNumber, title, content, versionNote, and createdAt fields.
export interface PromptVersion { id: string; versionNumber: number; title: string; content: string; versionNote: string | null; createdAt: string; } - src/api-client.ts:245-247 (helper)API client method listVersions that makes an HTTP GET request to the /api/mcp/prompt/{promptId}/version endpoint and returns an array of PromptVersion objects.
async listVersions(promptId: string): Promise<PromptVersion[]> { return this.request<PromptVersion[]>(`/api/mcp/prompt/${promptId}/version`); } - src/index.ts:89-105 (helper)resolvePromptId helper function that resolves a prompt ID from either an explicit ID or a title search. Used by the list_versions handler to find the correct prompt.
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 }; }