Set Settings
set_settingsUpdate WhatsApp instance settings: control call rejection, group messages, online status, and message read preferences.
Instructions
Update settings for the pinned WhatsApp instance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rejectCall | No | Automatically reject incoming calls | |
| msgCall | No | Auto-reply message when rejecting calls | |
| groupsIgnore | No | Ignore messages from groups | |
| alwaysOnline | No | Always appear online | |
| readMessages | No | Automatically mark messages as read | |
| syncFullHistory | No | Sync full message history on connect | |
| readStatus | No | Automatically read status updates |
Implementation Reference
- src/tools/set-settings.ts:16-42 (handler)Main handler function for the 'set_settings' tool. Defines registerSetSettings which registers the tool with server, builds a payload from optional args (rejectCall, msgCall, groupsIgnore, alwaysOnline, readMessages, syncFullHistory, readStatus), and POSTs to /settings/set/{instanceName}. Returns the API response or an McpError on failure.
export function registerSetSettings(server: McpServer, client: EvolutionClient): void { server.registerTool( "set_settings", { title: "Set Settings", description: "Update settings for the pinned WhatsApp instance.", inputSchema: schema, }, async (args) => { try { const payload: Record<string, unknown> = {}; if (args.rejectCall !== undefined) payload["rejectCall"] = args.rejectCall; if (args.msgCall !== undefined) payload["msgCall"] = args.msgCall; if (args.groupsIgnore !== undefined) payload["groupsIgnore"] = args.groupsIgnore; if (args.alwaysOnline !== undefined) payload["alwaysOnline"] = args.alwaysOnline; if (args.readMessages !== undefined) payload["readMessages"] = args.readMessages; if (args.syncFullHistory !== undefined) payload["syncFullHistory"] = args.syncFullHistory; if (args.readStatus !== undefined) payload["readStatus"] = args.readStatus; const data = await client.post(`/settings/set/${client.instanceName}`, payload); 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/set-settings.ts:6-14 (schema)Input schema for the 'set_settings' tool using Zod. Defines 7 optional fields: rejectCall (boolean), msgCall (string), groupsIgnore (boolean), alwaysOnline (boolean), readMessages (boolean), syncFullHistory (boolean), readStatus (boolean).
const schema = { rejectCall: z.boolean().optional().describe("Automatically reject incoming calls"), msgCall: z.string().optional().describe("Auto-reply message when rejecting calls"), groupsIgnore: z.boolean().optional().describe("Ignore messages from groups"), alwaysOnline: z.boolean().optional().describe("Always appear online"), readMessages: z.boolean().optional().describe("Automatically mark messages as read"), syncFullHistory: z.boolean().optional().describe("Sync full message history on connect"), readStatus: z.boolean().optional().describe("Automatically read status updates"), }; - src/tools/index.ts:62-62 (registration)Import of registerSetSettings from './set-settings.js' in the tools index file.
import { registerSetSettings } from "./set-settings.js"; - src/tools/index.ts:135-135 (registration)Registration call to registerSetSettings(server, client) inside registerAllTools, wiring the tool to the MCP server.
registerSetSettings(server, client); - src/evolution-client.ts:1-60 (helper)EvolutionClient helper class used internally by the set_settings handler. Provides the post() method (line 24) that sends HTTP requests with API key, and the instanceName getter (line 16) used to construct the endpoint URL.
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; } } }