Check Number
check_numberCheck whether phone numbers have active WhatsApp accounts. Returns existence status and JID for each number.
Instructions
Check whether phone numbers have WhatsApp accounts. Returns exists, jid, and number for each.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| numbers | Yes | Array of phone numbers to check (e.g. ['5511999999999']). Returns whether each number has WhatsApp and their JID. |
Implementation Reference
- src/tools/check-number.ts:1-32 (handler)The registerCheckNumber function is the main handler that registers the 'check_number' tool on the MCP server. It accepts a zod schema requiring an array of phone numbers, calls the Evolution API endpoint /chat/whatsappNumbers/{instanceName} to check if each number has WhatsApp, and returns the result (exists, jid, number) as JSON.
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"; const schema = { numbers: z.array(z.string().min(1)).min(1).describe( "Array of phone numbers to check (e.g. ['5511999999999']). Returns whether each number has WhatsApp and their JID." ), }; export function registerCheckNumber(server: McpServer, client: EvolutionClient): void { server.registerTool( "check_number", { title: "Check Number", description: "Check whether phone numbers have WhatsApp accounts. Returns exists, jid, and number for each.", inputSchema: schema, }, async (args) => { try { const data = await client.post(`/chat/whatsappNumbers/${client.instanceName}`, { numbers: args.numbers, }); 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/check-number.ts:6-10 (schema)The input schema defines a single required parameter 'numbers' as an array of non-empty strings, describing that it checks if each number has WhatsApp and returns their JID.
const schema = { numbers: z.array(z.string().min(1)).min(1).describe( "Array of phone numbers to check (e.g. ['5511999999999']). Returns whether each number has WhatsApp and their JID." ), }; - src/tools/index.ts:74-74 (registration)Import of registerCheckNumber from the check-number module.
import { registerCheckNumber } from "./check-number.js"; - src/tools/index.ts:147-147 (registration)Registration call: registerCheckNumber(server, client) invoked inside registerAllTools.
registerCheckNumber(server, client);