Mattermost

io.github.toffguy77由 GitHub 账号 toffguy77 发布v1.1.0更新于 Nov 3, 2026

Mattermost:读取未读消息、提及、频道和讨论串;可选择开启发帖、编辑和表情回应

AI 翻译由 AI 模型根据下方的原文描述翻译,可能有误。

原文描述

Mattermost: read unreads, mentions, channels and threads; opt-in posting, edits, reactions

已验证STDIO仅桌面

概览

Mattermost 的本地 MCP 服务;无需登录;STDIO;15 个工具。

暂无 AI 概览:以下信息来自注册中心条目和服务本身。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mattermost,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mattermost-mcp

[test] [PyPI] [License: MIT]

[Mattermost MCP server]

A Model Context Protocol server for Mattermost. It lets an AI agent (Claude, Cursor, VS Code, any MCP client) catch up on your unreads and mentions, read channels, threads and DMs, and search. If you switch write mode on, the agent can also post, reply, send DMs, edit its own messages and react.

  • Read-only by default. Write tools are not even registered until you set MATTERMOST_ENABLE_WRITE=1. Even then, the agent can only edit posts written by your own account.
  • Sees what you see. Unread counts match the client badge (muted channels are skipped, collapsed-thread counts are used) and sidebar categories work as filters. Mentions from muted channels are still shown.
  • Works where personal access tokens don't. Use a personal access token (PAT) or bot token if you can. If an admin has disabled PATs (common with SSO), run mattermost-mcp-server login: sign in once in a browser window and the server picks up the session cookies itself, and picks them up again when they expire.
  • Fast. Channel metadata is fetched once, across teams in parallel, and cached briefly. No per-channel requests.

Quick start

  1. Create a personal access token in Mattermost: Profile → Security → Personal Access Tokens → Create Token. If that section is missing, an admin must enable System Console → Integrations → Integration Management → Enable Personal Access Tokens, or skip the token and sign in with your browser instead.
  2. Install uv.
  3. Add the server to your client.

Claude Code

sh
claude mcp add mattermost \  -e MATTERMOST_URL=https://mattermost.example.com \  -e MATTERMOST_ACCESS_TOKEN=your-token \  -- uvx mattermost-mcp-server

Claude Desktop (claude_desktop_config.json), Cursor (~/.cursor/mcp.json) and other clients that use mcpServers:

json
{  "mcpServers": {    "mattermost": {      "command": "uvx",      "args": ["mattermost-mcp-server"],      "env": {        "MATTERMOST_URL": "https://mattermost.example.com",        "MATTERMOST_ACCESS_TOKEN": "your-token"      }    }  }}

VS Code (.vscode/mcp.json):

json
{  "inputs": [    { "type": "promptString", "id": "mm-token", "description": "Mattermost access token", "password": true }  ],  "servers": {    "mattermost": {      "command": "uvx",      "args": ["mattermost-mcp-server"],      "env": {        "MATTERMOST_URL": "https://mattermost.example.com",        "MATTERMOST_ACCESS_TOKEN": "${input:mm-token}"      }    }  }}

Then try asking: "What did I miss in Mattermost today?" or "Summarize the thread about the release in #engineering."

To let the agent post, add "MATTERMOST_ENABLE_WRITE": "1" to env (see Write mode).

Tools

ToolKindWhat it does
get_unreadreadUnread and mention counts per channel; skips muted channels by default, like the client badge
get_mentionsreadPosts that mention you, newest first; since, limit
list_channelsreadYour channels with unread_count, mute state and sidebar category; filter by team, category, DMs, muted
get_channel_postsreadRecent posts in a channel; since (ISO 8601) or before (post ID) to page back
get_threadreadA root post and all its replies
search_postsreadFull-text search with Mattermost syntax (from:, in:, after:…), optionally scoped to one channel or a sidebar category; skips muted channels by default
get_direct_messagesreadDM history with a user; since, before
get_userreadA user's profile by username
search_usersreadFind users by name, username or email prefix
get_mereadYour profile, the auth mode, and whether write mode is on
list_teamsreadYour teams
get_postreadOne post by ID
get_channelreadA channel by ID or by name (town-square), with header and purpose
get_pinned_postsreadPinned posts of a channel
get_file_inforeadName, type and size of an attached file (content is not downloaded)
create_postwritePost in a channel, or reply in a thread with root_id
send_direct_messagewriteDM a user by username
update_postwriteEdit one of your own posts; refuses anyone else's
add_reactionwriteReact with an emoji (thumbsup or :thumbsup:)
remove_reactionwriteRemove your reaction; no error if it was not there

