Skip to main content
Glama
InditexTech

MCP Microsoft Teams Server

by InditexTech

update_thread

Modify an existing Microsoft Teams thread by adding new content or mentioning a member. Use the thread ID and desired content to update discussions efficiently.

Instructions

Update an existing thread with new content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe content to update in the thread
member_nameNoMember name to mention in the thread
thread_idYesThe thread ID as a string in the format '1743086901347'

Implementation Reference

  • MCP tool handler for update_thread: registers the tool, defines input schema via Field, and delegates to TeamsClient.update_thread
    @mcp.tool( name="update_thread", description="Update an existing thread with new content" ) async def update_thread( ctx: Context, thread_id: str = Field( description="The thread ID as a string in the format '1743086901347'" ), content: str = Field(description="The content to update in the thread"), member_name: str | None = Field( description="Member name to mention in the thread", default=None ), ) -> TeamsMessage: await ctx.debug(f"update_thread with thread_id={thread_id} and content={content}") client = _get_teams_client(ctx) return await client.update_thread(thread_id, content, member_name)
  • Core implementation of update_thread in TeamsClient: initializes service, creates mention if member_name provided, sends reply activity to thread using BotFramework ConversationsOperations
    async def update_thread( self, thread_id: str, content: str, member_name: str | None = None ) -> TeamsMessage: """Add a message to an existing thread, mentioning a user optionally. Args: thread_id: Thread ID to update content: Message content to add member_name: Member name to mention (optional) Returns: Updated thread details """ try: await self._initialize() result = TeamsMessage(thread_id=thread_id, content=content, message_id="") async def update_thread_callback(context: TurnContext): mention_member = None if member_name is not None: members = await TeamsInfo.get_team_members(context, self.team_id) for member in members: if member.name == member_name: mention_member = member mentions = [] if mention_member is not None: result.content = f"<at>{mention_member.name}</at> {content}" mention = Mention( text=f"<at>{mention_member.name}</at>", type="mention", mentioned=ChannelAccount( id=mention_member.id, name=mention_member.name ), ) mentions.append(mention) reply = Activity( type=ActivityTypes.message, text=result.content, from_property=TeamsChannelAccount( id=self.teams_app_id, name="MCP Bot" ), conversation=ConversationAccount(id=thread_id), entities=mentions, ) # # Hack to get the connector client and reply to an existing activity # conversations = TeamsClient._get_conversation_operations(context) # # Hack to reply to conversation https://github.com/microsoft/botframework-sdk/issues/6626 # conversation_id = ( f"{context.activity.conversation.id};messageid={thread_id}" # pyright: ignore ) response = await conversations.send_to_conversation( conversation_id=conversation_id, activity=reply ) if response is not None: result.message_id = response.id # pyright: ignore await self.adapter.continue_conversation( bot_app_id=self.teams_app_id, reference=self._create_conversation_reference(), callback=update_thread_callback, ) return result except Exception as e: LOGGER.error(f"Error updating thread: {str(e)}") raise
  • Pydantic model TeamsMessage defining output schema for update_thread
    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 = Field(description="Message content")
  • Tool registration via @mcp.tool decorator in __init__.py
    @mcp.tool( name="update_thread", description="Update an existing thread with new content" ) async def update_thread( ctx: Context, thread_id: str = Field( description="The thread ID as a string in the format '1743086901347'" ), content: str = Field(description="The content to update in the thread"), member_name: str | None = Field( description="Member name to mention in the thread", default=None ), ) -> TeamsMessage: await ctx.debug(f"update_thread with thread_id={thread_id} and content={content}") client = _get_teams_client(ctx) return await client.update_thread(thread_id, content, member_name)
  • Inner callback function used by TeamsClient.update_thread to send the update message to the thread
    async def update_thread_callback(context: TurnContext): mention_member = None if member_name is not None: members = await TeamsInfo.get_team_members(context, self.team_id) for member in members: if member.name == member_name: mention_member = member mentions = [] if mention_member is not None: result.content = f"<at>{mention_member.name}</at> {content}" mention = Mention( text=f"<at>{mention_member.name}</at>", type="mention", mentioned=ChannelAccount( id=mention_member.id, name=mention_member.name ), ) mentions.append(mention) reply = Activity( type=ActivityTypes.message, text=result.content, from_property=TeamsChannelAccount( id=self.teams_app_id, name="MCP Bot" ), conversation=ConversationAccount(id=thread_id), entities=mentions, ) # # Hack to get the connector client and reply to an existing activity # conversations = TeamsClient._get_conversation_operations(context) # # Hack to reply to conversation https://github.com/microsoft/botframework-sdk/issues/6626 # conversation_id = ( f"{context.activity.conversation.id};messageid={thread_id}" # pyright: ignore ) response = await conversations.send_to_conversation( conversation_id=conversation_id, activity=reply ) if response is not None: result.message_id = response.id # pyright: ignore

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