Skip to main content
Glama
InditexTech

MCP Microsoft Teams Server

by InditexTech

list_threads

List threads in a Microsoft Teams channel with pagination using cursor and limit parameters.

Instructions

List threads in channel with pagination

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorYesCursor to retrieve the next page of messages.
limitYesPage limit, maximum number of items to retrieve
totalYesTotal items available for retrieval
itemsYesList of channel messages or threads

Implementation Reference

  • MCP tool handler function 'list_threads' - accepts 'limit' (default 50) and 'cursor' (optional) parameters, delegates to TeamsClient.read_threads()
    @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)
  • Tool registration via @mcp.tool decorator on the FastMCP instance 'mcp' (created at line 88)
    @mcp.tool(name="list_threads", description="List threads in channel with pagination")
  • TeamsClient.read_threads() - the actual logic using Microsoft Graph API to list channel messages with pagination support (limit, cursor)
    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
  • PagedTeamsMessages schema - the return type for list_threads, containing cursor, limit, total, and items (list of TeamsMessage)
    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")
  • Helper function _get_teams_client() used by list_threads to obtain the TeamsClient from the request context
    def _get_teams_client(ctx: Context) -> TeamsClient:
        return ctx.request_context.lifespan_context.client
Behavior3/5

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

With no annotations, the description carries the burden of disclosing effects. It mentions pagination, implying a read operation, but does not state read-only nature or authentication requirements. Adequate but not thorough.

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?

A single, focused sentence with zero unnecessary words. Every word adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity and the presence of an output schema, the description is largely complete. It could mention return structure but is not critically missing.

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 coverage is 100% with clear descriptions for both parameters. The description adds the context of 'in channel', but does not elaborate on the parameters further. Baseline 3 is appropriate.

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

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'List threads in channel with pagination', specifying the verb (list), resource (threads), and context (in channel). It is distinct from siblings like read_thread or list_members.

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?

No guidance is provided on when to use this tool versus alternatives (e.g., read_thread). The description does not mention scenarios or exclusions.

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

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