Every tool carries MCP annotations (readOnlyHint, destructiveHint, idempotentHint), so clients can auto-approve reads and ask before writes. Nothing can delete posts, change channels or perform admin actions.

Write mode

Write mode is off unless MATTERMOST_ENABLE_WRITE is 1, true, yes or on. When it is off:

  • the five write tools are not registered, so the model never sees them;
  • the HTTP client refuses every request that is not a GET or one of the read-only POSTs (user lookup, user search, post search), before anything is sent.

The one server-side effect of read-only mode is the same as in any Mattermost client: get_direct_messages with someone you have never messaged creates the (empty) DM channel between you.

When write mode is on, update_post checks the post's author and refuses any post that is not yours, even if your account has permission to edit other people's posts. Posts are written as the authenticated user (or bot), so consider a dedicated bot account for agents that post on their own.

Configuration

VariableDefaultMeaning
MATTERMOST_URL— (required)Base URL of your server, e.g. https://mattermost.example.com
MATTERMOST_ACCESS_TOKEN—Personal access token or bot token; selects token auth
MATTERMOST_ENABLE_WRITEoff1 enables the write tools
MATTERMOST_AUTH_MODEautotoken or cookie, to force a mode (see below)
MATTERMOST_TOKEN—Cookie auth: value of the MMAUTHTOKEN cookie
MATTERMOST_CSRF—Cookie auth: value of the MMCSRF cookie; required for write tools
MATTERMOST_USER_ID—Cookie auth: value of the MMUSERID cookie (optional)
MATTERMOST_AUTO_LOGINoff1 opens the browser sign-in automatically when the saved session expires
MATTERMOST_LOGIN_TIMEOUT300Seconds to wait for an automatic sign-in
MATTERMOST_BROWSERautoPath of the Chromium-family browser used by login
MATTERMOST_BROWSER_ARGS—Extra browser flags for login, e.g. --proxy-server=…
MATTERMOST_BROWSER_PROFILE~/.config/mattermost-mcp/browser-profileSign-in browser profile (mode 0700)
MATTERMOST_SESSION_FILE~/.config/mattermost-mcp/session.envWhere login saves the session (mode 0600)
MATTERMOST_CACHE_TTL60Seconds to cache channel metadata; 0 disables the cache
MATTERMOST_TRUST_ENV10 ignores HTTP(S)_PROXY/ALL_PROXY and connects to Mattermost directly
MATTERMOST_AUTH_HELP—Extra text appended to the 401 error, e.g. how credentials are rotated in your setup
MATTERMOST_KEYCHAIN_SERVICEmattermost-mcpKeychain service name (see Credential sources)
MATTERMOST_COOKIE_HOSToffCookie host: ssh alias, or local
MATTERMOST_COOKIE_PATH.config/mattermost-mcp/cookie.envCookie host: file path, relative to $HOME on the host
MATTERMOST_COOKIE_CACHE~/.cache/mattermost-mcp/cookie.cacheCookie host: local cache file (mode 0600)
MATTERMOST_COOKIE_TTL900Cookie host: cache lifetime, seconds
MATTERMOST_COOKIE_SSH_TIMEOUT10Cookie host: ssh connect timeout, seconds

