meta_subscribe_webhook
Subscribe to webhook notifications for Meta objects like Instagram or Page. Provide callback URL, verify token, and fields to receive updates on changes such as messages or feed.
Instructions
Subscribe to webhook notifications for an object (e.g., 'instagram', 'page'). Requires META_APP_ID and META_APP_SECRET.
Input 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:75-97 (handler)The handler for the meta_subscribe_webhook tool. It accepts object, callback_url, verify_token, and fields parameters, then calls client.meta('POST', '/app/subscriptions') to subscribe to webhook notifications for a Meta App.
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 }; } } ); - src/tools/meta/auth.ts:78-83 (schema)Zod input schema for meta_subscribe_webhook: object (enum), callback_url (URL), verify_token (string), fields (string).
{ 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')"), }, - src/tools/meta/auth.ts:75-97 (registration)The tool is registered on the McpServer via server.tool() inside the registerMetaAuthTools function, which is called from src/index.ts.
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 }; } } ); - src/services/meta-client.ts:98-108 (helper)The MetaClient.meta() method is the helper that makes the actual API call to the Meta Graph API using an app access token (appId|appSecret).
async meta( method: string, path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { if (!this.config.appId || !this.config.appSecret) { throw new Error("META_APP_ID and META_APP_SECRET are required."); } const appToken = `${this.config.appId}|${this.config.appSecret}`; return this.request(IG_BASE, appToken, method, path, params); }