waha_get_chat_picture
Retrieve WhatsApp chat profile picture URLs with optional cache refresh for chat identification and management.
Instructions
Get the profile picture URL for a chat. Uses 24-hour cache by default.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID (format: number@c.us) | |
| refresh | No | Refresh from server instead of using cache (default: false) |
Implementation Reference
- src/index.ts:1577-1597 (handler)Primary MCP tool handler for 'waha_get_chat_picture'. Validates args, calls WAHAClient.getChatPicture(), formats and returns the picture URL response.const chatId = args.chatId; const refresh = args.refresh || false; if (!chatId) { throw new Error("chatId is required"); } const result = await this.wahaClient.getChatPicture({ chatId, refresh, }); return { content: [ { type: "text", text: `Chat picture URL for ${chatId}:\n${result.url}\n${refresh ? '(Refreshed from server)' : '(From 24h cache)'}`, }, ], }; }
- src/index.ts:327-345 (registration)Tool registration definition in ListToolsRequestSchema handler, including name, description, and input schema for validation.{ name: "waha_get_chat_picture", description: "Get the profile picture URL for a chat. Uses 24-hour cache by default.", inputSchema: { type: "object", properties: { chatId: { type: "string", description: "Chat ID (format: number@c.us)", }, refresh: { type: "boolean", description: "Refresh from server instead of using cache (default: false)", default: false, }, }, required: ["chatId"], }, },
- src/index.ts:1077-1078 (registration)Switch case registration in CallToolRequestSchema handler that routes calls to the tool handler function.case "waha_get_chat_picture": return await this.handleGetChatPicture(args);
- src/client/waha-client.ts:505-528 (helper)WAHAClient helper method that performs the actual HTTP GET request to the WAHA API endpoint /api/{session}/chats/{chatId}/picture to retrieve the chat picture URL.async getChatPicture(params: { chatId: string; refresh?: boolean; }): Promise<{ url: string }> { const { chatId, refresh } = params; if (!chatId) { throw new WAHAError("chatId is required"); } const queryParams: Record<string, any> = {}; if (refresh !== undefined) { queryParams.refresh = refresh; } const queryString = this.buildQueryString(queryParams); const endpoint = `/api/${this.session}/chats/${encodeURIComponent( chatId )}/picture${queryString}`; return this.request<{ url: string }>(endpoint, { method: "GET", }); }