list_channels
Retrieve detailed information about all channels in a Microsoft Team, including names, descriptions, types, and IDs, by specifying the team ID for streamlined management and analysis.
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:76-127 (registration)Registration of the 'list_channels' MCP tool, including inline schema definition (teamId parameter) and handler function that retrieves and summarizes channels from a Microsoft Team using the Graph API.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}`, }, ], }; } } );
- src/tools/teams.ts:82-127 (handler)Handler function for 'list_channels' tool: fetches channels via Graph API `/teams/{teamId}/channels`, maps to ChannelSummary, returns JSON stringified list or error message.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:80-81 (schema)Input schema for 'list_channels' tool using Zod: requires 'teamId' string.teamId: z.string().describe("Team ID"), },