Skip to main content
Glama

list_channels

Retrieve all channels in a Microsoft Team to view names, descriptions, types, and IDs for team management and organization.

Instructions

List all channels in a specific Microsoft Team. Returns channel names, descriptions, types, and IDs for the specified team.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
teamIdYesTeam ID

Implementation Reference

  • The handler function for the 'list_channels' tool. It retrieves channels for a given teamId using Microsoft Graph API, maps them to ChannelSummary, and returns JSON or error.
    async ({ teamId }) => {
      try {
        const client = await graphService.getClient();
        const response = (await client
          .api(`/teams/${teamId}/channels`)
          .get()) as GraphApiResponse<Channel>;
    
        if (!response?.value?.length) {
          return {
            content: [
              {
                type: "text",
                text: "No channels found in this team.",
              },
            ],
          };
        }
    
        const channelList: ChannelSummary[] = response.value.map((channel: Channel) => ({
          id: channel.id,
          displayName: channel.displayName,
          description: channel.description,
          membershipType: channel.membershipType,
        }));
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(channelList, null, 2),
            },
          ],
        };
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
        return {
          content: [
            {
              type: "text",
              text: `❌ Error: ${errorMessage}`,
            },
          ],
        };
      }
    }
  • Zod schema for 'list_channels' tool input: requires 'teamId' string.
    {
      teamId: z.string().describe("Team ID"),
    },
  • Registration of the 'list_channels' tool using server.tool(), including name, description, schema, and handler.
    server.tool(
      "list_channels",
      "List all channels in a specific Microsoft Team. Returns channel names, descriptions, types, and IDs for the specified team.",
      {
        teamId: z.string().describe("Team ID"),
      },
      async ({ teamId }) => {
        try {
          const client = await graphService.getClient();
          const response = (await client
            .api(`/teams/${teamId}/channels`)
            .get()) as GraphApiResponse<Channel>;
    
          if (!response?.value?.length) {
            return {
              content: [
                {
                  type: "text",
                  text: "No channels found in this team.",
                },
              ],
            };
          }
    
          const channelList: ChannelSummary[] = response.value.map((channel: Channel) => ({
            id: channel.id,
            displayName: channel.displayName,
            description: channel.description,
            membershipType: channel.membershipType,
          }));
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(channelList, null, 2),
              },
            ],
          };
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
          return {
            content: [
              {
                type: "text",
                text: `❌ Error: ${errorMessage}`,
              },
            ],
          };
        }
      }
    );

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