Skip to main content
Glama

create_chat

Generate new chat conversations in Microsoft Teams by specifying user emails for 1:1 chats or group discussions. Optionally set a topic for group chats to enhance organization and context.

Instructions

Create a new chat conversation. Can be a 1:1 chat (with one other user) or a group chat (with multiple users). Group chats can optionally have a topic.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicNoChat topic (for group chats)
userEmailsYesArray of user email addresses to add to chat

Implementation Reference

  • The handler function that implements the create_chat tool logic: resolves users by email, builds the chat payload using CreateChatPayload type, and creates the chat via Microsoft Graph API.
    async ({ userEmails, topic }) => { try { const client = await graphService.getClient(); // Get current user ID const me = (await client.api("/me").get()) as User; // Create members array const members: ConversationMember[] = [ { "@odata.type": "#microsoft.graph.aadUserConversationMember", user: { id: me?.id, }, roles: ["owner"], } as ConversationMember, ]; // Add other users as members for (const email of userEmails) { const user = (await client.api(`/users/${email}`).get()) as User; members.push({ "@odata.type": "#microsoft.graph.aadUserConversationMember", user: { id: user?.id, }, roles: ["member"], } as ConversationMember); } const chatData: CreateChatPayload = { chatType: userEmails.length === 1 ? "oneOnOne" : "group", members, }; if (topic && userEmails.length > 1) { chatData.topic = topic; } const newChat = (await client.api("/chats").post(chatData)) as Chat; return { content: [ { type: "text", text: `✅ Chat created successfully. Chat ID: ${newChat?.id}`, }, ], }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ { type: "text", text: `❌ Error: ${errorMessage}`, }, ], }; } }
  • Zod schema defining the input parameters for the create_chat tool.
    { userEmails: z.array(z.string()).describe("Array of user email addresses to add to chat"), topic: z.string().optional().describe("Chat topic (for group chats)"), },
  • Registration of the create_chat tool using server.tool.
    server.tool( "create_chat",
  • TypeScript interface defining the payload structure for creating a chat, used in the handler.
    export interface CreateChatPayload { chatType: "oneOnOne" | "group"; members: ConversationMember[]; topic?: string; }

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