delete_session
Remove a WhatsApp session and its data permanently. Use this tool to clean up unused sessions and free resources.
Instructions
Permanently delete a WhatsApp session and its data
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ID of the session to delete |
Implementation Reference
- src/tools/sessions.ts:68-71 (handler)The handler function for the 'delete_session' tool. Sends a DELETE request to /sessions/{sessionId} via openwaClient and returns the result as text.
async ({ sessionId }) => { const data = await openwaClient({ method: "DELETE", path: `/sessions/${sessionId}` }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/tools/sessions.ts:63-66 (schema)Input schema for 'delete_session' defining the required 'sessionId' parameter (a string).
description: "Permanently delete a WhatsApp session and its data", inputSchema: { sessionId: z.string().describe("ID of the session to delete"), }, - src/tools/sessions.ts:60-72 (registration)Registration of the 'delete_session' tool on the McpServer via server.registerTool, including description, input schema, and handler.
server.registerTool( "delete_session", { description: "Permanently delete a WhatsApp session and its data", inputSchema: { sessionId: z.string().describe("ID of the session to delete"), }, }, async ({ sessionId }) => { const data = await openwaClient({ method: "DELETE", path: `/sessions/${sessionId}` }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/client.ts:10-35 (helper)The openwaClient helper function used by the handler to make HTTP requests 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:15-16 (registration)Registration of registerSessionTools on the McpServer in the main entry point.
registerSessionTools(server); registerMessageTools(server);