generate_preview
Generate ad previews by inputting creative specs and ad format. Visualize how the ad would appear on Facebook or Instagram without requiring an existing ad.
Instructions
Generate an ad preview without needing an existing ad. Provide creative spec directly to see how it would look.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ad_format | Yes | Ad format: DESKTOP_FEED_STANDARD, MOBILE_FEED_STANDARD, INSTAGRAM_STANDARD, INSTAGRAM_STORY, RIGHT_COLUMN_STANDARD, etc. | |
| creative | Yes | JSON string of creative spec: {object_story_spec: {...}} or {object_story_id: '...'} |
Implementation Reference
- src/tools/creatives.ts:113-129 (handler)The generate_preview tool handler: registers an MCP tool that takes ad_format and creative (JSON string of creative spec) as input, calls the Meta Ads API GET /act_{accountId}/generatepreviews endpoint, and returns the preview data with rate limit info.
// ─── generate_preview ────────────────────────────────────── server.tool( "generate_preview", "Generate an ad preview without needing an existing ad. Provide creative spec directly to see how it would look.", { ad_format: z.string().describe("Ad format: DESKTOP_FEED_STANDARD, MOBILE_FEED_STANDARD, INSTAGRAM_STANDARD, INSTAGRAM_STORY, RIGHT_COLUMN_STANDARD, etc."), creative: z.string().describe("JSON string of creative spec: {object_story_spec: {...}} or {object_story_id: '...'}"), }, async ({ ad_format, creative }) => { try { const { data, rateLimit } = await client.get(`${client.accountPath}/generatepreviews`, { ad_format, creative }); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/tools/creatives.ts:117-120 (schema)Input schema for generate_preview: ad_format (string) and creative (string - JSON of creative spec).
{ ad_format: z.string().describe("Ad format: DESKTOP_FEED_STANDARD, MOBILE_FEED_STANDARD, INSTAGRAM_STANDARD, INSTAGRAM_STORY, RIGHT_COLUMN_STANDARD, etc."), creative: z.string().describe("JSON string of creative spec: {object_story_spec: {...}} or {object_story_id: '...'}"), }, - src/tools/creatives.ts:114-115 (registration)Registration of the generate_preview tool on the MCP server via server.tool().
server.tool( "generate_preview", - src/index.ts:53-53 (registration)Top-level registration: registerCreativeTools(server, client) is called in index.ts which wires up all creative tools including generate_preview.
registerCreativeTools(server, client);