Skip to main content
Glama
by wsapi-chat

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

NameRequiredDescriptionDefault
addressNoAddress of the location (max 1000 characters)
latitudeYesLatitude coordinate
longitudeYesLongitude coordinate
nameNoName of the location (max 1000 characters)
toYesRecipient phone number (with @s.whatsapp.net) or group ID (with @g.us)
urlNoURL 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

  • 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', }; }, };
  • 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(), });
  • 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`); }
  • 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, };

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/wsapi-chat/wsapi-mcp'

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