Send Contact
send_contactSend one or more contact details as vCards to a WhatsApp number or group.
Instructions
Share one or more contacts (vCards) via the pinned WhatsApp instance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | Recipient JID or phone number (e.g. 5511999999999 or group@g.us) | |
| contact | Yes | Array of contacts to share |
Implementation Reference
- src/tools/send-contact.ts:21-42 (handler)The registerSendContact function that registers the 'send_contact' tool. The handler function (lines 29-40) sends contact(s) by making a POST request to /message/sendContact/{instanceName} with number and contact array, then returns the JSON response.
export function registerSendContact(server: McpServer, client: EvolutionClient): void { server.registerTool( "send_contact", { title: "Send Contact", description: "Share one or more contacts (vCards) via the pinned WhatsApp instance.", inputSchema: schema, }, async (args) => { try { const data = await client.post(`/message/sendContact/${client.instanceName}`, { number: args.number, contact: args.contact, }); 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/send-contact.ts:1-19 (schema)Schema definitions for the send_contact tool. ContactSchema defines the per-contact fields (fullName, wuid, phoneNumber, organization, email, url). The input schema takes a 'number' (PhoneOrJidSchema) and an array of 'contact' objects.
import { z } from "zod"; import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { McpError } from "@modelcontextprotocol/sdk/types.js"; import type { EvolutionClient } from "../evolution-client.js"; import { PhoneOrJidSchema } from "../schemas.js"; const ContactSchema = z.object({ fullName: z.string().min(1).describe("Contact's full name"), wuid: z.string().min(1).describe("WhatsApp UID (e.g. 5511999999999@s.whatsapp.net)"), phoneNumber: z.string().min(1).describe("Phone number in international format"), organization: z.string().optional().describe("Contact's organization/company"), email: z.string().email().optional().describe("Contact's email address"), url: z.string().url().optional().describe("Contact's website URL"), }); const schema = { number: PhoneOrJidSchema, contact: z.array(ContactSchema).min(1).describe("Array of contacts to share"), }; - src/tools/index.ts:19-19 (registration)Import of registerSendContact from send-contact.ts in the central tools index.
import { registerSendContact } from "./send-contact.js"; - src/tools/index.ts:92-92 (registration)Registration call: registerSendContact(server, client) invoked inside registerAllTools.
registerSendContact(server, client); - src/schemas.ts:8-11 (helper)PhoneOrJidSchema used as the input schema for the 'number' parameter - accepts WhatsApp JID or phone number.
export const PhoneOrJidSchema = z .string() .min(1) .describe("Recipient JID or phone number (e.g. 5511999999999 or group@g.us)");