Skip to main content
Glama

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
NameRequiredDescriptionDefault
phoneYesPhone 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"],
    },
  • 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)}`,
          },
        ],
      };
    }
  • 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);
  • 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",
      });
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/seejux/waha-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server