A Model Context Protocol server for Mattermost, enabling Claude to interact with your Mattermost instance.
dakatan (tkdtkd0022@gmail.com)
- Post Management: Create, search, pin/unpin posts, and manage threads
- Channel Operations: Search and retrieve channel information
- User Management: Search and retrieve user information
- Reaction Management: Add, remove, and retrieve post reactions
- Action Recording: Automatically record all MCP actions in a Neo4j graph database
- Pattern Recognition: Find similar actions and usage patterns
- Smart Recommendations: Get action suggestions based on historical data
- Cross-MCP Analytics: Track relationships between different MCP systems
- User Identity Management: Link actions to specific users and teams
- Organizational Memory: Build a knowledge graph of team actions and workflows
The fastest way to get started is using Docker with the provided docker-compose.yml
:
- Clone the repository:
git clone https://github.com/dakatan/mcp-mattermost.git
cd mcp-mattermost
- Create environment file:
cp env.example .env
# Edit .env with your configuration
- Start the services:
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 |
- Install dependencies:
npm install
- Configure environment variables:
# 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="your@email.com"
export CURSOR_USER_TEAM="Your Team"
- (Optional) Initialize Neo4j schema for action tracking:
npm run build
npm run init-neo4j
- Build and start the server:
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:
- Browser interface: http://localhost:7474
- Bolt connection: bolt://localhost:7687
- Default credentials: neo4j/password (change via NEO4J_PASSWORD env var)
- Install Neo4j Desktop or use Neo4j AuraDB
- Create a new database
- Set the Neo4j environment variables as shown above
- Run the schema initialization:
npm run init-neo4j
This will create the necessary constraints and indexes:
CREATE CONSTRAINT IF NOT EXISTS FOR (user:User) REQUIRE user.id IS UNIQUE;
CREATE CONSTRAINT IF NOT EXISTS FOR (mcp:MCP) REQUIRE mcp.id IS UNIQUE;
CREATE CONSTRAINT IF NOT EXISTS FOR (action:Action) REQUIRE action.id IS UNIQUE;
CREATE INDEX IF NOT EXISTS FOR (user:User) ON (user.email);
CREATE INDEX IF NOT EXISTS FOR (user:User) ON (user.team);
CREATE INDEX IF NOT EXISTS FOR (action:Action) ON (action.type);
CREATE INDEX IF NOT EXISTS FOR (action:Action) ON (action.name);
CREATE FULLTEXT INDEX actionContext IF NOT EXISTS FOR (a:Action) ON EACH [a.name, a.type];
The MCP server uses lazy initialization to avoid connection failures during startup. The Mattermost client is only initialized when the first tool is invoked, allowing the server to start successfully even without immediate Mattermost connectivity.
When Neo4j is configured, the server automatically tracks:
- User Actions: All MCP tool invocations with user context
- Action Relationships: Links between different actions and services
- Usage Patterns: Historical data for recommendations and insights
- Cross-Service Data: Relationships between Mattermost and other MCP systems
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 page
Search 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 hashtags
Example:
{
"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 ID
Get posts by their IDs.
Parameters:
postId
(string): Comma-separated list of post IDs
Get unread posts in a channel for the current user.
Parameters:
channelId
(string): Channel ID
Get 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 ID
Pin or unpin a post to/from a channel.
Parameters:
postId
(string): Post ID to pin/unpin
Get all pinned posts in a channel.
Parameters:
channelId
(string): Channel ID
Search channels by term.
Parameters:
term
(string): Search termpage
(number, optional): Page numberperPage
(number, optional): Number of channels per page
Get channels by ID or name.
Parameters:
channelId
(string, optional): Comma-separated channel IDsname
(string, optional): Comma-separated channel names
Get 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 IDs
Search users by term.
Parameters:
term
(string): Search term
Add emoji reactions to a post.
Parameters:
postId
(string): Target post IDemojiName
(string): Comma-separated emoji names
Remove emoji reactions from a post.
Parameters:
postId
(string): Target post IDemojiName
(string): Comma-separated emoji names
Get all reactions for a post.
Parameters:
postId
(string): Post ID
Find 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 action
Find a user by email in the action tracking system.
Parameters:
email
(string): Email of the user to findenv
(string): Environment ('uat' or 'prod')
The Neo4j action tracking system provides several key benefits:
- Captures organizational knowledge that would otherwise be lost
- Preserves context around decisions and actions
- Builds institutional memory
- Identifies common workflows and successful approaches
- Recognizes inefficient patterns and bottlenecks
- Discovers best practices automatically
- Suggests relevant actions based on historical patterns
- Provides context-aware recommendations
- Helps users discover new capabilities
- Shows dependencies between different systems (Mattermost, Jira, etc.)
- Tracks how teams use multiple tools together
- Identifies integration opportunities
- Enhances knowledge sharing between team members
- Shows how different teams approach similar problems
- Facilitates cross-team learning
- Links actions to specific users and teams
- Enables personalized recommendations
- Supports team-based analytics
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": "your@email.com",
"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": "your@email.com",
"CURSOR_USER_TEAM": "Your Team"
},
"includeAuth": true
}
}
}
The cursor-auth
header will be automatically populated with the current user's information when you configure "includeAuth": true
.
Here are some example questions you can ask Claude when using this Mattermost MCP server:
- "Search for posts about 'project alpha' in the engineering channel"
- "Create a post in the general channel saying 'Hello team!'"
- "Get the last 10 unread posts in the announcements channel"
- "Show me all pinned posts in the town-square channel"
- "Find users with 'john' in their name"
- "Find all posts from alice about meetings in the last week"
- "Search for posts containing 'deadline' but not 'extended'"
- "Show me posts in the dev-team channel from yesterday"
- "Add a thumbs up reaction to post abc123"
- "Show me all reactions on post xyz789"
- "Remove the fire emoji from post def456"
- "Show me similar actions to creating posts in channels"
- "What actions has user123 performed recently?"
- "Suggest what I should do next after creating a post"
- "Find users by email in the action tracking system"
npm test
npm run dev
npm run build
npm run lint
npm run lint:fix
For development with Docker:
# Build development image
docker build -t mcp-mattermost:dev .
# Run with volume mounting for development
docker run -it --rm \
-v $(pwd):/app \
-e MATTERMOST_URL="https://your-mattermost-instance.com" \
-e MATTERMOST_TOKEN="your-token" \
mcp-mattermost:dev npm run dev
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:
- Verify Neo4j is running (check
docker-compose logs neo4j
) - Check environment variables are correctly set
- Ensure Neo4j credentials are correct
- The server will continue to work without action tracking
Common Docker problems:
- Build failures: Ensure all dependencies are correctly specified in package.json
- Permission issues: The container runs as non-root user
mcp
(uid 1001) - Environment variables: Use
docker-compose
or set env vars correctly
This Mattermost MCP server is designed to work seamlessly with other MCP servers through the Neo4j action tracking system. When used alongside:
- DynamoDB MCP: Track database operations related to chat activities
- Jira MCP: Link project management activities with team communications
- Other MCPs: Build a comprehensive view of team workflows
The action tracking system creates relationships between actions across different services, enabling powerful insights and recommendations.
This project is licensed under the MIT License. See the LICENSE file for details.