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
| Name | Required | Description | Default |
|---|---|---|---|
| contactId | Yes | Contact ID (format: number@c.us) |
Implementation Reference
- src/index.ts:2429-2446 (handler)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)}`, }, ], }; }
- src/index.ts:870-883 (schema)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":
- src/client/waha-client.ts:1230-1245 (helper)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", }); }