Skip to main content
Glama
InditexTech

MCP Microsoft Teams Server

by InditexTech

list_threads

Retrieve and manage threads in a Microsoft Teams channel with pagination, enabling efficient navigation through discussion history.

Instructions

List threads in channel with pagination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorNoPagination cursor for the next page of results
limitNoMaximum number of items to retrieve or page size

Implementation Reference

  • MCP tool handler for 'list_threads': registers the tool, validates inputs via Pydantic Fields, retrieves TeamsClient from context, and calls read_threads with pagination parameters.
    @mcp.tool(name="list_threads", description="List threads in channel with pagination")
    async def list_threads(
        ctx: Context,
        limit: int = Field(
            description="Maximum number of items to retrieve or page size", default=50
        ),
        cursor: str | None = Field(
            description="Pagination cursor for the next page of results", default=None
        ),
    ) -> PagedTeamsMessages:
        await ctx.debug(f"list_threads with cursor={cursor} and limit={limit}")
        client = _get_teams_client(ctx)
        return await client.read_threads(limit, cursor)
  • Pydantic schema/model for the paged response returned by list_threads tool, including cursor, limit, total, and list of TeamsMessage items.
    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")
  • TeamsClient.read_threads method: the core implementation that fetches channel messages (threads) from Microsoft Graph API using pagination (limit/cursor), maps to PagedTeamsMessages.
    async def read_threads(
        self, limit: int = 50, cursor: str | None = None
    ) -> PagedTeamsMessages:
        """Read all threads in configured teams channel.
    
        Args:
            cursor: The pagination cursor.
    
            limit: The pagination page size
    
        Returns:
            Paged team channel messages containing
        """
        try:
            query = MessagesRequestBuilder.MessagesRequestBuilderGetQueryParameters(
                top=limit
            )
            request = RequestConfiguration(query_parameters=query)
            if cursor is not None:
                response = (
                    await self.graph_client.teams.by_team_id(self.team_id)
                    .channels.by_channel_id(self.teams_channel_id)
                    .messages.with_url(cursor)
                    .get(request_configuration=request)
                )
            else:
                response = (
                    await self.graph_client.teams.by_team_id(self.team_id)
                    .channels.by_channel_id(self.teams_channel_id)
                    .messages.get(request_configuration=request)
                )
    
            result = PagedTeamsMessages(
                cursor=response.odata_next_link,  # pyright: ignore
                limit=limit,
                total=response.odata_count,  # pyright: ignore
                items=[],
            )
            if response.value is not None:  # pyright: ignore
                for message in response.value:  # pyright: ignore
                    result.items.append(
                        TeamsMessage(
                            message_id=message.id,  # pyright: ignore
                            content=message.body.content,  # pyright: ignore
                            thread_id=message.id,  # pyright: ignore
                        )
                    )
    
            return result
        except Exception as e:
            LOGGER.error(f"Error reading thread: {str(e)}")
            raise
  • Helper function to retrieve the TeamsClient instance from the MCP request context, used by list_threads handler.
    def _get_teams_client(ctx: Context) -> TeamsClient:
        return ctx.request_context.lifespan_context.client
  • Pydantic model for individual TeamsMessage items in the paged response of list_threads.
    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")
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions pagination, which is useful, but fails to cover critical aspects like whether this is a read-only operation, what permissions are needed, rate limits, or what the output format looks like. For a list tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 at just six words, front-loading the core purpose ('List threads in channel') and adding a key behavioral note ('with pagination') without any wasted words. Every element earns its place, making it efficient and easy to parse.

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 lack of annotations and output schema, the description is incomplete for a tool that lists resources. It doesn't explain what data is returned (e.g., thread IDs, titles, timestamps), how errors are handled, or any prerequisites like channel access. For a list operation with no structured output documentation, this leaves too much undefined for reliable agent use.

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?

The schema description coverage is 100%, so the input schema already fully documents the 'cursor' and 'limit' parameters. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain how pagination works in practice or default behaviors). This meets the baseline for high schema 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 action ('List') and resource ('threads in channel'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'read_thread' or 'start_thread' beyond the listing function, which prevents a perfect score.

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 like 'read_thread' (for single thread details) or 'start_thread' (for creating threads). It mentions pagination, which hints at usage for large datasets, but lacks explicit when/when-not instructions or sibling comparisons.

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