Skip to content

fix: resolve contact names from address book instead of phone numbers#173

Open
FreakySurgeon wants to merge 1 commit intolharries:mainfrom
FreakySurgeon:fix/contact-name-resolution
Open

fix: resolve contact names from address book instead of phone numbers#173
FreakySurgeon wants to merge 1 commit intolharries:mainfrom
FreakySurgeon:fix/contact-name-resolution

Conversation

@FreakySurgeon
Copy link
Copy Markdown

@FreakySurgeon FreakySurgeon commented Feb 27, 2026

Summary

  • MCP server (whatsapp.py): get_sender_name() now reads contact names from the whatsmeow_contacts table (synced from the phone's address book) with priority full_name > first_name > push_name, instead of relying on the chats table which often only contains phone numbers
  • Handles standard @s.whatsapp.net JIDs, LID-based senders (common in group messages), and LID-to-phone mapping via whatsmeow_lid_map
  • Chat names, sender names, and contact search results all resolve to real names
  • Go bridge (main.go): GetChatName() no longer treats phone numbers as valid cached names — it re-resolves contacts when the stored name is numeric
  • New POST /api/refresh-contacts endpoint to backfill existing chat names from the whatsmeow contact store
  • Added exclude_groups parameter to list_chats MCP tool

Problem

When reading messages, all contacts were displayed as phone numbers (e.g. From: 0606060606) instead of their real names. The chats table in messages.db was populated with phone numbers because GetChatName() cached the first name found (often before contacts were synced), and never updated it.

Meanwhile, the real contact names from the phone's address book were available in whatsmeow_contacts (whatsapp.db) but never used.

Test plan

  • get_sender_name() resolves phone numbers to names from address book
  • LID-based senders in group messages resolve correctly
  • search_contacts() searches both whatsmeow contacts and chats table
  • list_chats() returns resolved names for individual contacts
  • /api/refresh-contacts backfills existing chat names from contacts
  • New messages store resolved names via improved GetChatName()

🤖 Generated with Claude Code

… numbers

The MCP server now reads contact names from whatsmeow_contacts (synced
from the phone's address book) instead of the chats table which often
only contained phone numbers. Handles standard JIDs, LID-based senders
(common in groups), and LID-to-phone mapping.

Go bridge: GetChatName() no longer treats phone numbers as valid cached
names, and a new /api/refresh-contacts endpoint backfills existing chats.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant