This Mattermost MCP server enables Claude to interact with your Mattermost instance through the Model Context Protocol. It provides tools for managing posts, channels, users, and reactions, with optional Neo4j action tracking for advanced analytics and recommendations.
The fastest way to get started is using Docker with the provided configuration:
git clone https://github.com/dakatan/mcp-mattermost.git
cd mcp-mattermost
cp env.example .env
# Edit .env with your configuration
docker-compose up -d
This will start both the MCP server and a Neo4j instance for action tracking.
docker build -t mcp-mattermost .
docker run -d \
--name mcp-mattermost \
-e MATTERMOST_URL="https://your-mattermost-instance.com" \
-e MATTERMOST_TOKEN="your-personal-access-token" \
-e NEO4J_URI="bolt://neo4j:7687" \
-e NEO4J_USERNAME="neo4j" \
-e NEO4J_PASSWORD="your_password" \
mcp-mattermost
Variable | Required | Description |
---|---|---|
MATTERMOST_URL |
Yes | Your Mattermost instance URL |
MATTERMOST_TOKEN |
Yes | Personal access token for Mattermost |
NEO4J_URI |
No | Neo4j connection URI (for action tracking) |
NEO4J_USERNAME |
No | Neo4j username |
NEO4J_PASSWORD |
No | Neo4j password |
CURSOR_USER_ID |
No | User ID for Cursor integration |
CURSOR_USER_NAME |
No | User name for Cursor integration |
CURSOR_USER_EMAIL |
No | User email for Cursor integration |
CURSOR_USER_TEAM |
No | Team name for Cursor integration |
npm install
# Required: Mattermost configuration
export MATTERMOST_URL="https://your-mattermost-instance.com"
export MATTERMOST_TOKEN="your-personal-access-token"
# Optional: Neo4j Action Tracking
export NEO4J_URI="bolt://localhost:7687"
export NEO4J_USERNAME="neo4j"
export NEO4J_PASSWORD="your_password"
# Optional: Cursor Integration (for user identity)
export CURSOR_USER_ID="your_user_id"
export CURSOR_USER_NAME="Your Name"
export CURSOR_USER_EMAIL="[email protected]"
export CURSOR_USER_TEAM="Your Team"
npm run build
npm start
If you want to enable advanced action tracking and analytics:
The docker-compose.yml
file includes a Neo4j service that's automatically configured:
docker-compose up neo4j -d
Neo4j will be available at:
Search posts with advanced modifiers support.
Parameters:
terms
(string): Search term with optional modifierspage
(number, optional): Page number for paginationperPage
(number, optional): Number of posts per pageSearch Modifiers:
from:username
- Find posts from specific usersin:channel
- Find posts in specific channelsbefore:YYYY-MM-DD
- Find posts before a dateafter:YYYY-MM-DD
- Find posts after a dateon:YYYY-MM-DD
- Find posts on a specific date-term
- Exclude posts containing the term"exact phrase"
- Search for exact phrasesterm*
- Wildcard search#hashtag
- Search for hashtagsExample:
{
"terms": "meeting in:town-square from:john after:2023-01-01",
"page": 0,
"perPage": 50
}
Create a new post in a channel.
Parameters:
channelId
(string): Target channel IDmessage
(string): Message contentrootId
(string, optional): Reply to this post IDGet posts by their IDs.
Parameters:
postId
(string): Comma-separated list of post IDsGet unread posts in a channel for the current user.
Parameters:
channelId
(string): Channel IDGet all posts in a thread.
Parameters:
rootId
(string): Thread parent post IDperPage
(number, optional): Number of posts per pagefromPost
(string, optional): Start from this post IDPin or unpin a post to/from a channel.
Parameters:
postId
(string): Post ID to pin/unpinGet all pinned posts in a channel.
Parameters:
channelId
(string): Channel IDSearch channels by term.
Parameters:
term
(string): Search termpage
(number, optional): Page numberperPage
(number, optional): Number of channels per pageGet channels by ID or name.
Parameters:
channelId
(string, optional): Comma-separated channel IDsname
(string, optional): Comma-separated channel namesGet channels that the current user is a member of.
Parameters: None
Get users by username or user ID.
Parameters:
username
(string, optional): Comma-separated usernamesuserId
(string, optional): Comma-separated user IDsSearch users by term.
Parameters:
term
(string): Search termAdd emoji reactions to a post.
Parameters:
postId
(string): Target post IDemojiName
(string): Comma-separated emoji namesRemove emoji reactions from a post.
Parameters:
postId
(string): Target post IDemojiName
(string): Comma-separated emoji namesGet all reactions for a post.
Parameters:
postId
(string): Post IDFind actions similar to the current one based on MCP type, action type, and parameters.
Parameters:
mcpType
(string): Type of MCP (Mattermost, DynamoDB, Jira, etc.)actionType
(string): Type of action being performedparameters
(object): Parameters of the actionlimit
(number, optional): Maximum number of similar actions to return (default: 5)Example:
{
"mcpType": "Mattermost",
"actionType": "post_creation",
"parameters": {
"channelId": "channel123"
},
"limit": 10
}
Get a user's action history.
Parameters:
userId
(string): ID of the userlimit
(number, optional): Maximum number of actions to return (default: 20)Suggest the next action based on historical patterns.
Parameters:
userId
(string): ID of the usermcpType
(string): Type of MCPcurrentActionType
(string): Type of the current actioncurrentParameters
(object): Parameters of the current actionFind a user by email in the action tracking system.
Parameters:
email
(string): Email of the user to findenv
(string): Environment ('uat' or 'prod')To use this server with Cursor, add this to your cursor_desktop_config.json
:
{
"mcpServers": {
"mattermost": {
"command": "node",
"args": ["/path/to/mcp-mattermost/build/index.js"],
"env": {
"MATTERMOST_URL": "https://your-mattermost-instance.com",
"MATTERMOST_TOKEN": "your-personal-access-token",
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your_password",
"CURSOR_USER_ID": "your_user_id",
"CURSOR_USER_NAME": "Your Name",
"CURSOR_USER_EMAIL": "[email protected]",
"CURSOR_USER_TEAM": "Your Team"
},
"includeAuth": true,
"authHeaders": {
"cursor-auth": "${BASE64_ENCODED_USER_INFO}"
}
}
}
}
If you're running the server in Docker, use this configuration:
{
"mcpServers": {
"mattermost": {
"command": "docker",
"args": ["exec", "mcp-mattermost", "node", "build/index.js"],
"env": {
"CURSOR_USER_ID": "your_user_id",
"CURSOR_USER_NAME": "Your Name",
"CURSOR_USER_EMAIL": "[email protected]",
"CURSOR_USER_TEAM": "Your Team"
},
"includeAuth": true
}
}
}
The server uses lazy initialization, so it will start successfully even if Mattermost is unavailable. Connection errors will only occur when tools are invoked.
If Neo4j action tracking fails to connect:
docker-compose logs neo4j
)Common Docker problems:
mcp
(uid 1001)docker-compose
or set env vars correctlyTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mattermost" '{"command":"node","args":["/path/to/mcp-mattermost/build/index.js"],"env":{"MATTERMOST_URL":"https://your-mattermost-instance.com","MATTERMOST_TOKEN":"your-personal-access-token","NEO4J_URI":"bolt://localhost:7687","NEO4J_USERNAME":"neo4j","NEO4J_PASSWORD":"your_password","CURSOR_USER_ID":"your_user_id","CURSOR_USER_NAME":"Your Name","CURSOR_USER_EMAIL":"[email protected]","CURSOR_USER_TEAM":"Your Team"},"includeAuth":true,"authHeaders":{"cursor-auth":"${BASE64_ENCODED_USER_INFO}"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mattermost": {
"command": "node",
"args": [
"/path/to/mcp-mattermost/build/index.js"
],
"env": {
"MATTERMOST_URL": "https://your-mattermost-instance.com",
"MATTERMOST_TOKEN": "your-personal-access-token",
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your_password",
"CURSOR_USER_ID": "your_user_id",
"CURSOR_USER_NAME": "Your Name",
"CURSOR_USER_EMAIL": "[email protected]",
"CURSOR_USER_TEAM": "Your Team"
},
"includeAuth": true,
"authHeaders": {
"cursor-auth": "${BASE64_ENCODED_USER_INFO}"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mattermost": {
"command": "node",
"args": [
"/path/to/mcp-mattermost/build/index.js"
],
"env": {
"MATTERMOST_URL": "https://your-mattermost-instance.com",
"MATTERMOST_TOKEN": "your-personal-access-token",
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your_password",
"CURSOR_USER_ID": "your_user_id",
"CURSOR_USER_NAME": "Your Name",
"CURSOR_USER_EMAIL": "[email protected]",
"CURSOR_USER_TEAM": "Your Team"
},
"includeAuth": true,
"authHeaders": {
"cursor-auth": "${BASE64_ENCODED_USER_INFO}"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect