list_webhooks
Retrieve all webhooks for a WhatsApp session to view and manage event notifications.
Instructions
List all webhooks configured for a WhatsApp session
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID |
Implementation Reference
- src/tools/webhooks.ts:5-18 (registration)The tool 'list_webhooks' is registered via server.registerTool along with its schema definition.
export function registerWebhookTools(server: McpServer) { server.registerTool( "list_webhooks", { description: "List all webhooks configured for a WhatsApp session", inputSchema: { sessionId: z.string().describe("Session ID"), }, }, async ({ sessionId }) => { const data = await openwaClient({ method: "GET", path: `/sessions/${sessionId}/webhooks` }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/tools/webhooks.ts:6-17 (handler)The handler function for 'list_webhooks' that makes a GET request to /sessions/{sessionId}/webhooks and returns the result.
server.registerTool( "list_webhooks", { description: "List all webhooks configured for a WhatsApp session", inputSchema: { sessionId: z.string().describe("Session ID"), }, }, async ({ sessionId }) => { const data = await openwaClient({ method: "GET", path: `/sessions/${sessionId}/webhooks` }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/tools/webhooks.ts:8-13 (schema)Input schema for list_webhooks: requires sessionId (string).
{ description: "List all webhooks configured for a WhatsApp session", inputSchema: { sessionId: z.string().describe("Session ID"), }, }, - src/client.ts:10-35 (helper)The openwaClient helper that performs the actual HTTP request to the OpenWA API.
export async function openwaClient<T = unknown>(opts: RequestOptions): Promise<T> { const url = `${BASE_URL}${opts.path}`; const headers: Record<string, string> = { "Content-Type": "application/json", "X-API-Key": API_KEY, }; const res = await fetch(url, { method: opts.method, headers, body: opts.body ? JSON.stringify(opts.body) : undefined, }); const text = await res.text(); if (!res.ok) { throw new Error(`OpenWA API ${res.status}: ${text}`); } try { return JSON.parse(text) as T; } catch { return text as T; } } - src/index.ts:9-9 (registration)Import of registerWebhookTools from webhooks.ts.
import { registerWebhookTools } from "./tools/webhooks.js";