Skip to main content
Glama

mattermost_search

Retrieve and filter messages from Mattermost channels using search queries or fetch recent messages. Specify channels, set message limits, and enhance monitoring with the MCP server integration.

Instructions

Fetch messages from Mattermost channels with optional search functionality

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelsNoList of channel IDs to fetch messages from. If not provided, uses the default channels.
limitNoMaximum number of messages to fetch per channel. If not provided, uses the default limit.
queryNoSearch query to filter messages. If provided, performs a search instead of fetching recent messages.

Implementation Reference

  • The execute function implementing the core logic of the 'mattermost_search' tool: validates input, initializes MattermostClient, fetches messages from specified channels using search parameters, and returns JSON-structured results grouped by channel.
    const execute = async ({ query, channels, before, after, on, limit }: Args) => { const client = new MattermostClient(config.endpoint, config.token); const targetChannels = await client.getTargetChannelNames(channels, config.channels); const messageLimit = limit ?? config.limit; const messages: { type: 'text'; text: string }[] = []; // クエリ未指定はエラーを返す if (!query) { throw new Error('Query is required'); } for (const channelName of targetChannels) { if (config.transport !== 'stdio') { let paramString = `query: ${query}`; if (before) { paramString += `, before: ${before}`; } if (after) { paramString += `, after: ${after}`; } if (on) { paramString += `, on: ${on}`; } consoleWriter.log( `Searching messages from ${channelName} with ${paramString} (limit:${messageLimit.toString()})` ); } const channelMessages: Message[] = await client.searchMessagesByName( query, config.team, channelName, before, after, on, messageLimit ); consoleWriter.log(`Found ${channelMessages.length.toString()} messages`); messages.push({ type: 'text' as const, text: JSON.stringify({ channel: channelName, messages: channelMessages, }), }); } return { content: messages, }; };
  • Defines the tool name, description, Zod schema for input parameters (query, channels, date filters, limit), and derived Args type for type safety.
    const name = 'mattermost_search'; const description = 'Search messages from Mattermost channels. return json of messages grouped by channel.'; const parameters = { query: z.string().describe('Search query to filter messages.'), channels: z .array(z.string()) .optional() .describe( 'List of channel names to fetch messages from. If not provided, uses the default channels.' ), before: z.string().optional().describe('Search before this timestamp (yyyy-mm-dd).'), after: z.string().optional().describe('Search after this timestamp (yyyy-mm-dd).'), on: z.string().optional().describe('Search on this date (yyyy-mm-dd).'), limit: z .number() .min(1) .optional() .describe( 'Maximum number of messages to fetch per channel. If not provided, uses the default limit.' ), }; type Args = z.objectOutputType<typeof parameters, ZodTypeAny>;
  • src/main.ts:33-38 (registration)
    Registers the 'mattermost_search' tool with the MCP server by calling mcp.tool() with its name, description, parameters, and execute handler.
    mcp.tool( mattermostSearch.name, mattermostSearch.description, mattermostSearch.parameters, mattermostSearch.execute );

Other Tools

Related Tools

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/kakehashi-inc/mattermost-mcp-server'

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