get_canvas
Retrieve details of an Instant Experience (Canvas) by providing its ID. Specify optional fields to customize the returned data.
Instructions
Get details of a specific Instant Experience (Canvas) by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| canvas_id | Yes | Canvas ID | |
| fields | No | Comma-separated fields to return |
Implementation Reference
- src/tools/canvas.ts:30-47 (handler)The 'get_canvas' tool handler: an async function registered with server.tool() that takes canvas_id and optional fields, builds query params, calls client.get(`/${canvas_id}`) to fetch a specific Canvas by ID from the Meta Ads API, and returns the response JSON with rate limit info.
server.tool( "get_canvas", "Get details of a specific Instant Experience (Canvas) by ID.", { canvas_id: z.string().describe("Canvas ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, async ({ canvas_id, fields }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; const { data, rateLimit } = await client.get(`/${canvas_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/canvas.ts:33-36 (schema)Input schema for get_canvas: requires 'canvas_id' (z.string) and optional 'fields' (z.string).
{ canvas_id: z.string().describe("Canvas ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, - src/index.ts:58-58 (registration)Registration call: registerCanvasTools(server, client) wires the tool into the MCP server.
registerCanvasTools(server, client); - src/services/ads-client.ts:180-185 (helper)The AdsClient.get() convenience method used by the handler to make the GET request to the Meta Ads API.
async get( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("GET", path, params); }