#19265: feat(mattermost): Add directory adapter for channel/user name resolution
channel: mattermost
size: M
Cluster:
Mattermost Integration Enhancements
Closes #19264
Enables agents to send messages using channel names (e.g. `target: "infra"`) instead of 26-character Mattermost IDs.
## Changes
### `src/mattermost/directory.ts` (new)
- `listMattermostDirectoryGroups` — scans all enabled bot accounts (deduplicated by token), returns public + private channels
- `listMattermostDirectoryPeers` — returns team members via first available client
- Multi-account scanning ensures private channels are discoverable regardless of which bot the requesting agent uses
### `src/channel.ts`
- Added `directory` property with `listGroups`/`listPeers` + live variants
- Core's `DirectoryCache` handles caching; both variants call the same function
### `src/normalize.ts`
- Bare names return `undefined` → falls through to directory lookup
- Stricter `looksLikeId`: 26-char alnum + DM format (`id__id`)
## Testing
Tested live with 19 bot accounts across public and private channels.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds directory adapter for Mattermost to enable channel/user name resolution, allowing agents to send messages using friendly names instead of 26-character IDs.
**Major changes:**
- New `directory.ts` implements `listMattermostDirectoryGroups` and `listMattermostDirectoryPeers` with multi-account scanning for comprehensive channel discovery
- `normalize.ts` updated to return `undefined` for bare names, triggering directory lookup fallback
- `looksLikeMattermostTargetId` now uses strict 26-char alphanumeric pattern plus DM format validation
- `monitor.ts` improved to record pending history for messages from non-allowlisted senders, preserving conversation context for future `@mentions`
**Issues found:**
- Both directory functions ignore the `limit` parameter—other channel implementations (msteams, matrix, feishu) apply it via `.slice(0, limit)`
<h3>Confidence Score: 4/5</h3>
- Safe to merge after fixing the limit parameter handling
- Well-structured implementation following existing patterns from other channel adapters. The limit parameter bug is straightforward and doesn't affect core functionality—results will just be unbounded when limit is specified. The monitor.ts history recording logic is sound and the normalize.ts changes correctly enable directory fallback.
- Fix `limit` parameter handling in `extensions/mattermost/src/mattermost/directory.ts` before merging
<sub>Last reviewed commit: 67dc87d</sub>
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#12468: feat(mattermost): add read, search, and channel-list actions
by adamsbytes · 2026-02-09
78.4%
#20928: mattermost: add readMessages action for channel history
by hubertusgbecker · 2026-02-19
76.4%
#16570: feat(mattermost): add replyToMode threading support
by FBartos · 2026-02-14
76.4%
#19274: feat(mattermost): enable threaded replies in channels
by rockinyp · 2026-02-17
74.2%
#16622: fix(mattermost): record pending history for messages dropped by gro...
by oskarmodig · 2026-02-14
73.8%
#13089: fix(msteams): alias team config under channel conversation IDs for ...
by BradGroux · 2026-02-10
72.5%
#18657: feat(mattermost): add native slash command support (refresh)
by echo931 · 2026-02-16
72.4%
#21271: fix(commands): pass channel/capabilities/shell/os to runtime in com...
by evansantos · 2026-02-19
72.3%
#8024: fix(slack): resolve channel names via directory for cross-account m...
by emma-digital-assistant · 2026-02-03
71.8%
#19957: feat(mattermost): add interactive buttons support
by tonydehnke · 2026-02-18
70.9%