Skip to main content
Glama
jhanglim

Mattermost MCP Server

by jhanglim

get_channel_messages

Retrieve recent messages from a Mattermost channel with author details. Specify channel ID to fetch messages with user names and usernames included.

Instructions

특정 채널의 최근 메시지들을 가져옵니다. 결과에는 자동으로 작성자의 이름(user_name)과 username이 포함됩니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYes채널 ID
pageNo페이지 번호 (기본값: 0)
per_pageNo페이지당 메시지 수 (기본값: 60)

Implementation Reference

  • Main handler for the 'get_channel_messages' tool within the CallToolRequestSchema switch statement. Extracts parameters, fetches messages from Mattermost API via client, enriches with user details, formats output, and returns JSON response.
    case "get_channel_messages": {
      const channelId = args.channel_id as string;
      const page = (args.page as number) || 0;
      const perPage = (args.per_page as number) || 60;
      
      const messages = await client.getChannelMessages(channelId, page, perPage);
    
      // 고유한 user_id 추출 및 사용자 정보 조회
      const uniqueUserIds = [...new Set(messages.order?.map((postId: string) => messages.posts[postId].user_id) || [])];
      const userMap = await client.getUsersInfo(uniqueUserIds);
    
      const posts = messages.order?.map((postId: string) => {
        const post = messages.posts[postId];
        const createTime = formatTimestamp(post.create_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",
          create_at: createTime,
        };
      }) || [];
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              channel_id: channelId,
              posts: posts,
            }, null, 2),
          },
        ],
      };
    }
  • src/index.ts:279-302 (registration)
    Tool registration in the ListToolsRequestSchema handler's tools array, defining name, description, and input schema for 'get_channel_messages'.
    {
      name: "get_channel_messages",
      description: "특정 채널의 최근 메시지들을 가져옵니다. 결과에는 자동으로 작성자의 이름(user_name)과 username이 포함됩니다.",
      inputSchema: {
        type: "object",
        properties: {
          channel_id: {
            type: "string",
            description: "채널 ID",
          },
          page: {
            type: "number",
            description: "페이지 번호 (기본값: 0)",
            default: 0,
          },
          per_page: {
            type: "number",
            description: "페이지당 메시지 수 (기본값: 60)",
            default: 60,
          },
        },
        required: ["channel_id"],
      },
    },
  • MattermostClient helper method that makes the API request to fetch channel messages, used by the main tool handler.
    async getChannelMessages(channelId: string, page: number = 0, perPage: number = 60): Promise<MattermostPostsResult> {
      return await this.request(`/channels/${channelId}/posts?page=${page}&per_page=${perPage}`) as MattermostPostsResult;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions that results include author names and usernames automatically, which adds some behavioral context. However, it doesn't disclose critical traits like whether this is a read-only operation, rate limits, authentication needs, pagination behavior beyond parameters, or error handling. For a tool with no annotations, this leaves significant gaps.

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?

Two concise sentences with no wasted words. The first sentence states the core purpose, and the second adds a useful behavioral detail. It's appropriately sized and front-loaded, though could be slightly improved with more structure (e.g., bullet points for clarity).

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 no annotations and no output schema, the description is incomplete. It doesn't explain return values beyond mentioning included fields, nor does it cover error cases, permissions, or side effects. For a tool with 3 parameters and retrieval functionality, more context is needed to ensure the agent can use it effectively.

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 the schema already documents all parameters (channel_id, page, per_page) with descriptions and defaults. The description adds no additional parameter semantics beyond what the schema provides, such as format details or constraints. Baseline 3 is appropriate when 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 action ('가져옵니다' - fetches/retrieves) and resource ('특정 채널의 최근 메시지들' - recent messages from a specific channel). It distinguishes from siblings like get_channels (which lists channels) and search_messages (which searches across channels), though not explicitly. However, it doesn't fully differentiate from get_post_thread (which might retrieve thread messages) or search_user_messages (user-specific), so it's not 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?

No explicit guidance on when to use this tool versus alternatives like search_messages or get_post_thread. The description implies it's for recent messages in a specific channel, but doesn't specify contexts like 'use this for quick overviews' or 'avoid for historical searches.' Without such distinctions, the agent lacks clear decision criteria.

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