get_session_status
Verify the connection status of a WhatsApp session to ensure it is active and ready for messaging.
Instructions
Check the current connection status of a WhatsApp session (connected, disconnected, etc.)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ID of the session to check |
Implementation Reference
- src/tools/sessions.ts:96-99 (handler)Handler function for get_session_status tool. Calls the OpenWA API GET /sessions/{sessionId}/status to retrieve the current connection status of a WhatsApp session and returns the result as formatted JSON text content.
async ({ sessionId }) => { const data = await openwaClient({ method: "GET", path: `/sessions/${sessionId}/status` }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/tools/sessions.ts:90-94 (schema)Schema definition for get_session_status. Defines the tool description and input schema requiring a sessionId string parameter validated with Zod.
{ description: "Check the current connection status of a WhatsApp session (connected, disconnected, etc.)", inputSchema: { sessionId: z.string().describe("ID of the session to check"), }, - src/tools/sessions.ts:88-100 (registration)Registration of the get_session_status tool on the MCP server via server.registerTool() inside the registerSessionTools function.
server.registerTool( "get_session_status", { description: "Check the current connection status of a WhatsApp session (connected, disconnected, etc.)", inputSchema: { sessionId: z.string().describe("ID of the session to check"), }, }, async ({ sessionId }) => { const data = await openwaClient({ method: "GET", path: `/sessions/${sessionId}/status` }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/client.ts:10-35 (helper)The openwaClient helper function used by get_session_status handler to make authenticated HTTP requests to the OpenWA backend 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; } }