get_ad
Retrieve details of a specific ad by providing its ID and optional fields.
Instructions
Get details of a specific ad by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ad_id | Yes | Ad ID | |
| fields | No | Comma-separated fields to return |
Implementation Reference
- src/tools/ads.ts:35-53 (handler)The get_ad tool handler: calls the Facebook Ads API via client.get with the ad ID and optional fields, returns ad details as JSON.
// ─── get_ad ──────────────────────────────────────────────── server.tool( "get_ad", "Get details of a specific ad by ID.", { ad_id: z.string().describe("Ad ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, async ({ ad_id, fields }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; const { data, rateLimit } = await client.get(`/${ad_id}`, 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/ads.ts:39-42 (schema)Input schema for get_ad: requires ad_id (string) and optional fields (string).
{ ad_id: z.string().describe("Ad ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, - src/index.ts:52-52 (registration)Registration of registerAdTools which includes the get_ad tool.
registerAdTools(server, client); - src/tools/ads.ts:36-37 (registration)Tool registration via server.tool('get_ad', ...) in the registerAdTools function.
server.tool( "get_ad",