get_creative
Retrieve a single Meta Ads creative by its ID to access asset details for review or reuse.
Instructions
Get a single ad creative by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| creative_id | Yes | ||
| fields | No |
Implementation Reference
- src/tools/creatives.ts:33-42 (handler)The handler for the 'get_creative' tool. It calls metaGet with the creative ID and optional fields, fetching a single ad creative from Meta's Graph API.
name: "get_creative", description: "Get a single ad creative by ID.", inputSchema: { creative_id: z.string(), fields: z.string().optional(), }, handler: async (args) => metaGet(`/${String(args.creative_id)}`, { fields: args.fields ?? DEFAULT_CREATIVE_FIELDS, }), - src/tools/creatives.ts:35-38 (schema)Input schema for get_creative: creative_id (required string) and fields (optional string). Defined using Zod.
inputSchema: { creative_id: z.string(), fields: z.string().optional(), }, - src/index.ts:65-89 (registration)Registration of 'get_creative' (and all other tools) via server.registerTool() in the stdio entrypoint.
for (const tool of allTools) { server.registerTool( tool.name, { description: tool.description, inputSchema: tool.inputSchema, }, // The SDK's ToolCallback type infers the arg shape from inputSchema, but // our shared ToolDef uses a generic Record<string, unknown> signature for // portability. The cast here is intentional and isolated to the bridge. async (args: unknown) => { try { const result = await tool.handler(args as Record<string, unknown>); return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], }; } catch (err) { const message = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } }, ); - src/http.ts:48-66 (registration)Registration of 'get_creative' (and all other tools) via server.registerTool() in the HTTP entrypoint.
for (const tool of allTools) { server.registerTool( tool.name, { description: tool.description, inputSchema: tool.inputSchema }, async (args: unknown) => { try { const result = await tool.handler(args as Record<string, unknown>); return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], }; } catch (err) { const message = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } }, ); - src/client.ts:144-160 (helper)The metaGet helper function used by the get_creative handler to perform the HTTP GET to the Meta Graph API.
export async function metaGet<T = unknown>( path: string, params: Record<string, unknown> = {}, ): Promise<T> { const qs = buildQuery(params); qs.append("access_token", getCurrentToken()); const url = `${META_API_BASE}${normalizePath(path)}?${qs.toString()}`; const res = await fetch(url, { method: "GET" }); if (!res.ok) { const text = await res.text().catch(() => ""); throw new Error(enhanceMetaError(res.status, text)); } const raw = await res.text(); if (!raw) return {} as T; return JSON.parse(raw) as T; }