Connection State
connection_stateCheck the current connection state of your pinned WhatsApp instance to determine if it is open, closed, or connecting.
Instructions
Get the current connection state of the pinned WhatsApp instance (open, close, connecting).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/connection-state.ts:5-23 (handler)The handler function that registers and implements the 'connection_state' tool. It calls the Evolution API endpoint /instance/connectionState/{instanceName} and returns the connection state data.
export function registerConnectionState(server: McpServer, client: EvolutionClient): void { server.registerTool( "connection_state", { title: "Connection State", description: "Get the current connection state of the pinned WhatsApp instance (open, close, connecting).", inputSchema: {}, }, async () => { try { const data = await client.get(`/instance/connectionState/${client.instanceName}`); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (e) { if (e instanceof McpError) return { isError: true, content: [{ type: "text" as const, text: e.message }] }; throw e; } } ); } - src/tools/index.ts:131-131 (registration)Registration call that wires up the connection_state tool handler.
registerConnectionState(server, client); - src/tools/index.ts:58-58 (helper)Import of the registerConnectionState function from its module.
import { registerConnectionState } from "./connection-state.js";