waha_check_contact_exists
Verify if a phone number is registered on WhatsApp to ensure valid contacts before messaging. Input a phone number to check its WhatsApp availability.
Instructions
Check if phone number is registered on WhatsApp.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| phone | Yes | Phone number to check (e.g., '1234567890') |
Implementation Reference
- src/index.ts:912-923 (registration)Tool registration in the listTools handler, defining the tool name, description, and input schema.name: "waha_check_contact_exists", description: "Check if phone number is registered on WhatsApp.", inputSchema: { type: "object", properties: { phone: { type: "string", description: "Phone number to check (e.g., '1234567890')", }, }, required: ["phone"], },
- src/index.ts:2472-2489 (handler)The MCP tool handler function that validates input, calls the WAHA client method, and returns a formatted text response with the result.private async handleCheckContactExists(args: any) { const phone = args.phone; if (!phone) { throw new Error("phone is required"); } const result = await this.wahaClient.checkContactExists(phone); return { content: [ { type: "text", text: `Contact existence check for ${phone}:\n${JSON.stringify(result, null, 2)}`, }, ], }; }
- src/index.ts:914-922 (schema)Input schema definition for the tool, specifying the required 'phone' parameter as a string.inputSchema: { type: "object", properties: { phone: { type: "string", description: "Phone number to check (e.g., '1234567890')", }, }, required: ["phone"],
- src/index.ts:1137-1138 (registration)Registration of the tool handler in the CallToolRequestSchema switch statement.case "waha_check_contact_exists": return await this.handleCheckContactExists(args);
- src/client/waha-client.ts:1278-1293 (helper)WAHA client helper method that makes a GET request to the WAHA API endpoint /api/contacts/check-exists to check if the phone number exists.async checkContactExists(phone: string): Promise<any> { if (!phone) { throw new WAHAError("phone is required"); } const queryParams = { phone, session: this.session }; const queryString = this.buildQueryString(queryParams); const endpoint = `/api/contacts/check-exists${queryString}`; return this.request<any>(endpoint, { method: "GET", }); }