meta_subscribe_webhook
Subscribe to real-time webhook notifications for Meta platform objects like Instagram pages or users. Configure HTTPS endpoints to receive updates on messages, feed changes, and other specified fields.
Instructions
Subscribe to webhook notifications for an object (e.g., 'instagram', 'page'). Requires META_APP_ID and META_APP_SECRET.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| object | Yes | Object type to subscribe to | |
| callback_url | Yes | HTTPS webhook endpoint URL | |
| verify_token | Yes | Verification token for the webhook | |
| fields | Yes | Comma-separated list of fields to subscribe (e.g., 'messages,feed') |
Implementation Reference
- src/tools/meta/auth.ts:74-97 (handler)The `meta_subscribe_webhook` tool is registered and implemented within `src/tools/meta/auth.ts` using the `server.tool` method. It takes an object, callback_url, verify_token, and fields as arguments and calls the Meta API's `/app/subscriptions` endpoint via the provided `client`.
// ─── meta_subscribe_webhook ────────────────────────────────── server.tool( "meta_subscribe_webhook", "Subscribe to webhook notifications for an object (e.g., 'instagram', 'page'). Requires META_APP_ID and META_APP_SECRET.", { object: z.enum(["instagram", "page", "user", "permissions"]).describe("Object type to subscribe to"), callback_url: z.string().url().describe("HTTPS webhook endpoint URL"), verify_token: z.string().describe("Verification token for the webhook"), fields: z.string().describe("Comma-separated list of fields to subscribe (e.g., 'messages,feed')"), }, async ({ object, callback_url, verify_token, fields }) => { try { const { data, rateLimit } = await client.meta("POST", `/app/subscriptions`, { object, callback_url, verify_token, fields, }); return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Webhook subscribe failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );