Sponsored by Deepsite.site

Mattermost MCP Client

Created By
jagan-shanmugam9 months ago
Content

Mattermost MCP Client

A Python-based MCP (Model Context Protocol) client that connects Mattermost with MCP servers, enabling command execution and tool management through Mattermost channels.

Demo

MCP Client Demo

Prerequisites

  • Python 3.13.1+
  • Mattermost server (local or remote)
  • Bot account in Mattermost with appropriate permissions

Installation

  1. Create a virtual environment
uv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
# On fish shell - source .venv/bin/activate.fish
  1. Install required packages
uv sync # Installs all dependencies
  1. Set up configuration

Create a .env file with your Mattermost and MCP server settings:

MATTERMOST_URL=http://localhost:8065
MATTERMOST_TOKEN=your-bot-token
MATTERMOST_SCHEME=http
MATTERMOST_PORT=8065
MATTERMOST_TEAM_NAME=your-team-name
MATTERMOST_CHANNEL_NAME=town-square
MCP_SERVER_TYPE=stdio
MCP_COMMAND=python
MCP_ARGS=mcp_server.py
LOG_LEVEL=INFO

For a complete list of configuration options and their default values, refer to the config.py.

Configuration Options

All configuration options can be set through environment variables or in the .env file. Here are the available options:

  • COMMAND_PREFIX - Prefix for bot commands (default: '!mcp')
  • LOG_LEVEL - Logging level (default: 'INFO')
  1. Configure MCP Servers

Create or modify mcp-servers.json in the src/mattermost_mcp_client directory:

{
    "mcpServers": {
      "ollama-mcp-server":{
        "command": "python",
        "args": ["ollama-mcp-server/src/ollama_mcp_server/main.py"],
        "type": "stdio"
      },
      "simple-mcp-server": {
        "command": "python",
        "args": ["simple-mcp-server/server.py"],
        "type": "stdio"
      },
      "mattermost-mcp-server": {
        "command": "python",
        "args": ["mattermost-mcp-server/src/mattermost_mcp_server/server.py"],
        "type": "stdio"
      }
    }
}

Mattermost Setup

  1. Start a local Mattermost server (if not already running)

You can use Docker to run Mattermost locally:

docker run --name mattermost-preview -d --publish 8065:8065 mattermost/mattermost-preview
  1. Create a Bot Account
  • Go to Integrations > Bot Accounts > Add Bot Account
  • Give it a name and description
  • Note the access token provided
  1. Add the bot to your team and channel

Running the Integration

  1. Start the Mattermost MCP Client
python src/mattermost_mcp_client/main.py

Using the MCP Tool Caller Utility

The mcp_tool_caller.py utility allows you to interact with MCP servers directly from the command line:

  1. List server capabilities
python utils/mcp_tool_caller.py list --server-name simple-mcp-server
  1. Call specific tools
python utils/mcp_tool_caller.py call --server-name simple-mcp-server --tool echo --tool-args '{"input": "Hello World"}'

Mattermost Commands

Once the integration is running, use these commands in your Mattermost channel:

  • !mcp help - Display help information
  • !mcp servers - List available MCP servers
  • !mcp <server_name> tools - List available tools for a specific server
  • !mcp <server_name> call <tool_name> <args> - Call a specific tool
  • !mcp <server_name> resources - List available resources
  • !mcp <server_name> prompts - List available prompts

Example:

!mcp simple-mcp-server call echo message "Hello World"
!mcp mattermost-mcp-server call post-message {"channel_id": "5q39mmzqji8bddxyjzsqbziy9a", "message": "Hello from Demo!"}'


!mcp ollama-mcp-server call generate {"prompt": "Write a short poem about AI", "model": "llama3.2:latest"}


MCP Servers included

This repository includes three MCP servers:

  • simple-mcp-server: A simple MCP server that has two simple tools
  • ollama-mcp-server: A MCP server that uses Ollama locally to generate text
  • mattermost-mcp-server: A MCP server that wraps Mattermost API and performs various actions

Troubleshooting

  1. Connection Issues:

    • Verify Mattermost URL and port
    • Check the bot token is valid
    • Ensure the MCP server is running
  2. Permission Issues:

    • Make sure the bot has appropriate permissions in Mattermost
    • Check that the bot is a member of the channel
  3. MCP Tool Errors:

    • Verify that the tools are properly defined in the MCP server
    • Check the input format for tool calls
    • Use the mcp_tool_caller.py utility to test tools directly

Next Steps

  1. Add support for npx based MCP servers
  2. Using Tool calling Agent to orchstrate tools in MCP servers
  3. Implement authentication for secure communication
  4. Add support for file uploads and other Mattermost features

Watch the full demo video:

Watch the demo video
Recommend Clients
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
WindsurfThe new purpose-built IDE to harness magic
HyperChatHyperChat is a Chat client that strives for openness, utilizing APIs from various LLMs to achieve the best Chat experience, as well as implementing productivity tools through the MCP protocol.
Cherry Studio🍒 Cherry Studio is a desktop client that supports for multiple LLM providers.
ChatWiseThe second fastest AI chatbot™
A Sleek AI Assistant & MCP Client5ire is a cross-platform desktop AI assistant, MCP client. It compatible with major service providers, supports local knowledge base and tools via model context protocol servers .
MCP ConnectEnables cloud-based AI services to access local Stdio based MCP servers via HTTP requests
Roo Code (prev. Roo Cline)Roo Code (prev. Roo Cline) gives you a whole dev team of AI agents in your code editor.
DeepChatYour AI Partner on Desktop
ZedCode at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
chatmcpChatMCP is an AI chat client implementing the Model Context Protocol (MCP).
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
VISBOOM
Refact.aiOpen-source AI Agent for VS Code and JetBrains that autonomously solves coding tasks end-to-end.
y-cli 🚀A Tiny Terminal Chat App for AI Models with MCP Client Support
Cline – #1 on OpenRouterAutonomous coding agent right in your IDE, capable of creating/editing files, executing commands, using the browser, and more with your permission every step of the way.
Continue⏩ Create, share, and use custom AI code assistants with our open-source IDE extensions and hub of models, rules, prompts, docs, and other building blocks
CursorThe AI Code Editor
MCP PlaygroundCall MCP Server Tools Online
LutraLutra is the first MCP compatible client built for everyone