Skip to main content
Glama
wowjinxy
by wowjinxy

get_channels

List Discord server channels organized by category to view and manage channel structure. Retrieve channel information using server ID.

Instructions

List channels for a Discord server grouped by category.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
server_idNo

Implementation Reference

  • Core implementation of the get_channels tool. Fetches guild channels, organizes by category, formats output with emojis and details.
    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)]
  • Registers the get_channels tool in the MCP server via @app.list_tools(), defining name, description, and input schema.
    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"]
        }
    ),
  • Routes get_channels tool calls to CoreToolHandlers.handle_get_channels via dynamic getattr in the main @app.call_tool() handler.
    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)
  • Input schema definition requiring 'server_id' as string for the get_channels tool.
    inputSchema={
        "type": "object",
        "properties": {
            "server_id": {
                "type": "string",
                "description": "Discord server (guild) ID"
            }
        },
        "required": ["server_id"]
    }

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/wowjinxy/mcp-discord'

If you have feedback or need assistance with the MCP directory API, please join our Discord server