用于 Mattermost API 的 MCP 服务器,使 Claude 和其他 MCP 客户端能够与 Mattermost 工作区进行交互。
此 MCP 服务器提供了与 Mattermost 进行交互的工具,包括:
该服务器包含一个主题监控系统,可以:
mattermost_list_channels:列出工作区中的公共频道mattermost_get_channel_history:获取频道中的最近消息mattermost_post_message:向频道发布新消息mattermost_reply_to_thread:回复特定的消息线程mattermost_add_reaction:给消息添加表情反应mattermost_get_thread_replies:获取线程中的所有回复mattermost_run_monitoring:立即触发主题监控过程mattermost_get_users:获取工作区中的用户列表mattermost_get_user_profile:获取用户的详细资料信息git clone https://github.com/yourusername/mattermost-mcp.git
cd mattermost-mcp
npm install
配置服务器:
该仓库包含一个带有占位符值的 config.json 文件。为了您的实际配置,请创建一个 config.local.json 文件(该文件被 git 忽略),并填写您的真实凭证:
{
"mattermostUrl": "https://your-mattermost-instance.com/api/v4",
"token": "your-personal-access-token",
"teamId": "your-team-id",
"monitoring": {
"enabled": false,
"schedule": "*/15 * * * *",
"channels": ["town-square", "off-topic"],
"topics": ["tv series", "champions league"],
"messageLimit": 50
}
}
这种方法可以确保您的真实凭证不进入仓库,同时保持模板供他人使用。
构建服务器:
npm run build
npm start
监控系统可以通过以下选项进行配置:
enabled(布尔值):是否启用监控schedule(字符串):检查新消息的 cron 表达式(例如,“*/15 * * * *”表示每15分钟一次)channels(字符串数组):要监控的频道名称数组topics(字符串数组):要在消息中查找的主题数组messageLimit(数字):每次检查时分析的最近消息数量notificationChannelId(字符串,可选):通知发送的频道ID。如果没有提供,则系统将自动使用直接消息频道。userId(字符串,可选):在通知中提及的用户ID。如果没有提供,则系统将自动检测当前用户。要启用监控,请将 enabled 设置为 true 在您的 config.local.json 文件中。
您可以通过多种方式手动触发监控过程:
使用提供的脚本:
./run-monitoring-http.sh - 通过 HTTP 触发监控而不重启服务器(推荐)./run-monitoring.sh - 启动一个新的服务器实例并启用监控./trigger-monitoring.sh - 运行监控过程并退出(适用于 cron 作业)./view-channel-messages.js <channel-name> [count] - 查看频道中的最后几条消息./analyze-channel.js <channel-name> [count] - 分析频道中的消息统计./get-last-message.js <channel-name> - 获取频道中的最后一条消息使用命令行界面 (CLI):
run - 运行监控过程monitor - 与 run 相同check - 与 run 相同help - 显示可用命令exit - 关闭服务器使用 MCP 工具:
mattermost_run_monitoring 工具使用命令行标志:
--run-monitoring 标志启动服务器:npm start -- --run-monitoring
--exit-after-monitoring 在监控过程完成后退出:npm start -- --run-monitoring --exit-after-monitoring
mattermost_list_channelslimit(数字,默认:100,最大:200):返回的最大频道数page(数字,默认:0):分页的页码mattermost_get_channel_historychannel_id(字符串):频道的IDlimit(数字,默认:30):要检索的消息数page(数字,默认:0):分页的页码mattermost_post_messagechannel_id(字符串):要发布的频道IDmessage(字符串):要发布的消息文本mattermost_reply_to_threadchannel_id(字符串):包含线程的频道post_id(字符串):父消息的IDmessage(字符串):回复文本mattermost_add_reactionchannel_id(字符串):包含消息的频道post_id(字符串):要反应的消息IDemoji_name(字符串):没有冒号的表情名称mattermost_get_thread_replieschannel_id(字符串):包含线程的频道post_id(字符串):父消息的IDmattermost_get_userslimit(数字,默认:100,最大:200):返回的最大用户数page(数字,默认:0):分页的页码mattermost_get_user_profileuser_id(字符串):用户的ID在您的 claude_desktop_config.json 中添加以下内容:
{
"mcpServers": {
"mattermost": {
"command": "node",
"args": [
"/path/to/mattermost-mcp/build/index.js"
]
}
}
}
如果您遇到权限错误,请验证:
服务器暴露了用于远程控制的 HTTP 端点:
运行监控:http://localhost:3456/run-monitoring
检查状态:http://localhost:3456/status
您可以使用这些端点与 curl 或任何 HTTP 客户端:
# 触发监控
curl http://localhost:3456/run-monitoring
# 检查状态
curl http://localhost:3456/status
此脚本通过 HTTP 端点触发监控过程:
./run-monitoring-http.sh
这是推荐的手动触发监控的方式,因为它:
此脚本允许您查看任何频道中的最新消息:
# 查看频道中的消息(频道名称是必需的)
node view-channel-messages.js <channel-name>
# 查看特定数量的消息
node view-channel-messages.js <channel-name> <message-count>
# 示例:查看频道中的最后10条消息
node view-channel-messages.js general 10
该脚本将显示:
此脚本提供了频道中消息的详细统计:
# 分析频道中的消息(频道名称是必需的)
node analyze-channel.js <channel-name>
# 分析特定数量的消息
node analyze-channel.js <channel-name> <message-count>
# 示例:分析频道中的最后50条消息
node analyze-channel.js general 50
该脚本将显示:
此脚本仅检索频道中的最新消息:
# 获取频道中的最新消息(频道名称是必需的)
node get-last-message.js <channel-name>
# 示例:获取 general 频道中的最新消息
node get-last-message.js general
该脚本将显示:
此 MCP 服务器根据 MIT 许可证授权。