Skip to main content
Glama
InditexTech

MCP Microsoft Teams Server

by InditexTech

read_thread

Retrieve and view replies within a specific Microsoft Teams thread using the thread ID. Integrates with MCP Microsoft Teams Server for efficient message management.

Instructions

Read replies in a thread

Input Schema

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

Implementation Reference

  • MCP tool handler function for 'read_thread' that logs the request, retrieves the TeamsClient instance, and delegates to client.read_thread_replies to fetch thread replies.
    @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)
  • Pydantic model defining the output schema for paginated Teams messages, used as return type for read_thread tool.
    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")
  • Core helper method in TeamsClient that performs the Microsoft Graph API query to retrieve paginated replies for a specific thread ID, mapping responses to 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)}")
            raise
  • Utility function to retrieve the TeamsClient instance from the MCP context, used by the read_thread handler.
    def _get_teams_client(ctx: Context) -> TeamsClient:
        return ctx.request_context.lifespan_context.client
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'Read replies' but doesn't specify what 'read' entails—e.g., whether it returns all replies, paginated results, metadata, or if it's a safe read-only operation. This leaves critical behavioral traits (like safety, output format, or error handling) undocumented.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence ('Read replies in a thread'), which is front-loaded and wastes no words. For a simple tool with one parameter, this brevity is appropriate and efficient.

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 (a read operation with one parameter) and lack of annotations and output schema, the description is incomplete. It doesn't cover what the tool returns (e.g., reply content, metadata), error conditions, or behavioral details, leaving significant gaps for an agent to 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 the 'thread_id' parameter with its format. The description adds no additional meaning beyond what the schema provides—it doesn't explain what a thread ID represents, how to obtain it, or its relationship to replies. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/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 states the action (read) and target (replies in a thread), but it's somewhat vague about scope. It doesn't specify whether it reads all replies, recent replies, or a subset, nor does it differentiate from sibling tools like 'list_threads' or 'update_thread'.

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 no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid thread ID), exclusions, or comparisons to siblings like 'list_threads' (which might list threads without reading replies) or 'update_thread' (which modifies threads).

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

Related 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