Skip to content

Conversation

@JasonWang1124
Copy link

Summary

Add a new MCP tool dm_to_another that allows sending direct messages to
other users, complementing the existing dm_self tool.

Fixes #461

Changes

  • Add DMToAnotherArgs struct with user_id, username, message, and
    attachments fields
  • Register dm_to_another tool in getPostTools()
  • Implement toolDMToAnother method using CreateDirectChannel API
  • Support finding target user by either user_id or username

Implementation Details

The implementation follows the same pattern as dm_self:

  1. Find target user by user_id (using GetUser) or username (using
    GetUserByUsername)
  2. Create or get existing DM channel using
    CreateDirectChannel(currentUser.Id, targetUser.Id)
  3. Create the post in the DM channel with appropriate props
    (from_webhook, ai_generated_by)

Example Usage

{"username": "john.doe", "message": "Hello!"}

or

{"user_id": "abc123xyz456", "message": "Meeting reminder"}

Testing

- Tested sending DM to another user by username ✅
- Tested sending DM to another user by user_id ✅
- Verified bot label is displayed (consistent with dm_self) ✅

Add `dm_to_another` MCP tool to send direct messages to other users

TBD-JasonWang and others added 3 commits December 9, 2025 21:06
- Add DMToAnotherArgs struct with user_id, username, message, attachments fields
- Register dm_to_another tool in getPostTools()
- Implement toolDMToAnother method using CreateDirectChannel API
- Support finding target user by either user_id or username

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add get_dm_channel MCP tool to get/create DM channel by user_id or username
- Improve toolReadChannel to handle DM/Group channels that have no team
- Display appropriate labels for Direct Message and Group Message channels

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

Feature Request: Add dm_to_another tool for sending DMs to other users

2 participants