Skip to main content
Glama

create_chat

Start new 1:1 or group conversations in Microsoft Teams by specifying participant email addresses, with optional topics for group chats.

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
userEmailsYesArray of user email addresses to add to chat
topicNoChat topic (for group chats)

Implementation Reference

  • Executes the creation of a new 1:1 or group chat by resolving user emails to AAD members, constructing the payload, and posting to Microsoft Graph /chats endpoint.
    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 validation schema for the 'create_chat' tool inputs.
    {
      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)"),
    },
  • TypeScript interface defining the payload structure for creating a chat via Microsoft Graph API, used in the handler.
    export interface CreateChatPayload {
      chatType: "oneOnOne" | "group";
      members: ConversationMember[];
      topic?: string;
    }
  • MCP server.tool registration for the 'create_chat' tool, including name, description, schema, and handler.
    // Create new chat (1:1 or group)
    server.tool(
      "create_chat",
      "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.",
      {
        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)"),
      },
      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}`,
              },
            ],
          };
        }
      }
    );
  • src/index.ts:135-135 (registration)
    Top-level call to registerChatTools function which includes the 'create_chat' tool registration.
    registerChatTools(server, graphService);
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral context. It mentions chat types (1:1/group) and optional topics, but doesn't disclose permissions needed, whether chats are private/public, if there are rate limits, what happens with duplicate user emails, or what the response looks like. For a creation tool with zero annotation coverage, this is insufficient.

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 with just two sentences that efficiently convey the core functionality. Every word earns its place - first sentence establishes the main action, second sentence provides essential context about chat types and optional features. No wasted words or redundancy.

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?

For a creation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what gets returned (chat ID? success status?), doesn't mention error conditions, doesn't clarify whether userEmails must be valid/existing users, and provides no guidance on usage context relative to sibling tools. The conciseness comes at the expense of necessary completeness.

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 description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds minimal value by mentioning 'topic (for group chats)' which slightly clarifies usage context, but doesn't provide additional semantics beyond what's in the schema descriptions. 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 verb 'create' and resource 'new chat conversation', specifying it can be 1:1 or group chat. However, it doesn't explicitly differentiate from sibling tools like 'send_chat_message' which might also initiate chats, leaving some ambiguity about when to use this specific creation tool versus sending a first message.

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. With siblings like 'send_chat_message' that might also initiate conversations, there's no indication whether this is for empty chat creation versus starting with content, or any prerequisites like authentication status needed before creating chats.

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