read_thread
Fetch all replies in a Microsoft Teams thread by providing its thread ID. Use this to access full threaded conversation details.
Instructions
Read replies in a thread
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thread_id | Yes | The thread ID as a string in the format '1743086901347' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | Yes | Cursor to retrieve the next page of messages. | |
| limit | Yes | Page limit, maximum number of items to retrieve | |
| total | Yes | Total items available for retrieval | |
| items | Yes | List of channel messages or threads |
Implementation Reference
- src/mcp_teams_server/__init__.py:141-150 (handler)MCP tool handler for 'read_thread' - decorated with @mcp.tool, 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) - TeamsClient.read_thread_replies() - the actual implementation that fetches thread replies via Microsoft Graph API with pagination support
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 - src/mcp_teams_server/__init__.py:141-141 (registration)Tool registration via @mcp.tool(name='read_thread', description='Read replies in a thread') decorator
@mcp.tool(name="read_thread", description="Read replies in a thread") - Input schema - thread_id parameter typed as str with Field description
ctx: Context, thread_id: str = Field( description="The thread ID as a string in the format '1743086901347'" ),