Update Profile Name
update_profile_nameUpdates the display name of the pinned WhatsApp instance's profile.
Instructions
Update the display name of the pinned WhatsApp instance's profile.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | New display name for the WhatsApp profile |
Implementation Reference
- src/tools/update-profile-name.ts:10-30 (handler)The registerUpdateProfileName function registers and implements the 'update_profile_name' tool. It calls the Evolution API POST endpoint /chat/updateProfileName/{instanceName} with the new name, and returns the result as JSON text.
export function registerUpdateProfileName(server: McpServer, client: EvolutionClient): void { server.registerTool( "update_profile_name", { title: "Update Profile Name", description: "Update the display name of the pinned WhatsApp instance's profile.", inputSchema: schema, }, async (args) => { try { const data = await client.post(`/chat/updateProfileName/${client.instanceName}`, { name: args.name, }); 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/update-profile-name.ts:6-8 (schema)Input schema for the tool: requires a 'name' string (min length 1) describing the new display name for the WhatsApp profile.
const schema = { name: z.string().min(1).describe("New display name for the WhatsApp profile"), }; - src/tools/index.ts:109-114 (registration)Registration call that wires update_profile_name into the MCP server alongside other profile tools.
registerUpdateProfileName(server, client); registerUpdateProfileStatus(server, client); registerUpdateProfilePicture(server, client); registerRemoveProfilePicture(server, client); registerFetchPrivacy(server, client); registerUpdatePrivacy(server, client); - src/tools/index.ts:36-38 (registration)Import statement for registerUpdateProfileName from the update-profile-name module.
import { registerUpdateProfileName } from "./update-profile-name.js"; import { registerUpdateProfileStatus } from "./update-profile-status.js"; import { registerUpdateProfilePicture } from "./update-profile-picture.js"; - src/evolution-client.ts:1-60 (helper)EvolutionClient class used by the handler to make HTTP POST requests to the Evolution API. The instanceName getter provides the instance name used in the URL path.
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js"; import type { Config } from "./config.js"; export class EvolutionClient { private readonly baseUrl: string; private readonly apiKey: string; private readonly instance: string; constructor(config: Config) { // Strip trailing slash to keep URL building consistent this.baseUrl = config.EVOLUTION_API_URL.replace(/\/$/, ""); this.apiKey = config.EVOLUTION_API_KEY; this.instance = config.EVOLUTION_INSTANCE; } get instanceName(): string { return this.instance; } async get<T = unknown>(path: string): Promise<T> { return this.request<T>("GET", path); } async post<T = unknown>(path: string, body: unknown): Promise<T> { return this.request<T>("POST", path, body); } async delete<T = unknown>(path: string, body?: unknown): Promise<T> { return this.request<T>("DELETE", path, body); } private async request<T>(method: string, path: string, body?: unknown): Promise<T> { const url = `${this.baseUrl}${path}`; const headers: Record<string, string> = { apikey: this.apiKey, "Content-Type": "application/json", }; const res = await fetch(url, { method, headers, body: body !== undefined ? JSON.stringify(body) : undefined, }); const text = await res.text(); if (!res.ok) { throw new McpError( ErrorCode.InternalError, `Evolution API error ${res.status}: ${text}` ); } try { return JSON.parse(text) as T; } catch { return text as unknown as T; } } }