MCP Server for the Mattermost API, enabling Claude and other MCP clients to interact with Mattermost workspaces.
This MCP server provides tools for interacting with Mattermost, including:
The server includes a topic monitoring system that can:
mattermost_list_channels
: List public channels in the workspacemattermost_get_channel_history
: Get recent messages from a channelmattermost_post_message
: Post a new message to a channelmattermost_reply_to_thread
: Reply to a specific message threadmattermost_add_reaction
: Add an emoji reaction to a messagemattermost_get_thread_replies
: Get all replies in a threadmattermost_run_monitoring
: Trigger the topic monitoring process immediatelymattermost_get_users
: Get a list of users in the workspacemattermost_get_user_profile
: Get detailed profile information for a usergit clone https://github.com/yourusername/mattermost-mcp.git
cd mattermost-mcp
npm install
Configure the server:
The repository includes a config.json
file with placeholder values. For your actual configuration, create a config.local.json
file (which is gitignored) with your real credentials:
{
"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
}
}
This approach keeps your real credentials out of the repository while maintaining the template for others.
Build the server:
npm run build
npm start
The monitoring system can be configured with the following options:
enabled
(boolean): Whether monitoring is enabledschedule
(string): Cron expression for when to check for new messages (e.g., "*/15 * * * *" for every 15 minutes)channels
(string[]): Array of channel names to monitortopics
(string[]): Array of topics to look for in messagesmessageLimit
(number): Number of recent messages to analyze per checknotificationChannelId
(string, optional): Channel ID where notifications will be sent. If not provided, the system will automatically use a direct message channel.userId
(string, optional): Your user ID for mentions in notifications. If not provided, the system will automatically detect the current user.To enable monitoring, set enabled
to true
in your config.local.json
file.
You can trigger the monitoring process manually in several ways:
Using the provided scripts:
./run-monitoring-http.sh
- Triggers monitoring via HTTP without restarting the server (recommended)./run-monitoring.sh
- Starts a new server instance with monitoring enabled./trigger-monitoring.sh
- Runs the monitoring process and exits (useful for cron jobs)./view-channel-messages.js <channel-name> [count]
- View the last messages in a channel./analyze-channel.js <channel-name> [count]
- Analyze message statistics in a channel./get-last-message.js <channel-name>
- Get the last message from a channelUsing the command-line interface (CLI):
run
- Run the monitoring processmonitor
- Same as run
check
- Same as run
help
- Show available commandsexit
- Shutdown the serverUsing the MCP tool:
mattermost_run_monitoring
tool through the MCP interfaceUsing the command-line flags:
--run-monitoring
flag:npm start -- --run-monitoring
--exit-after-monitoring
to exit after the monitoring process completes:npm start -- --run-monitoring --exit-after-monitoring
mattermost_list_channels
limit
(number, default: 100, max: 200): Maximum number of channels to returnpage
(number, default: 0): Page number for paginationmattermost_get_channel_history
channel_id
(string): The ID of the channellimit
(number, default: 30): Number of messages to retrievepage
(number, default: 0): Page number for paginationmattermost_post_message
channel_id
(string): The ID of the channel to post tomessage
(string): The message text to postmattermost_reply_to_thread
channel_id
(string): The channel containing the threadpost_id
(string): ID of the parent messagemessage
(string): The reply textmattermost_add_reaction
channel_id
(string): The channel containing the messagepost_id
(string): Message ID to react toemoji_name
(string): Emoji name without colonsmattermost_get_thread_replies
channel_id
(string): The channel containing the threadpost_id
(string): ID of the parent messagemattermost_get_users
limit
(number, default: 100, max: 200): Maximum users to returnpage
(number, default: 0): Page number for paginationmattermost_get_user_profile
user_id
(string): The user's IDAdd the following to your claude_desktop_config.json
:
{
"mcpServers": {
"mattermost": {
"command": "node",
"args": [
"/path/to/mattermost-mcp/build/index.js"
]
}
}
}
If you encounter permission errors, verify that:
The server exposes HTTP endpoints for remote control:
Run Monitoring: http://localhost:3456/run-monitoring
Check Status: http://localhost:3456/status
You can use these endpoints with curl or any HTTP client:
# Trigger monitoring
curl http://localhost:3456/run-monitoring
# Check status
curl http://localhost:3456/status
This script triggers the monitoring process via the HTTP endpoint:
./run-monitoring-http.sh
This is the recommended way to trigger monitoring manually as it:
This script allows you to view the most recent messages in any channel:
# View messages in a channel (channel name is required)
node view-channel-messages.js <channel-name>
# View a specific number of messages
node view-channel-messages.js <channel-name> <message-count>
# Example: View the last 10 messages in a channel
node view-channel-messages.js general 10
The script will display:
This script provides detailed statistics about messages in a channel:
# Analyze messages in a channel (channel name is required)
node analyze-channel.js <channel-name>
# Analyze a specific number of messages
node analyze-channel.js <channel-name> <message-count>
# Example: Analyze the last 50 messages in a channel
node analyze-channel.js general 50
The script will display:
This script retrieves only the most recent message from a channel:
# Get the last message from a channel (channel name is required)
node get-last-message.js <channel-name>
# Example: Get the last message from the general channel
node get-last-message.js general
The script will display:
This MCP server is licensed under the MIT License.
{
"mcpServers": {
"mattermost": {
"env": {},
"args": [
"/path/to/mattermost-mcp/build/index.js"
],
"command": "node"
}
}
}
Seamless access to top MCP servers powering the future of AI integration.