Skip to main content
Glama

WaPulse WhatsApp MCP Server

by Quegenx
validatePhoneNumber.ts•1.64 kB
import { z } from 'zod'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; import { validatePhoneNumber, formatPhoneNumber } from '../../utils/helpers.js'; export const validatePhoneNumberTool: Tool = { name: 'validate_phone_number', description: 'Validate if a phone number is in the correct format for WaPulse API', annotations: { title: 'Validate Phone Number', readOnlyHint: true, idempotentHint: true }, inputSchema: { type: 'object', properties: { phoneNumber: { type: 'string', description: 'Phone number to validate' } }, required: ['phoneNumber'], additionalProperties: false } }; export async function handleValidatePhoneNumber(args: any) { const schema = z.object({ phoneNumber: z.string() }); const { phoneNumber } = schema.parse(args); const isValid = validatePhoneNumber(phoneNumber); if (isValid) { const formatted = formatPhoneNumber(phoneNumber); // Extract country code (first 1-4 digits) const countryCode = phoneNumber.match(/^(\d{1,4})/)?.[1] || ''; return { content: [{ type: 'text', text: `āœ… Phone number is valid!\n\nšŸ“± Original: ${phoneNumber}\nšŸ“ž Formatted: ${formatted}\nšŸŒ Country Code: ${countryCode}\nšŸ“Š Status: VALID` }] }; } else { return { content: [{ type: 'text', text: `āŒ Phone number is invalid!\n\nšŸ“± Number: ${phoneNumber}\n🚫 Error: Must be 7-19 digits with country code\nšŸ“Š Status: INVALID\n\nšŸ’” Tip: Phone numbers should include country code (e.g., 972512345678 for Israel)` }] }; } }

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/Quegenx/wapulse-mcp'

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