Skip to main content
Glama
jhanglim

Mattermost MCP Server

by jhanglim

search_messages

Search for messages in Mattermost using keywords, usernames (with @ or from:), or dates to find specific conversations and information.

Instructions

Mattermost에서 메시지를 검색합니다. 키워드, 사용자명(@username 또는 from:username), 날짜 등으로 검색할 수 있습니다. 검색 결과에는 자동으로 작성자의 이름(user_name)과 username이 포함됩니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes검색할 키워드 또는 검색어. 사용자명으로 검색하려면 'from:username' 또는 '@username' 형식 사용
is_or_searchNotrue인 경우 OR 검색, false인 경우 AND 검색 (기본값: false)

Implementation Reference

  • The handler for the 'search_messages' tool. It takes a query and optional is_or_search flag, searches Mattermost posts via client.searchPosts, retrieves user info for all posters, formats timestamps to KST, and returns a JSON object with total_count and detailed posts including usernames and names.
    case "search_messages": {
      const query = args.query as string;
      const isOrSearch = (args.is_or_search as boolean) || false;
      
      const result = await client.searchPosts(query, isOrSearch);
    
      // 고유한 user_id 추출
      const uniqueUserIds = [...new Set(result.order?.map((postId: string) => result.posts[postId].user_id) || [])];
      
      // 사용자 정보 일괄 조회
      const userMap = await client.getUsersInfo(uniqueUserIds);
    
      // 검색 결과 포맷팅
      const posts = result.order?.map((postId: string) => {
        const post = result.posts[postId];
        const createTime = formatTimestamp(post.create_at);
        const updateTime = formatTimestamp(post.update_at);
        const userInfo = userMap.get(post.user_id);
        
        return {
          id: post.id,
          message: post.message,
          user_id: post.user_id,
          username: userInfo?.username || "unknown",
          user_name: userInfo?.name || "Unknown User",
          channel_id: post.channel_id,
          create_at: createTime,
          update_at: updateTime,
        };
      }) || [];
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              total_count: posts.length,
              posts: posts,
            }, null, 2),
          },
        ],
      };
    }
  • src/index.ts:206-224 (registration)
    Registration of the 'search_messages' tool in the list of tools returned by ListToolsRequestSchema, including its name, description, and input schema definition.
    {
      name: "search_messages",
      description: "Mattermost에서 메시지를 검색합니다. 키워드, 사용자명(@username 또는 from:username), 날짜 등으로 검색할 수 있습니다. 검색 결과에는 자동으로 작성자의 이름(user_name)과 username이 포함됩니다.",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "검색할 키워드 또는 검색어. 사용자명으로 검색하려면 'from:username' 또는 '@username' 형식 사용",
          },
          is_or_search: {
            type: "boolean",
            description: "true인 경우 OR 검색, false인 경우 AND 검색 (기본값: false)",
            default: false,
          },
        },
        required: ["query"],
      },
    },
  • Helper method in MattermostClient class that performs the actual Mattermost API search for posts, used by the search_messages handler.
    async searchPosts(terms: string, isOrSearch: boolean = false): Promise<MattermostSearchResult> {
      return await this.request("/posts/search", {
        method: "POST",
        body: JSON.stringify({
          terms,
          is_or_search: isOrSearch,
        }),
      }) as MattermostSearchResult;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that search results include author names and usernames, which adds some context about output behavior. However, it lacks details on permissions, rate limits, pagination, or error handling, which are important for a search operation. This partial disclosure earns a score of 2.

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

Conciseness4/5

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

The description is concise and front-loaded, with two sentences that directly explain the tool's function and output. There is no unnecessary information, making it efficient. However, it could be slightly more structured by explicitly separating usage guidelines, which prevents a perfect score of 5.

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

Completeness3/5

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

Given the complexity of a search tool with no annotations and no output schema, the description is moderately complete. It covers the basic purpose and output inclusion but lacks details on result format, limitations, or error cases. This makes it adequate but with clear gaps, resulting in a score of 3.

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?

The schema description coverage is 100%, so the input schema already fully documents the parameters. The description adds minimal value by mentioning keywords, usernames, and dates in the search, but does not provide additional syntax or format details beyond what the schema states. This meets the baseline of 3 for high schema coverage.

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 tool's purpose: 'Mattermost에서 메시지를 검색합니다' (Search messages in Mattermost). It specifies the resource (messages) and the action (search), but does not explicitly differentiate it from sibling tools like 'search_user_messages' or 'get_channel_messages', which limits it to a 4 instead of a 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 provides no guidance on when to use this tool versus alternatives. It mentions search capabilities but does not compare to sibling tools like 'search_user_messages' or 'get_channel_messages', nor does it specify prerequisites or exclusions. This lack of comparative context results in a score of 2.

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

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

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