get_inspiration
Retrieve a gallery entry's full prompt and image URLs to use as visual examples or reference images for style transfer.
Instructions
Get the full prompt and all image URLs for a gallery entry. Show the images to the user as visual examples. The prompt can be used directly with generate_image(), and image URLs can be passed as referenceImages for style transfer.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| imageId | Yes | Image/prompt ID from search_gallery results |
Implementation Reference
- src/tools/get-inspiration.ts:15-121 (handler)Handler function that registers the 'get_inspiration' tool. Fetches full prompt details and images for a gallery entry, checking local curated library first, then falling back to the MeiGen API.
export function registerGetInspiration(server: McpServer, apiClient: MeiGenApiClient) { server.tool( 'get_inspiration', 'Get the full prompt and all image URLs for a gallery entry. Show the images to the user as visual examples. The prompt can be used directly with generate_image(), and image URLs can be passed as referenceImages for style transfer.', getInspirationSchema, { readOnlyHint: true }, async ({ imageId }) => { // 1. Check local curated library first const local = getPromptById(imageId) if (local) { const details = [ `# Trending Prompt #${local.rank}`, '', '## Generated Images', 'Show these images to the user as visual examples of what this prompt produces:', ...local.images.map((url, i) => ``), '', '## Full Prompt', '```', local.prompt, '```', '', '## Metadata', `- Author: ${local.author_name} (@${local.author})`, `- Model: ${local.model}`, `- Categories: ${local.categories.join(', ')}`, `- Likes: ${local.likes.toLocaleString()}`, `- Views: ${local.views.toLocaleString()}`, `- Date: ${local.date}`, '', '## Next Steps', '- Use this prompt directly with generate_image() to create a similar image', '- Modify the prompt to create your own variation', local.images.length > 0 ? `- Pass "${local.images[0]}" as a referenceImages URL to generate_image() for style transfer` : '', ].filter(Boolean).join('\n') return { content: [{ type: 'text' as const, text: details, }], } } // 2. Fallback to API query try { const image = await apiClient.getImageDetails(imageId) if (!image) { return { content: [{ type: 'text' as const, text: `Image not found: ${imageId}`, }], isError: true, } } const imageUrls = image.media_urls || [] const details = [ `# Image Details (ID: ${image.id})`, '', '## Generated Images', 'Show these images to the user:', image.thumbnail_url ? `` : '', ...imageUrls.map((url, i) => ``), '', '## Full Prompt', '```', image.text || '(No prompt available)', '```', '', '## Metadata', image.model ? `- Model: ${image.model}` : '', image.image_width && image.image_height ? `- Dimensions: ${image.image_width}x${image.image_height}` : '', `- Likes: ${image.likes}`, `- Views: ${image.views}`, image.author_display_name ? `- Author: ${image.author_display_name}` : '', '', '## Next Steps', '- Use this prompt with generate_image() to create a similar image', '- Modify the prompt to create your own variation', imageUrls.length > 0 ? `- Pass "${imageUrls[0]}" as a referenceImages URL to generate_image() for style transfer` : '', ].filter(Boolean).join('\n') return { content: [{ type: 'text' as const, text: details, }], } } catch { return { content: [{ type: 'text' as const, text: `Image not found: ${imageId}. This ID is not in the curated library and the online gallery is unavailable.`, }], isError: true, } } } ) } - src/tools/get-inspiration.ts:11-13 (schema)Input schema for get_inspiration: requires a single 'imageId' string parameter from search_gallery results.
export const getInspirationSchema = { imageId: z.string().describe('Image/prompt ID from search_gallery results'), } - src/server.ts:268-268 (registration)Registration call in createServer() that wires up the get_inspiration tool with the MCP server instance and API client.
registerGetInspiration(server, apiClient) - src/lib/prompt-library.ts:171-174 (helper)Helper function that looks up a prompt by ID in the local curated library of 1300+ trending prompts.
export function getPromptById(id: string): TrendingPrompt | null { const prompts = loadPrompts() return prompts.find(p => p.id === id) || null } - src/lib/meigen-api.ts:125-136 (helper)API client method that fetches image details by ID from the MeiGen platform (fallback when not in local library).
async getImageDetails(imageId: string): Promise<MeiGenSearchResult | null> { const res = await fetch(`${this.baseUrl}/api/images/${encodeURIComponent(imageId)}`) if (!res.ok) { if (res.status === 404) return null throw new Error(`Failed to fetch image: ${res.status} ${res.statusText}`) } const json = await res.json() as { success: boolean; data?: MeiGenSearchResult; error?: string } if (!json.success) return null return json.data || null }