Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
ad_formatYesAd format: DESKTOP_FEED_STANDARD, MOBILE_FEED_STANDARD, INSTAGRAM_STANDARD, INSTAGRAM_STORY, RIGHT_COLUMN_STANDARD, etc.
creativeYesJSON string of creative spec: {object_story_spec: {...}} or {object_story_id: '...'}

Implementation Reference

  • 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 };
        }
      }
    );
  • 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: '...'}"),
    },
  • 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);

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.2.1

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full burden. It discloses that this is a preview generation (not a mutation) and that it operates without an existing ad, which implies a read-only nature. However, it does not mention response format, permissions, or potential failure modes, leaving some behavioral uncertainty.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the primary purpose, and contains no wasted words. It efficiently communicates the core functionality and key differentiator.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter tool, the description covers the main purpose and usage context. However, because there is no output schema, the description does not clarify what the preview output looks like (e.g., image URL, JSON), which leaves some incompleteness. It is adequate but not fully comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already provides 100% coverage for both parameters, so the description adds no additional semantic value beyond what the schema gives. The description's mention of 'creative spec' and 'ad format' simply restates the parameter names without enriching understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Generate an ad preview') and the unique resource ('without needing an existing ad'). It explicitly distinguishes itself from the sibling tool get_ad_preview by emphasizing that it works directly from a creative spec, making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'without needing an existing ad' implies when to use this tool (when you don't have an ad yet) and indirectly contrasts with alternatives like get_ad_preview. However, it does not explicitly name alternatives or provide when-not-to-use guidance, so usage context is only implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools