update_group_subject
Changes the subject/name of a WhatsApp group using session and group IDs. Enables programmatic renaming of group chats.
Instructions
Change the name/subject of a WhatsApp group
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID | |
| groupId | Yes | Group ID | |
| subject | Yes | New group name/subject |
Implementation Reference
- src/index.ts:18-18 (registration)Registers all group tools (including update_group_subject) via registerGroupTools(server).
registerGroupTools(server); - src/tools/groups.ts:5-5 (registration)Exported function that registers group tools on the McpServer instance.
export function registerGroupTools(server: McpServer) { - src/tools/groups.ts:170-188 (handler)Handler for 'update_group_subject' tool: sends PUT request to /sessions/{sessionId}/groups/{groupId} with new subject in body.
server.registerTool( "update_group_subject", { description: "Change the name/subject of a WhatsApp group", inputSchema: { sessionId: z.string().describe("Session ID"), groupId: z.string().describe("Group ID"), subject: z.string().describe("New group name/subject"), }, }, async ({ sessionId, groupId, subject }) => { const data = await openwaClient({ method: "PUT", path: `/sessions/${sessionId}/groups/${groupId}`, body: { subject }, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/tools/groups.ts:174-178 (schema)Input schema for update_group_subject: sessionId (string), groupId (string), subject (string).
inputSchema: { sessionId: z.string().describe("Session ID"), groupId: z.string().describe("Group ID"), subject: z.string().describe("New group name/subject"), }, - src/client.ts:10-35 (helper)Generic HTTP client used by the handler to call the OpenWA API.
export async function openwaClient<T = unknown>(opts: RequestOptions): Promise<T> { const url = `${BASE_URL}${opts.path}`; const headers: Record<string, string> = { "Content-Type": "application/json", "X-API-Key": API_KEY, }; const res = await fetch(url, { method: opts.method, headers, body: opts.body ? JSON.stringify(opts.body) : undefined, }); const text = await res.text(); if (!res.ok) { throw new Error(`OpenWA API ${res.status}: ${text}`); } try { return JSON.parse(text) as T; } catch { return text as T; } }