Skip to main content
Glama

list_chats

Retrieve detailed information on recent chats, including topics, types, and participants, for the current user in Microsoft Teams. Simplify collaboration tracking with organized chat data.

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. Queries Microsoft Graph API `/me/chats?$expand=members`, maps chats to summaries (id, topic, chatType, members list), returns JSON stringified list or error message.
    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}`, }, ], }; } }
  • Registration of the list_chats tool using server.tool() with name, description, empty input schema, and inline handler function.
    server.tool( "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-135 (registration)
    Top-level call to registerChatTools(server, graphService) in the MCP server initialization, which triggers registration of list_chats and other chat tools.
    registerChatTools(server, graphService);

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