list_videos
Retrieve a list of ad videos from your ad account. Filter by fields, limit results, and paginate through videos.
Instructions
List ad videos uploaded to 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/videos.ts:7-27 (handler)The handler for the list_videos MCP tool. It calls the Meta Ads API GET /act_{accountId}/advideos with optional fields, limit, and after (pagination) parameters, then returns the result as JSON with rate limit info.
server.tool( "list_videos", "List ad videos uploaded to 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}/advideos`, 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/videos.ts:10-14 (schema)Zod schema for list_videos input: optional fields, limit (default 25), and after (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/videos.ts:5-5 (registration)The registerVideoTools function is where list_videos is registered via server.tool().
export function registerVideoTools(server: McpServer, client: AdsClient): void { - src/index.ts:57-58 (registration)Registration call site in the main server initialization (line 57 is registerVideoTools).
registerVideoTools(server, client); registerCanvasTools(server, client); - src/services/ads-client.ts:213-225 (helper)The AdsClient.accountPath getter used by the handler to construct the API URL (/act_{accountId}/advideos).
get accountPath(): string { return `/act_${this.accountId}`; } get accountId(): string { if (!this.config.adAccountId) { throw new Error( "META_AD_ACCOUNT_ID is not configured. Set it as an environment variable." ); } return this.config.adAccountId; }