Skip to main content
Glama
by wsapi-chat

whatsapp_update_contact

Modify an existing WhatsApp contact's details, such as full name and first name, using the contact's ID to ensure accurate updates in your address book.

Instructions

Update an existing WhatsApp contact.

Input Schema

NameRequiredDescriptionDefault
contactIdYesContact ID (phone number with @s.whatsapp.net)
firstNameYesFirst name of the contact (max 255 characters)
fullNameYesFull name of the contact (max 255 characters)

Input Schema (JSON Schema)

{ "properties": { "contactId": { "description": "Contact ID (phone number with @s.whatsapp.net)", "type": "string" }, "firstName": { "description": "First name of the contact (max 255 characters)", "type": "string" }, "fullName": { "description": "Full name of the contact (max 255 characters)", "type": "string" } }, "required": [ "contactId", "fullName", "firstName" ], "type": "object" }

Implementation Reference

  • Full ToolHandler definition for 'whatsapp_update_contact', including input schema, validation, API call to update contact via wsapiClient.put, and success response.
    export const updateContact: ToolHandler = { name: 'whatsapp_update_contact', description: 'Update an existing WhatsApp contact.', inputSchema: { type: 'object', properties: { contactId: { type: 'string', description: 'Contact ID (phone number with @s.whatsapp.net)', }, fullName: { type: 'string', description: 'Full name of the contact (max 255 characters)', }, firstName: { type: 'string', description: 'First name of the contact (max 255 characters)', }, }, required: ['contactId', 'fullName', 'firstName'], }, handler: async (args: any) => { const input = validateInput(updateContactSchema, args); logger.info('Updating contact', { contactId: input.contactId, fullName: input.fullName, }); await wsapiClient.put(`/contacts/${input.contactId}`, { fullName: input.fullName, firstName: input.firstName, }); logger.info('Contact updated successfully', { contactId: input.contactId }); return { success: true, message: 'Contact updated successfully', }; }, };
  • Zod schema for validating input to the whatsapp_update_contact tool, used in validateInput.
    export const updateContactSchema = z.object({ contactId: phoneNumberSchema, fullName: z.string().min(1).max(255), firstName: z.string().min(1).max(255), });
  • src/server.ts:53-79 (registration)
    Registration logic in MCP server that includes contactTools (containing updateContact) in toolCategories array and registers all tools into this.tools Map by name.
    private setupToolHandlers(): void { logger.info('Setting up tool handlers'); // Register all tool categories 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/server.ts:15-22 (registration)
    Imports contactTools which exports the updateContact handler, enabling its registration.
    import { messagingTools } from './tools/messaging.js'; import { contactTools } from './tools/contacts.js'; import { groupTools } from './tools/groups.js'; import { chatTools } from './tools/chats.js'; import { sessionTools } from './tools/session.js'; import { instanceTools } from './tools/instance.js'; import { accountTools } from './tools/account.js';
  • validateInput function used in the handler to validate arguments against updateContactSchema.
    export function validateInput<T>(schema: z.ZodSchema<T>, data: unknown): T { const result = schema.safeParse(data); if (!result.success) { const errors = result.error.errors.map(err => `${err.path.join('.')}: ${err.message}`); throw new Error(`Validation failed: ${errors.join(', ')}`); } return result.data; }

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