Skip to main content
Glama
InditexTech

MCP Microsoft Teams Server

by InditexTech

read_thread

Retrieve all replies in a Microsoft Teams thread by providing the thread ID.

Instructions

Read replies in a thread

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
thread_idYesThe thread ID as a string in the format '1743086901347'

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorYesCursor to retrieve the next page of messages.
limitYesPage limit, maximum number of items to retrieve
totalYesTotal items available for retrieval
itemsYesList of channel messages or threads

Implementation Reference

  • MCP tool handler for 'read_thread'. Decorated with @mcp.tool, takes a thread_id parameter, calls client.read_thread_replies(thread_id, 50).
    @mcp.tool(name="read_thread", description="Read replies in a thread")
    async def read_thread(
        ctx: Context,
        thread_id: str = Field(
            description="The thread ID as a string in the format '1743086901347'"
        ),
    ) -> PagedTeamsMessages:
        await ctx.debug(f"read_thread with thread_id={thread_id}")
        client = _get_teams_client(ctx)
        return await client.read_thread_replies(thread_id, 50)
  • The actual implementation in TeamsClient.read_thread_replies(). Makes a Microsoft Graph API call to fetch replies for a given thread_id, with optional pagination via cursor. Returns PagedTeamsMessages.
    async def read_thread_replies(
        self, thread_id: str, limit: int = 50, cursor: str | None = None
    ) -> PagedTeamsMessages:
        """Read all replies in a thread.
    
        Args:
            thread_id: Thread ID to read
            cursor: The pagination cursor
            limit: The pagination page size
    
        Returns:
            List of thread messages
        """
        try:
            params = RepliesRequestBuilder.RepliesRequestBuilderGetQueryParameters(
                top=limit
            )
            request = RequestConfiguration(query_parameters=params)
    
            if cursor is not None:
                replies = (
                    await self.graph_client.teams.by_team_id(self.team_id)
                    .channels.by_channel_id(self.teams_channel_id)
                    .messages.by_chat_message_id(thread_id)
                    .replies.with_url(cursor)
                    .get(request_configuration=request)
                )
            else:
                replies = (
                    await self.graph_client.teams.by_team_id(self.team_id)
                    .channels.by_channel_id(self.teams_channel_id)
                    .messages.by_chat_message_id(thread_id)
                    .replies.get(request_configuration=request)
                )
    
            result = PagedTeamsMessages(
                cursor=cursor,
                limit=limit,
                total=replies.odata_count,  # pyright: ignore
                items=[],
            )
    
            if replies is not None and replies.value is not None:
                for reply in replies.value:
                    result.items.append(
                        TeamsMessage(
                            message_id=reply.id,  # pyright: ignore
                            content=reply.body.content,  # pyright: ignore
                            thread_id=reply.reply_to_id,  # pyright: ignore
                        )
                    )
    
            return result
        except Exception as e:
            LOGGER.error(f"Error reading thread: {str(e)}")
  • PagedTeamsMessages response model: contains cursor, limit, total, and items (list of TeamsMessage).
    class PagedTeamsMessages(BaseModel):
        cursor: str | None = Field(
            description="Cursor to retrieve the next page of messages."
        )
        limit: int = Field(description="Page limit, maximum number of items to retrieve")
        total: int = Field(description="Total items available for retrieval")
        items: list[TeamsMessage] = Field(description="List of channel messages or threads")
  • TeamsMessage model used in PagedTeamsMessages: contains thread_id, message_id, and content.
    class TeamsMessage(BaseModel):
        thread_id: str = Field(
            description="Thread ID as a string in the format '1743086901347'"
        )
        message_id: str = Field(description="Message ID")
        content: str | None = Field(description="Message content")
  • The @mcp.tool decorator registers 'read_thread' as an MCP tool with the description 'Read replies in a thread'.
    @mcp.tool(name="read_thread", description="Read replies in a thread")
Behavior2/5

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

No annotations are provided, so the description bears full responsibility for behavioral disclosure. It states 'Read replies' which implies a read-only operation, but it does not specify what is returned (e.g., list of reply objects, pagination, ordering), side effects, or error conditions. The output schema may cover return structure, but the description itself is insufficient.

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 a single concise sentence with the action upfront. It is front-loaded and contains no fluff. However, it could be slightly expanded to include context without being verbose.

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?

For a simple read operation with one parameter and an output schema, the description is adequate but not complete. It lacks usage guidelines and behavioral transparency, which are needed for an agent to decide confidently when to invoke this tool.

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 coverage is 100% with a description for 'thread_id' (format '1743086901347'). The description adds no additional meaning beyond what the schema already provides. Baseline score of 3 is appropriate given high 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 'Read replies in a thread' clearly identifies the action (read) and resource (replies in a thread). It distinguishes from siblings like 'list_threads' (lists all threads) and 'start_thread' (creates a new thread), making its purpose clear.

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 guidance is provided on when to use this tool versus alternatives. For example, it does not mention that 'list_threads' could be used first to get thread IDs, nor does it specify prerequisites or context. This lack of usage cues forces the agent to infer context from the name alone.

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

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