get_channels
Retrieve and organize Discord server channels by category to view channel structure and manage server organization effectively.
Instructions
List channels for a Discord server grouped by category.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server_id | No |
Implementation Reference
- The handler function for the 'get_channels' tool. Fetches the Discord guild by server_id, organizes channels by categories (including uncategorized), formats them with emojis and details, and returns as TextContent.@staticmethod async def handle_get_channels(discord_client, arguments: Dict[str, Any]) -> List[TextContent]: """Get channels in a server""" guild = await discord_client.fetch_guild(int(arguments["server_id"])) # Organize channels by category categories = {} uncategorized = [] for channel in guild.channels: if isinstance(channel, discord.CategoryChannel): categories[channel.name] = { "id": channel.id, "channels": [] } elif channel.category: if channel.category.name not in categories: categories[channel.category.name] = { "id": channel.category.id, "channels": [] } categories[channel.category.name]["channels"].append({ "name": channel.name, "id": channel.id, "type": str(channel.type) }) else: uncategorized.append({ "name": channel.name, "id": channel.id, "type": str(channel.type) }) # Format the output result = f"**Channels in {guild.name}:**\n\n" # Add categorized channels for cat_name, cat_data in categories.items(): if cat_data["channels"]: # Only show categories with channels result += f"**📁 {cat_name}** (ID: {cat_data['id']})\n" for channel in cat_data["channels"]: emoji = "🔊" if "voice" in channel["type"] else "💬" result += f" {emoji} {channel['name']} (ID: {channel['id']}) - {channel['type']}\n" result += "\n" # Add uncategorized channels if uncategorized: result += "**📋 Uncategorized:**\n" for channel in uncategorized: emoji = "🔊" if "voice" in channel["type"] else "💬" result += f" {emoji} {channel['name']} (ID: {channel['id']}) - {channel['type']}\n" return [TextContent(type="text", text=result)]
- src/discord_mcp/integrated_server.py:643-656 (registration)Registers the 'get_channels' tool in the MCP server's list_tools() method, providing name, description, and input schema requiring 'server_id'.Tool( name="get_channels", description="Get a organized list of all channels in a Discord server", inputSchema={ "type": "object", "properties": { "server_id": { "type": "string", "description": "Discord server (guild) ID" } }, "required": ["server_id"] } ),
- src/discord_mcp/integrated_server.py:1021-1032 (registration)In the call_tool handler, includes 'get_channels' in core_tool_names list and dynamically dispatches to CoreToolHandlers.handle_get_channels using getattr.core_tool_names = [ "get_server_info", "list_servers", "get_channels", "list_members", "get_user_info", "send_message", "read_messages", "add_reaction", "add_multiple_reactions", "remove_reaction", "moderate_message", "create_text_channel", "delete_channel", "add_role", "remove_role" ] if name in core_tool_names: handler_method = f"handle_{name}" if hasattr(CoreToolHandlers, handler_method): return await getattr(CoreToolHandlers, handler_method)(discord_client, arguments)