mattermost

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Mattermost CLI (
mm
)

Mattermost CLI(
mm

Read and search Mattermost from the command line. JSON output by default,
--human
for markdown.
从命令行读取和搜索Mattermost内容。默认输出JSON格式,使用
--human
参数可输出markdown格式。

Setup

安装配置

Check if
mm
is already available:
bash
mm whoami
If that works, skip to "Start here" below.
If
mm
is not found, install it. Pick whichever works in your environment:
bash
pip install mattermost-cli    # adds `mm` to PATH
检查
mm
是否已可用:
bash
mm whoami
如果命令正常执行,直接跳至下方的「入门」部分。
如果未找到
mm
,请进行安装。选择适合你环境的方式:
bash
pip install mattermost-cli    # 将`mm`添加至PATH

or

pipx install mattermost-cli # isolated global install
pipx install mattermost-cli # 隔离式全局安装

or

uvx --from mattermost-cli mm # run without installing (needs uvx)

Then authenticate (one-time):

```bash
mm login --url https://your.mattermost.server
mm whoami   # verify
The login command will prompt for credentials interactively. If your server supports Personal Access Tokens (Profile > Security > Personal Access Tokens in the Mattermost UI), you can skip the prompt:
bash
mm login --url https://your.mattermost.server --token YOUR_TOKEN
For environment variables, multiple servers, and troubleshooting, see references/setup.md.
uvx --from mattermost-cli mm # 无需安装直接运行(需要uvx)

然后进行一次性身份验证:

```bash
mm login --url https://your.mattermost.server
mm whoami   # 验证登录状态
登录命令会交互式提示输入凭据。如果你的服务器支持个人访问令牌(在Mattermost界面中进入「个人资料 > 安全 > 个人访问令牌」),可跳过提示直接登录:
bash
mm login --url https://your.mattermost.server --token YOUR_TOKEN
关于环境变量、多服务器配置和故障排查,请查看references/setup.md

Start here:
mm overview

入门:
mm overview

Always run this first. It returns mentions, unread channels, and active channels in a single call.
bash
mm overview              # last 6 hours (default)
mm overview --since 1d   # last 24 hours
The response has three sections:
  • mentions - posts that @-mention you, with root message context when it's a reply
  • unread - channels with unread messages, sorted by count
  • active_channels - channels with recent posts, sorted by recency
Each entry includes a
ref
field you can pass directly to other commands.
请先运行此命令。它会一次性返回提及提醒、未读频道和活跃频道信息。
bash
mm overview              # 最近6小时(默认)
mm overview --since 1d   # 最近24小时
响应包含三个部分:
  • mentions - 提及你的帖子,如果是回复则包含根消息上下文
  • unread - 包含未读消息的频道,按未读消息数量排序
  • active_channels - 有近期帖子的频道,按更新时间排序
每个条目都包含一个
ref
字段,可直接传递给其他命令使用。

Reading messages

读取消息

bash
mm messages <channel>                   # last 30 messages, chronological
mm messages <channel> --since 2h        # messages from last 2 hours
mm messages <channel> --threads         # thread index: root + reply count + last reply
mm messages @username                   # DMs with someone
<channel>
accepts a name (
off-topic
),
@username
for DMs, or a channel ID (for group DMs from overview output).
bash
mm messages <channel>                   # 最近30条消息,按时间顺序排列
mm messages <channel> --since 2h        # 最近2小时的消息
mm messages <channel> --threads         # 线程索引:根消息 + 回复数 + 最新回复
mm messages @username                   # 与指定用户的私信
<channel>
可接受频道名称(如
off-topic
)、
@username
(用于私信)或频道ID(来自overview输出中的群组私信)。

Threads

对话线程

Every post includes a
thread_id
. Use it to read the full conversation:
bash
mm thread <thread_id>                   # root + last 9 replies
mm thread <thread_id> --limit 0         # entire thread
mm thread <thread_id> --since 1h        # just recent replies (root always included)
每条帖子都包含
thread_id
字段,可用于读取完整对话:
bash
mm thread <thread_id>                   # 根消息 + 最新9条回复
mm thread <thread_id> --limit 0         # 完整对话线程
mm thread <thread_id> --since 1h        # 仅显示近期回复(始终包含根消息)

Searching and mentions

搜索与提及提醒

bash
mm search "deployment issue"
mm search "from:alice in:devops after:2025-01-01"
mm mentions                             # @-mentions in last 24h
mm mentions --since 3d
Mentions for replies include a
root
field with the original message, so you know what "this" or "it" refers to without a follow-up call.
bash
mm search "deployment issue"
mm search "from:alice in:devops after:2025-01-01"
mm mentions                             # 最近24小时内的@提及提醒
mm mentions --since 3d
回复中的提及提醒包含
root
字段,即被回复的原始消息,因此无需额外调用即可了解“this”或“it”指代的内容。

Channel context

频道信息

bash
mm channel <name>                       # purpose, header, member/pinned count
mm pinned <channel>                     # important/pinned posts
mm members <channel>                    # who's here + online status
mm channels --since 6h                  # all channels with recent activity
mm channels --type dm                   # just DMs
bash
mm channel <name>                       # 频道用途、头部信息、成员/置顶帖子数量
mm pinned <channel>                     # 重要/置顶帖子
mm members <channel>                    # 频道成员及在线状态
mm channels --since 6h                  # 所有有近期活动的频道
mm channels --type dm                   # 仅显示私信频道

People

用户信息

bash
mm user @someone                        # profile, role, status, timezone
bash
mm user @someone                        # 用户资料、角色、状态、时区

Key JSON fields

核心JSON字段

Every post includes these fields so you can navigate without guesswork:
FieldWhat it's for
thread_id
Pass to
mm thread
to read full conversation
ref
On channel entries; pass to
mm messages
is_bot
/
bot_name
Webhook and bot posts are flagged automatically
root
On reply-mentions; the original message being replied to
is_reply
/
reply_count
Thread structure
reactions
Emoji counts like
{"+1": 3, "white_check_mark": 1}
Bot posts from webhooks automatically extract alert content from Slack-format attachments, so you see the actual alert text instead of empty messages.
每条帖子都包含以下字段,方便你无需猜测即可导航:
字段用途
thread_id
传递给
mm thread
命令以读取完整对话
ref
频道条目包含此字段;传递给
mm messages
命令
is_bot
/
bot_name
自动标记Webhook和机器人发布的帖子
root
回复提及提醒包含此字段;即被回复的原始消息
is_reply
/
reply_count
对话线程结构信息
reactions
表情计数,例如
{"+1": 3, "white_check_mark": 1}
来自Webhook的机器人帖子会自动从Slack格式的附件中提取告警内容,因此你看到的是实际告警文本而非空消息。

Further reading

拓展阅读

  • references/scenarios.md - real use cases: "what did I miss?", "summarize this channel", "is this resolved?", "find that thing someone said"
  • references/workflows.md - command sequences: morning triage, incident investigation, channel discovery
  • references/commands.md - full command reference with all options and flags
  • references/scenarios.md - 实际用例:“我错过了什么?”、“总结此频道内容”、“问题是否已解决?”、“找到某人说过的内容”
  • references/workflows.md - 命令序列:晨间巡检、事件调查、频道发现
  • references/commands.md - 完整命令参考,包含所有选项和参数