Skip to main content
Glama

waha_get_contact

Retrieve WhatsApp contact details by ID to access user information for messaging and chat management.

Instructions

Get contact information by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactIdYesContact ID (format: number@c.us)

Implementation Reference

  • The main handler function for the "waha_get_contact" MCP tool. It validates the contactId input, calls the WAHA client's getContact method, and returns a formatted text response containing the contact information as JSON.
    private async handleGetContact(args: any) {
      const contactId = args.contactId;
    
      if (!contactId) {
        throw new Error("contactId is required");
      }
    
      const contact = await this.wahaClient.getContact(contactId);
    
      return {
        content: [
          {
            type: "text",
            text: `Contact information for ${contactId}:\n${JSON.stringify(contact, null, 2)}`,
          },
        ],
      };
    }
  • The input schema definition for the "waha_get_contact" tool, specifying that a 'contactId' string (format: number@c.us) is required.
    {
      name: "waha_get_contact",
      description: "Get contact information by ID.",
      inputSchema: {
        type: "object",
        properties: {
          contactId: {
            type: "string",
            description: "Contact ID (format: number@c.us)",
          },
        },
        required: ["contactId"],
      },
    },
  • src/index.ts:1134-1135 (registration)
    Registration of the tool handler in the MCP CallToolRequestSchema switch statement, dispatching calls to handleGetContact.
      return await this.handleGetContact(args);
    case "waha_get_all_contacts":
  • Supporting WAHA client method that performs the actual API request to retrieve contact information via GET /api/contacts?contactId=...&session=...
    async getContact(contactId: string): Promise<any> {
      if (!contactId) {
        throw new WAHAError("contactId is required");
      }
    
      const queryParams = { 
        contactId,
        session: this.session
      };
      const queryString = this.buildQueryString(queryParams);
      const endpoint = `/api/contacts${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