Skip to main content
Glama

list_chats

Retrieve recent Microsoft Teams conversations including 1:1 chats and group discussions with participant details and chat topics.

Instructions

List all recent chats (1:1 conversations and group chats) that the current user participates in. Returns chat topics, types, and participant information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_chats' tool. Fetches the user's chats from Microsoft Graph API using /me/chats?$expand=members, maps to ChatSummary with id, topic, type, members, and returns as JSON string in MCP content format. Handles no chats and errors.
        try {
          // Build query parameters
          const queryParams: string[] = ["$expand=members"];
    
          const queryString = queryParams.join("&");
    
          const client = await graphService.getClient();
          const response = (await client
            .api(`/me/chats?${queryString}`)
            .get()) as GraphApiResponse<Chat>;
    
          if (!response?.value?.length) {
            return {
              content: [
                {
                  type: "text",
                  text: "No chats found.",
                },
              ],
            };
          }
    
          const chatList: ChatSummary[] = response.value.map((chat: Chat) => ({
            id: chat.id,
            topic: chat.topic || "No topic",
            chatType: chat.chatType,
            members:
              chat.members?.map((member: ConversationMember) => member.displayName).join(", ") ||
              "No members",
          }));
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(chatList, null, 2),
              },
            ],
          };
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
          return {
            content: [
              {
                type: "text",
                text: `❌ Error: ${errorMessage}`,
              },
            ],
          };
        }
      }
    );
  • MCP server.tool registration for 'list_chats' tool within registerChatTools function. Includes description, empty input schema ({}), and inline handler.
      "list_chats",
      "List all recent chats (1:1 conversations and group chats) that the current user participates in. Returns chat topics, types, and participant information.",
      {},
      async () => {
        try {
          // Build query parameters
          const queryParams: string[] = ["$expand=members"];
    
          const queryString = queryParams.join("&");
    
          const client = await graphService.getClient();
          const response = (await client
            .api(`/me/chats?${queryString}`)
            .get()) as GraphApiResponse<Chat>;
    
          if (!response?.value?.length) {
            return {
              content: [
                {
                  type: "text",
                  text: "No chats found.",
                },
              ],
            };
          }
    
          const chatList: ChatSummary[] = response.value.map((chat: Chat) => ({
            id: chat.id,
            topic: chat.topic || "No topic",
            chatType: chat.chatType,
            members:
              chat.members?.map((member: ConversationMember) => member.displayName).join(", ") ||
              "No members",
          }));
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(chatList, null, 2),
              },
            ],
          };
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
          return {
            content: [
              {
                type: "text",
                text: `❌ Error: ${errorMessage}`,
              },
            ],
          };
        }
      }
    );
  • src/index.ts:135-136 (registration)
    Top-level call to registerChatTools(server, graphService) in main MCP server setup, which registers the list_chats tool among others.
    registerChatTools(server, graphService);
    registerSearchTools(server, graphService);
  • ChatSummary interface used in the list_chats handler to type the returned chat list. Defined with optional id, topic, chatType, memberCount.
    export interface ChatSummary {
      id?: string | undefined;
      topic?: NullableOption<string> | undefined;
      chatType?: ChatType | undefined;
      memberCount?: number | undefined;
    }
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 of behavioral disclosure. It mentions that the tool returns 'chat topics, types, and participant information,' which adds some context about output format. However, it doesn't cover important behavioral aspects like pagination, rate limits, sorting order, or whether 'recent' has a specific time window. For a list operation with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured in two sentences. The first sentence clearly states the purpose, and the second adds useful context about return values. There's no wasted verbiage, and the information is front-loaded appropriately.

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

Completeness3/5

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

Given the tool's moderate complexity (listing user chats) and the absence of both annotations and an output schema, the description is minimally adequate. It explains what the tool does and what information it returns, but lacks details on behavioral constraints, output structure, or differentiation from sibling tools. With no output schema, more detail about return values would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, earning a baseline score of 4 for not adding unnecessary information. It correctly focuses on the tool's purpose rather than non-existent parameters.

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 tool's purpose: 'List all recent chats (1:1 conversations and group chats) that the current user participates in.' It specifies the verb ('List'), resource ('chats'), and scope ('recent', 'current user participates in'), but doesn't explicitly differentiate from sibling tools like 'list_channels' or 'get_chat_messages'.

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. For example, it doesn't mention how this differs from 'list_channels' (which lists channels, not chats) or 'get_chat_messages' (which retrieves messages within a specific chat). The description only states what the tool does, not when to choose it.

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/floriscornel/teams-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server