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
| Name | Required | Description | Default |
|---|---|---|---|
| teamId | Yes | Team ID |
Implementation Reference
- src/tools/teams.ts:82-126 (handler)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}`, }, ], }; } }
- src/tools/teams.ts:79-81 (schema)Zod schema for 'list_channels' tool input: requires 'teamId' string.{ teamId: z.string().describe("Team ID"), },
- src/tools/teams.ts:76-127 (registration)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}`, }, ], }; } } );