Skip to content

feat(mcp): expose chatroom ID in get_chat_history/get_chat_images headers#142

Open
crimsonsky1 wants to merge 1 commit into
ylytdeng:mainfrom
crimsonsky1:feat/expose-chatroom-id-in-header
Open

feat(mcp): expose chatroom ID in get_chat_history/get_chat_images headers#142
crimsonsky1 wants to merge 1 commit into
ylytdeng:mainfrom
crimsonsky1:feat/expose-chatroom-id-in-header

Conversation

@crimsonsky1

Copy link
Copy Markdown

Problem

When multiple groups share a name prefix (e.g. 18福特Fusion_211 appears in 3 rental-period groups), passing the short display name to downstream tools like decode_image causes resolve_username() to match the wrong group — typically an older one that doesn't contain the target local_id.

Solution

Expose the resolved internal username (chatroom ID like xxx@chatroom or wxid_xxx) in the output headers of get_chat_history and get_chat_images. Callers can then reuse the exact ID for subsequent tool calls, avoiding fuzzy-match ambiguity.

Changes

  • get_chat_history: group chats now show [群聊, id=xxx@chatroom]; non-group chats show [id=wxid_xxx] when username differs from display_name
  • get_chat_images: header includes , id=xxx when username differs from display_name

Before / After

# Before
赵松 的消息记录(返回 13 条,offset=0, limit=50)
18福特Fusion_211 05/18 的消息记录(返回 14 条,...) [群聊]

# After  
赵松 的消息记录(返回 13 条,offset=0, limit=50) [id=wxid_xxx]
18福特Fusion_211 05/18 的消息记录(返回 14 条,...) [群聊, id=26121425923@chatroom]

The IDs can be passed directly back to any MCP tool's chat_name parameter — resolve_username() already recognizes @chatroom and wxid_ patterns and passes them through without fuzzy matching (line 501).

No behavioral change for tools that receive the exact display name.

When multiple groups share a name prefix (e.g. "18福特Fusion_211" appears
in 3 different rental-period groups), passing the short name to downstream
tools like decode_image causes resolve_username() to match the wrong group.

This commit adds the resolved internal ID to the output headers of
get_chat_history and get_chat_images so callers can reuse the exact ID
for subsequent tool calls, eliminating fuzzy-match ambiguity.

- get_chat_history: group chats show `[群聊, id=xxx@chatroom]`;
  non-group chats show `[id=wxid_xxx]` when username differs from display name
- get_chat_images: header includes `id=xxx` when username differs

Co-Authored-By: Claude Opus 4.6 (1M context) <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