Choosing the auth mode. If MATTERMOST_AUTH_MODE is unset, the first credential source that has any credential decides. The sources are checked in order: env, then cookie host, then the saved login session, then keychain. MATTERMOST_ACCESS_TOKEN in that source means token mode. MATTERMOST_TOKEN alone means cookie mode. A lower-priority source never overrides a higher one.

Sign in with your browser

No personal access tokens on your server? Sign in once the way you always do (password, SSO, MFA), and the server uses your session:

sh
uvx mattermost-mcp-server login --url https://mattermost.example.com

A browser window opens at your server's login page and closes by itself as soon as you are signed in. Any installed Chrome, Chromium, Edge or Brave works; set MATTERMOST_BROWSER to use a specific one. The session cookies are checked against the server and saved to ~/.config/mattermost-mcp/session.env (mode 0600). From then on the server needs no credentials in its configuration at all:

sh
claude mcp add mattermost -- uvx mattermost-mcp-server

Other ways to sign in:

sh
mattermost-mcp-server login --password       # username/email + password (+ MFA code); the password is not storedmattermost-mcp-server login --from-firefox   # reuse the session of a Firefox where you are signed inmattermost-mcp-server status                 # which server, user and credential source is in usemattermost-mcp-server logout                 # revoke and delete the saved session (--forget-browser: also the browser profile)

When the session expires. Sessions expire after the time your admin configured. Run login again; running servers pick the new session up on their next call, without a restart. With MATTERMOST_AUTO_LOGIN=1 in the server's env, the server opens the sign-in window itself when it gets a 401. The browser profile remembers your identity provider, so with SSO this often completes without typing anything. Several running servers share one window.

The sign-in browser uses its own profile in ~/.config/mattermost-mcp/browser-profile, separate from your everyday browser. On macOS and Linux the server talks to it over a private pipe, not a network port.

Cookie auth

To use session cookies directly, without login: log in to Mattermost in a browser, open DevTools → Application → Cookies, and copy MMAUTHTOKEN, MMCSRF and (optionally) MMUSERID into MATTERMOST_TOKEN, MATTERMOST_CSRF and MATTERMOST_USER_ID. This is also the way to go when a reverse proxy strips the Authorization header.

Session cookies expire. When they do, tool calls fail with a 401 error. Put fresh cookies wherever the server reads them from, then restart it, because env is read only once. If something rotates cookies for you, describe it in MATTERMOST_AUTH_HELP so the agent knows what to do.

Credential sources

The server resolves each field separately. The first source that has a value wins:

  1. Environment variables, as above.

  2. Cookie host (off by default). A plain KEY=VALUE file with the same variable names, kept on another machine and read over ssh. Use this when one machine rotates the credential and others just consume it. The result is cached locally. On a 401 the server pulls the file again and retries once. ssh runs with BatchMode=yes, so a locked key fails fast instead of hanging the MCP handshake, and the reason goes to stderr. The file may only supply MATTERMOST_URL, MATTERMOST_ACCESS_TOKEN, MATTERMOST_TOKEN, MATTERMOST_CSRF and MATTERMOST_USER_ID. Nothing else is read from it, not even the auth or write mode.

  3. Saved session from mattermost-mcp-server login. It is used only as a whole (URL, cookies and CSRF together), only in cookie mode, and only when it belongs to the same server as any MATTERMOST_URL you set.

  4. OS keychain: accounts url, access_token, token, csrf and user_id under the service MATTERMOST_KEYCHAIN_SERVICE.

    sh
    # macOSsecurity add-generic-password -s mattermost-mcp -a url          -w https://mattermost.example.comsecurity add-generic-password -s mattermost-mcp -a access_token -w <personal access token># Linux (pass)pass insert mattermost-mcp/urlpass insert mattermost-mcp/access_token

