Skip to main content
Glama
hanweg

mcp-discord

by hanweg

get_channels

Retrieve a complete list of channels for any Discord server by providing the server ID. Enables users to manage and navigate server structures efficiently.

Instructions

Get a list of all channels in a Discord server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
server_idYesDiscord server (guild) ID

Implementation Reference

  • The handler implementation for the 'get_channels' tool. It retrieves the Discord guild by server_id, iterates over its channels, formats a list of channel names, IDs, and types, and returns the formatted text content.
    elif name == "get_channels":
        try:
            guild = discord_client.get_guild(int(arguments["server_id"]))
            if guild:
                channel_list = []
                for channel in guild.channels:
                    channel_list.append(f"#{channel.name} (ID: {channel.id}) - {channel.type}")
                
                return [TextContent(
                    type="text", 
                    text=f"Channels in {guild.name}:\n" + "\n".join(channel_list)
                )]
            else:
                return [TextContent(type="text", text="Guild not found")]
        except Exception as e:
            return [TextContent(type="text", text=f"Error: {str(e)}")]
  • Registration of the 'get_channels' tool in the list_tools() function, including its name, description, and input schema requiring 'server_id'.
    Tool(
        name="get_channels",
        description="Get a list of all channels in a Discord server",
        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/hanweg/mcp-discord'

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