whatsapp_send_location
Send location coordinates to WhatsApp contacts or groups using latitude and longitude data, optionally including place names, addresses, or map links for precise location sharing.
Instructions
Send a location message to a WhatsApp contact or group.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | No | Address of the location (max 1000 characters) | |
| latitude | Yes | Latitude coordinate | |
| longitude | Yes | Longitude coordinate | |
| name | No | Name of the location (max 1000 characters) | |
| to | Yes | Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us) | |
| url | No | URL related to the location (e.g., Google Maps link) |
Input Schema (JSON Schema)
{
"properties": {
"address": {
"description": "Address of the location (max 1000 characters)",
"optional": true,
"type": "string"
},
"latitude": {
"description": "Latitude coordinate",
"maximum": 90,
"minimum": -90,
"type": "number"
},
"longitude": {
"description": "Longitude coordinate",
"maximum": 180,
"minimum": -180,
"type": "number"
},
"name": {
"description": "Name of the location (max 1000 characters)",
"optional": true,
"type": "string"
},
"to": {
"description": "Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)",
"type": "string"
},
"url": {
"description": "URL related to the location (e.g., Google Maps link)",
"optional": true,
"type": "string"
}
},
"required": [
"to",
"latitude",
"longitude"
],
"type": "object"
}
Implementation Reference
- src/tools/messaging-advanced.ts:300-361 (handler)The complete ToolHandler object for the 'whatsapp_send_location' tool, defining its name, description, input schema, and the async handler function that performs input validation and sends the location message via the WSAPI client.export const sendLocationMessage: ToolHandler = { name: 'whatsapp_send_location', description: 'Send a location message to a WhatsApp contact or group.', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)', }, latitude: { type: 'number', minimum: -90, maximum: 90, description: 'Latitude coordinate', }, longitude: { type: 'number', minimum: -180, maximum: 180, description: 'Longitude coordinate', }, name: { type: 'string', description: 'Name of the location (max 1000 characters)', optional: true, }, address: { type: 'string', description: 'Address of the location (max 1000 characters)', optional: true, }, url: { type: 'string', description: 'URL related to the location (e.g., Google Maps link)', optional: true, }, }, required: ['to', 'latitude', 'longitude'], }, handler: async (args: any) => { const input = validateInput(sendLocationMessageSchema, args) as SendLocationMessageInput; logger.info('Sending location message', { to: input.to, latitude: input.latitude, longitude: input.longitude, hasName: !!input.name, hasAddress: !!input.address, }); const result = await wsapiClient.post('/messages/location', input); logger.info('Location message sent successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Location message sent successfully', }; }, };
- src/validation/schemas.ts:99-106 (schema)Zod validation schema (sendLocationMessageSchema) used by the tool handler's validateInput function to parse and validate the input parameters.export const sendLocationMessageSchema = z.object({ to: chatIdSchema, latitude: z.number().min(-90).max(90), longitude: z.number().min(-180).max(180), name: z.string().max(1000).optional(), address: z.string().max(1000).optional(), url: urlSchema.optional(), });
- src/validation/schemas.ts:322-322 (schema)TypeScript type definition for the tool's input, inferred from the Zod schema.export type SendLocationMessageInput = z.infer<typeof sendLocationMessageSchema>;
- src/server.ts:57-79 (registration)Registration of all tools, including 'whatsapp_send_location' via messagingTools, into the MCP server's tools Map during setupToolHandlers().const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); }); }); logger.info(`Registered ${this.tools.size} tools`); }
- src/tools/messaging.ts:541-555 (registration)Aggregation of advanced messaging tools (including sendLocationMessage / whatsapp_send_location) into the messagingTools object that is imported and registered in the MCP server.import { advancedMessagingTools } from './messaging-advanced.js'; // Export all messaging tools export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };