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
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states 'update' implies mutation but lacks details on permissions, reversibility, side effects, or response format. For a mutation tool with zero annotation coverage, this is a significant gap in behavioral disclosure.

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 a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, clearly stating the core action without unnecessary elaboration.

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 (mutation with 3 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like error handling, return values, or usage context, which are critical for an update operation.

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 all parameters (thread_id, content, member_name). The description mentions 'new content' which aligns with the 'content' parameter but adds no additional meaning beyond what the schema provides, meeting the baseline for 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 clearly states the verb ('update') and resource ('an existing thread') with the specific action ('with new content'). It distinguishes from siblings like 'read_thread' (read-only) and 'start_thread' (creation), but doesn't explicitly contrast with other update-like operations since none exist among siblings.

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 an existing thread ID), exclusions, or comparisons to siblings like 'read_thread' for viewing or 'start_thread' for creation, leaving usage context unclear.

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