feat: add create_group and leave_group MCP tools#239
Open
jayeshkaithwas wants to merge 1 commit into
Open
Conversation
Adds two new tools so the MCP agent can manage groups, not just read/send into existing ones: - create_group(name, participants, is_community=False, community_parent_jid=""): Create a new group via whatsmeow.CreateGroup. Participants accept either bare phone numbers (country code, no '+') or full JIDs. Optionally creates a community parent or attaches the new group as a sub-group of an existing community. Persists the resulting chat into the local SQLite so it shows up in list_chats immediately. - leave_group(jid): Leave a group via whatsmeow.LeaveGroup. WhatsApp has no "delete group" primitive — this is the closest action. Bridge: new POST /api/create_group and /api/leave_group endpoints. MCP server: matching tools registered in main.py. README: tool list updated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7 tasks
BenGedi
added a commit
to BenGedi/whatsapp-mcp
that referenced
this pull request
May 30, 2026
Ports lharries#239. Adds create_group and leave_group end-to-end: Go HTTP handlers, Python wrappers, MCP tool registrations. Input validation returns 400; connection/network errors return 500. Upstream delta: context.Background() added to whatsmeow calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two new MCP tools so the agent can manage groups, not just read/send into existing ones.
create_group(name, participants, is_community=False, community_parent_jid="")— wrapswhatsmeow.CreateGroup. Participants accept either bare phone numbers (country code, no+) or full JIDs. The caller's own JID is added implicitly by WhatsApp, so it must not be included. Optionally creates a community parent (is_community=True) or attaches the new group as a sub-group of an existing community (community_parent_jid). Persists the resulting chat to the local SQLite so it shows up inlist_chatsright away.leave_group(jid)— wrapswhatsmeow.LeaveGroup. WhatsApp has no "delete group" primitive — this is the closest action; other members continue to see the group with you marked as left.Changes
whatsapp-bridge/main.go: new/api/create_groupand/api/leave_groupendpoints + their request/response types and handlers.whatsapp-mcp-server/whatsapp.py: matchingcreate_group/leave_groupHTTP helpers.whatsapp-mcp-server/main.py: tool registrations.README.md: tool list updated with the two new entries.No dependency bumps. No changes to existing tools or storage schema. Builds cleanly against the whatsmeow version pinned in
go.mod.Test plan
go buildclean against the existing pinned whatsmeow.python3 -m py_compileclean on both server files.POST /api/create_group, confirmed it appeared in WhatsApp on both ends and inlist_chats. Then left it viaPOST /api/leave_groupand confirmed the "left" event on the other device.Notes / open questions
name,participants, plus the two community knobs thatwhatsmeow.ReqCreateGroupalready exposes here). Happy to addannounce/locked/ephemeral/join_approval_requiredin a follow-up — they need a newer whatsmeow than the one currently pinned.create_groupwrites the new chat row directly to the bridge SQLite. WhatsApp's ownevents.JoinedGroupwould also do this asynchronously; doing it eagerly just makes the tool's response immediately visible to subsequentlist_chatscalls in the same MCP session. Open to dropping that line if you'd rather rely on the event path alone.🤖 Generated with Claude Code