list_creatives
Retrieve ad creatives from your Meta Ads account with optional field selection, result limit, and pagination cursor.
Instructions
List ad creatives in the ad account.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | Comma-separated fields to return | |
| limit | No | Number of results (default 25) | |
| after | No | Pagination cursor for next page |
Implementation Reference
- src/tools/creatives.ts:15-27 (handler)The async handler function that executes the 'list_creatives' tool logic. It accepts optional 'fields', 'limit', and 'after' parameters, then calls client.get with the account path and '/adcreatives' endpoint, returning the JSON data with rate limit info.
async ({ fields, limit, after }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; if (limit) params.limit = limit; if (after) params.after = after; const { data, rateLimit } = await client.get(`${client.accountPath}/adcreatives`, params); 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:10-14 (schema)Zod input schema for 'list_creatives'. Defines three optional parameters: 'fields' (string), 'limit' (number, default 25), and 'after' (string, pagination cursor).
{ fields: z.string().optional().describe("Comma-separated fields to return"), limit: z.number().optional().default(25).describe("Number of results (default 25)"), after: z.string().optional().describe("Pagination cursor for next page"), }, - src/tools/creatives.ts:7-27 (registration)Registration of 'list_creatives' as an MCP tool via server.tool(). The tool is named 'list_creatives' with description 'List ad creatives in the ad account.'
server.tool( "list_creatives", "List ad creatives in the ad account.", { fields: z.string().optional().describe("Comma-separated fields to return"), limit: z.number().optional().default(25).describe("Number of results (default 25)"), after: z.string().optional().describe("Pagination cursor for next page"), }, async ({ fields, limit, after }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; if (limit) params.limit = limit; if (after) params.after = after; const { data, rateLimit } = await client.get(`${client.accountPath}/adcreatives`, params); 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/index.ts:53-53 (registration)Top-level call to registerCreativeTools(server, client) which registers the 'list_creatives' tool along with other creative tools.
registerCreativeTools(server, client); - src/services/ads-client.ts:213-215 (helper)The accountPath getter on AdsClient used in the handler to construct the API endpoint URL: /act_{accountId}/adcreatives.
get accountPath(): string { return `/act_${this.accountId}`; }