Skip to main content
Glama

get_channel_message_replies

Retrieve all replies to a specific message in a Microsoft Teams channel, including reply content, sender details, and timestamps for threaded conversations.

Instructions

Get all replies to a specific message in a channel. Returns reply content, sender information, and timestamps.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
teamIdYesTeam ID
channelIdYesChannel ID
messageIdYesMessage ID to get replies for
limitNoNumber of replies to retrieve (default: 20)

Implementation Reference

  • The handler function that fetches and formats replies to a specific message in a Microsoft Teams channel using the Graph API. Handles pagination with $top, sorts replies chronologically, and includes error handling.
      async ({ teamId, channelId, messageId, limit }) => {
        try {
          const client = await graphService.getClient();
    
          // Only $top is supported for message replies
          const queryParams: string[] = [`$top=${limit}`];
          const queryString = queryParams.join("&");
    
          const response = (await client
            .api(
              `/teams/${teamId}/channels/${channelId}/messages/${messageId}/replies?${queryString}`
            )
            .get()) as GraphApiResponse<ChatMessage>;
    
          if (!response?.value?.length) {
            return {
              content: [
                {
                  type: "text",
                  text: "No replies found for this message.",
                },
              ],
            };
          }
    
          const repliesList: MessageSummary[] = response.value.map((reply: ChatMessage) => ({
            id: reply.id,
            content: reply.body?.content,
            from: reply.from?.user?.displayName,
            createdDateTime: reply.createdDateTime,
            importance: reply.importance,
          }));
    
          // Sort replies by creation date (oldest first for replies)
          repliesList.sort((a, b) => {
            const dateA = new Date(a.createdDateTime || 0).getTime();
            const dateB = new Date(b.createdDateTime || 0).getTime();
            return dateA - dateB;
          });
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    parentMessageId: messageId,
                    totalReplies: repliesList.length,
                    hasMore: !!response["@odata.nextLink"],
                    replies: repliesList,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
          return {
            content: [
              {
                type: "text",
                text: `❌ Error: ${errorMessage}`,
              },
            ],
          };
        }
      }
    );
  • Zod input schema validating parameters: teamId (string), channelId (string), messageId (string), limit (number, 1-50, default 20).
    {
      teamId: z.string().describe("Team ID"),
      channelId: z.string().describe("Channel ID"),
      messageId: z.string().describe("Message ID to get replies for"),
      limit: z
        .number()
        .min(1)
        .max(50)
        .optional()
        .default(20)
        .describe("Number of replies to retrieve (default: 20)"),
    },
  • Registration of the tool with MCP server, including name, description.
    server.tool(
      "get_channel_message_replies",
      "Get all replies to a specific message in a channel. Returns reply content, sender information, and timestamps.",

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/floriscornel/teams-mcp'

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