Skip to main content
Glama

Mattermost MCP Server

by pvev
index.ts2.33 kB
import { Tool } from "@modelcontextprotocol/sdk/types.js"; import { listChannelsTool, getChannelHistoryTool, handleListChannels, handleGetChannelHistory } from "./channels.js"; import { postMessageTool, replyToThreadTool, addReactionTool, getThreadRepliesTool, handlePostMessage, handleReplyToThread, handleAddReaction, handleGetThreadReplies } from "./messages.js"; import { getUsersTool, getUserProfileTool, handleGetUsers, handleGetUserProfile } from "./users.js"; import { runMonitoringTool, handleRunMonitoring, setTopicMonitorInstance } from "./monitoring.js"; import { MattermostClient } from "../client.js"; // Export all tool definitions export const tools: Tool[] = [ listChannelsTool, getChannelHistoryTool, postMessageTool, replyToThreadTool, addReactionTool, getThreadRepliesTool, getUsersTool, getUserProfileTool, runMonitoringTool ]; // Export the setTopicMonitorInstance function export { setTopicMonitorInstance }; // Tool handler map export const toolHandlers: Record<string, Function> = { mattermost_list_channels: handleListChannels, mattermost_get_channel_history: handleGetChannelHistory, mattermost_post_message: handlePostMessage, mattermost_reply_to_thread: handleReplyToThread, mattermost_add_reaction: handleAddReaction, mattermost_get_thread_replies: handleGetThreadReplies, mattermost_get_users: handleGetUsers, mattermost_get_user_profile: handleGetUserProfile, mattermost_run_monitoring: handleRunMonitoring }; // Execute a tool with the given name and arguments export async function executeTool( client: MattermostClient, toolName: string, args: any ) { const handler = toolHandlers[toolName]; if (!handler) { return { content: [ { type: "text", text: JSON.stringify({ error: `Unknown tool: ${toolName}`, }), }, ], isError: true, }; } try { return await handler(client, args); } catch (error) { console.error(`Error executing tool ${toolName}:`, error); return { content: [ { type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), }), }, ], isError: true, }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pvev/mattermost-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server