Skip to main content
Glama
kakehashi-inc

Mattermost MCP Server

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
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the basic operation. It doesn't disclose behavioral traits like authentication needs, rate limits, error handling, or what 'default channels/limit' entail, which are critical for a fetch/search tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('fetch messages') and adds key detail ('optional search functionality'). It's appropriately sized with zero wasted words, earning its place clearly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavior, output format, error cases, or how parameters interact (e.g., search overriding fetch), leaving significant gaps for agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are well-documented in the schema. The description adds minimal value by implying the tool can fetch recent messages or search, but doesn't elaborate on parameter interactions or semantics beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('fetch messages') and resource ('from Mattermost channels'), with the added detail of 'optional search functionality'. It's specific about what the tool does, though without sibling tools to differentiate from, it can't achieve a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions 'optional search functionality' but provides no explicit guidance on when to use search vs. fetching recent messages, nor any prerequisites or alternatives. Without siblings, it lacks comparative context, leaving usage unclear beyond the basic function.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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