Skip to main content
Glama
jhanglim

Mattermost MCP Server

by jhanglim

search_user_messages

Find messages from specific Mattermost users by name or username, optionally filtering by keywords to locate relevant conversations.

Instructions

특정 사용자의 메시지를 이름이나 username으로 검색합니다. '박찬우', 'cwpark' 등으로 검색 가능.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_nameYes검색할 사용자의 이름 또는 username (예: '박찬우', 'cwpark')
keywordNo추가로 검색할 키워드 (선택사항)

Implementation Reference

  • The handler function for the 'search_user_messages' tool. It searches for the user by name or username, constructs a search query for their messages with an optional keyword, fetches the posts using Mattermost API, enriches with user info, and returns formatted results.
    case "search_user_messages": {
      const userName = args.user_name as string;
      const keyword = (args.keyword as string) || "";
      
      // 먼저 사용자 검색
      let users: MattermostUser[] = [];
      try {
        // username으로 직접 조회 시도
        const user = await client.getUserByUsername(userName);
        users = [user];
      } catch {
        // 실패하면 검색으로 시도
        users = await client.searchUsers(userName);
      }
    
      if (users.length === 0) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                error: `사용자 '${userName}'를 찾을 수 없습니다.`,
                total_count: 0,
                posts: [],
              }, null, 2),
            },
          ],
        };
      }
    
      // 첫 번째 매칭된 사용자의 메시지 검색
      const user = users[0];
      const searchQuery = keyword 
        ? `from:${user.username} ${keyword}`
        : `from:${user.username}`;
      
      const result = await client.searchPosts(searchQuery, false);
    
      // 고유한 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({
              found_user: {
                id: user.id,
                username: user.username,
                name: `${user.first_name} ${user.last_name}`.trim() || user.nickname,
              },
              total_count: posts.length,
              posts: posts,
            }, null, 2),
          },
        ],
      };
    }
  • src/index.ts:225-242 (registration)
    Registration of the 'search_user_messages' tool in the ListTools response, including its name, description, and input schema definition.
    {
      name: "search_user_messages",
      description: "특정 사용자의 메시지를 이름이나 username으로 검색합니다. '박찬우', 'cwpark' 등으로 검색 가능.",
      inputSchema: {
        type: "object",
        properties: {
          user_name: {
            type: "string",
            description: "검색할 사용자의 이름 또는 username (예: '박찬우', 'cwpark')",
          },
          keyword: {
            type: "string",
            description: "추가로 검색할 키워드 (선택사항)",
          },
        },
        required: ["user_name"],
      },
    },
  • Input schema definition for the 'search_user_messages' tool, specifying parameters user_name (required) and keyword (optional).
    inputSchema: {
      type: "object",
      properties: {
        user_name: {
          type: "string",
          description: "검색할 사용자의 이름 또는 username (예: '박찬우', 'cwpark')",
        },
        keyword: {
          type: "string",
          description: "추가로 검색할 키워드 (선택사항)",
        },
      },
      required: ["user_name"],
    },
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 states the tool searches messages, implying a read-only operation, but doesn't clarify aspects like permissions needed, rate limits, pagination, or what the output format might be. For a search tool with zero annotation coverage, this is a significant gap in transparency about how the tool behaves beyond its basic function.

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 brief and front-loaded, stating the core purpose in the first sentence. The second sentence adds useful examples without redundancy. It avoids unnecessary words, making it efficient, though it could be slightly more structured to highlight key points like the optional keyword parameter more explicitly.

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?

Given the tool's complexity (search functionality with 2 parameters), lack of annotations, and no output schema, the description is incomplete. It covers the basic purpose but fails to address behavioral aspects, usage context relative to siblings, or output expectations. This leaves significant gaps for an agent to understand how to effectively use the tool in practice.

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%, meaning the input schema already fully documents both parameters (user_name and keyword). The description adds minimal value by repeating the examples for user_name ('박찬우', 'cwpark') and mentioning keyword as optional, but doesn't provide additional semantics beyond what's in the schema. This meets the baseline of 3 when the schema does the heavy lifting.

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: 'search messages of a specific user by name or username' (특정 사용자의 메시지를 이름이나 username으로 검색합니다). It specifies the verb (search) and resource (user messages), and provides concrete examples ('박찬우', 'cwpark'). However, it doesn't explicitly differentiate from sibling tools like 'search_messages' or 'search_users', which reduces clarity about its unique role.

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 minimal guidance on when to use this tool. It mentions that searches can be done by name or username with examples, but offers no advice on when to choose this over alternatives like 'search_messages' or 'search_users', nor does it specify prerequisites or exclusions. This lack of comparative context leaves the agent with insufficient direction.

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