Troubleshooting

  • Mattermost rejected the access token (401): the token was revoked or mistyped. Create a new one, or check whether your account is still allowed to use personal access tokens.
  • Mattermost rejected the session cookies (401): the browser session expired. Run mattermost-mcp-server login again (or set MATTERMOST_AUTO_LOGIN=1). If you set the cookies by hand, copy fresh ones and restart the server.
  • No Chromium-family browser found: install Chrome, Chromium, Edge or Brave, point MATTERMOST_BROWSER at one, or use login --password or login --from-firefox.
  • Write tools in cookie mode need the MMCSRF cookie: set MATTERMOST_CSRF. Mattermost requires it for any change made with cookie auth.
  • write mode is disabled: set MATTERMOST_ENABLE_WRITE=1 and restart the client.
  • Requests time out behind a corporate proxy: the server honours HTTPS_PROXY/ALL_PROXY, including SOCKS. If that proxy should not be used for Mattermost, set MATTERMOST_TRUST_ENV=0.
  • Nothing happens in Claude Desktop: GUI apps do not inherit your shell PATH. Use the full path to uvx (which uvx) as command.

Development

sh
git clone https://github.com/toffguy77/mattermost-mcp.gitcd mattermost-mcpuv syncuv run pytestuv run ruff check

Run your local checkout from a client with uv run --project /path/to/mattermost-mcp mattermost-mcp. python -m mattermost_mcp works too. The tests never touch the network or ssh: HTTP is mocked with respx. See CONTRIBUTING.md, CHANGELOG.md and SECURITY.md.

License

MIT

来源:README.md,提交 66f7765

工具

15

list_channels

List Channels

List all Mattermost channels the authenticated user is a member of.

输入参数team_idcategoryinclude_dminclude_muted

get_channel_posts

Get Channel Posts

Get recent posts from a Mattermost channel, newest first.

输入参数limitsincebeforechannel_id必填

get_thread

Get Thread

Get a post and all its replies.

输入参数post_id必填

search_posts

Search Posts

Full-text search across Mattermost posts, newest first. Supports Mattermost search syntax (from:username, in:channel-name, before:/after:/on:YYYY-MM-DD, "exact phrase", -excluded). By default skips channels the user has muted in the sidebar — pass include_muted=True to widen the search.

输入参数limitquery必填categorychannel_idinclude_muted

get_direct_messages

Get Direct Messages

Get direct message history with a specific user, newest first.

输入参数limitsincebeforeusername必填

get_mentions

Get Mentions

Get posts that mention the authenticated user, newest first. Mentions in muted channels are included by default — mute hides unread badges, not @-mentions. Pass include_muted=False to exclude them.

输入参数limitsinceinclude_muted

get_unread

Get Unread

Get unread counts and mention badges per channel. By default skips channels muted in the sidebar (same behavior as the client unread badge). Pass include_muted=True to see every unread.

输入参数categoryinclude_muted

get_user

Get User

Get a Mattermost user's profile by username.

输入参数username必填

get_me

Get Me

Get the authenticated user and what this server is allowed to do. Returns {id, username, first_name, last_name, email, status, nickname, position, auth_mode, write_enabled}. auth_mode is "token" or "cookie"; write_enabled tells whether posting/editing tools are available.

无需输入参数。

list_teams

List Teams

List the teams the authenticated user belongs to. Returns list of {id, name, display_name}.

无需输入参数。

get_post

Get Post

Get a single post by ID.

输入参数post_id必填

get_channel

Get Channel

Look up a channel by ID, or by its name (the URL slug, e.g. "town-square"). Pass channel_id, or name. With name alone, searches the channels you are a member of; add team_id or team_name to look up any channel in a team. Returns {id, name, display_name, type, team_id, header, purpose}.

输入参数nameteam_idteam_namechannel_id

search_users

Search Users

Find users by username, full name, nickname or email prefix.

输入参数term必填limit

get_pinned_posts

Get Pinned Posts

Get the posts pinned in a channel.

输入参数channel_id必填

get_file_info

Get File Info

Get metadata of a file attached to a post (see a post's file_ids). The file content is not downloaded.

输入参数file_id必填

版本历史

2
  1. v1.1.0最新Nov 3, 2026
  2. v1.0.0Oct 30, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分