Skip to main content
Glama
jhanglim
by jhanglim

search_messages

Search for messages in Mattermost using keywords, usernames with @ or from: prefix, or date filters to find specific conversations and content.

Instructions

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

Input Schema

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

Implementation Reference

  • The handler case for 'search_messages' tool. Searches Mattermost posts using the provided query, fetches user info for authors, formats timestamps to KST, and returns formatted results including username and user_name.
    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), }, ], }; }
  • The tool definition including name, description, and inputSchema for 'search_messages' as returned by listTools.
    { 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"], }, },
  • MattermostClient.searchPosts method called by the handler to perform the actual API search for posts.
    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; }
  • Helper function to format timestamps from Mattermost (UTC) to KST, used in the search_messages handler.
    function formatTimestamp(timestamp: number) { const kstDate = new Date(timestamp + 9 * 60 * 60 * 1000); return kstDate.toISOString().replace('Z', '+09:00'); }

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