get_async_report
Retrieve status and results of an asynchronous insight report using its run ID. Optionally specify fields to return.
Instructions
Check status and retrieve results of an async insight report.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| report_run_id | Yes | Report run ID from create_async_report | |
| fields | No | Comma-separated fields to return |
Implementation Reference
- src/tools/insights.ts:100-116 (handler)The 'get_async_report' tool handler. It takes report_run_id and optional fields, makes a GET request to the Meta Ads API using the report_run_id as path, and returns the async report data with rate limit info.
// ─── get_async_report ────────────────────────────────────── server.tool( "get_async_report", "Check status and retrieve results of an async insight report.", { report_run_id: z.string().describe("Report run ID from create_async_report"), fields: z.string().optional().describe("Comma-separated fields to return"), }, async ({ report_run_id, ...params }) => { try { const { data, rateLimit } = await client.get(`/${report_run_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/insights.ts:104-107 (schema)Input schema for 'get_async_report': requires 'report_run_id' (string) and optional 'fields' (string, comma-separated). Validated using zod.
{ report_run_id: z.string().describe("Report run ID from create_async_report"), fields: z.string().optional().describe("Comma-separated fields to return"), }, - src/tools/insights.ts:101-116 (registration)Registration of the 'get_async_report' tool on the MCP server via server.tool() with description, schema, and handler.
server.tool( "get_async_report", "Check status and retrieve results of an async insight report.", { report_run_id: z.string().describe("Report run ID from create_async_report"), fields: z.string().optional().describe("Comma-separated fields to return"), }, async ({ report_run_id, ...params }) => { try { const { data, rateLimit } = await client.get(`/${report_run_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/index.ts:65-65 (registration)Top-level invocation of registerInsightTools(server, client) which registers all insight tools including get_async_report.
registerInsightTools(server, client);