Skip to main content
Glama

get_channel_info

Retrieve detailed information about a specific Discord channel using server and channel IDs to manage and maintain Discord servers.

Instructions

Get detailed information about a specific channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel

Implementation Reference

  • The core handler function that fetches the Discord guild and channel, extracts base and type-specific information (text/voice), handles permissions and errors, and returns JSON-formatted data.
    async ({ guildId, channelId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!channel) throw new Error('Channel not found'); // Cast to GuildChannel for common properties const guildChannel = channel as GuildChannel; const baseInfo: Record<string, unknown> = { id: channel.id, name: channel.name, type: channel.type, typeName: ChannelType[channel.type], parentId: guildChannel.parentId, createdAt: channel.createdAt?.toISOString(), }; // Add position and permission overwrites for non-thread channels if ('position' in guildChannel) { baseInfo.position = guildChannel.position; } if ('permissionOverwrites' in guildChannel && guildChannel.permissionOverwrites) { baseInfo.permissionOverwrites = guildChannel.permissionOverwrites.cache.map((po) => ({ id: po.id, type: po.type, allow: po.allow.toArray(), deny: po.deny.toArray(), })); } // Add text channel specific info if (channel.type === ChannelType.GuildText || channel.type === ChannelType.GuildAnnouncement) { const textChannel = channel as TextChannel; return { ...baseInfo, topic: textChannel.topic, nsfw: textChannel.nsfw, rateLimitPerUser: textChannel.rateLimitPerUser, }; } // Add voice channel specific info if (channel.type === ChannelType.GuildVoice || channel.type === ChannelType.GuildStageVoice) { const voiceChannel = channel as VoiceChannel; return { ...baseInfo, bitrate: voiceChannel.bitrate, userLimit: voiceChannel.userLimit, rtcRegion: voiceChannel.rtcRegion, }; } return baseInfo; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
  • Zod input schema defining required guildId and channelId parameters.
    { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel'), },
  • Registration of the 'get_channel_info' tool on the MCP server within registerChannelTools function.
    server.tool( 'get_channel_info', 'Get detailed information about a specific channel', { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel'), }, async ({ guildId, channelId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!channel) throw new Error('Channel not found'); // Cast to GuildChannel for common properties const guildChannel = channel as GuildChannel; const baseInfo: Record<string, unknown> = { id: channel.id, name: channel.name, type: channel.type, typeName: ChannelType[channel.type], parentId: guildChannel.parentId, createdAt: channel.createdAt?.toISOString(), }; // Add position and permission overwrites for non-thread channels if ('position' in guildChannel) { baseInfo.position = guildChannel.position; } if ('permissionOverwrites' in guildChannel && guildChannel.permissionOverwrites) { baseInfo.permissionOverwrites = guildChannel.permissionOverwrites.cache.map((po) => ({ id: po.id, type: po.type, allow: po.allow.toArray(), deny: po.deny.toArray(), })); } // Add text channel specific info if (channel.type === ChannelType.GuildText || channel.type === ChannelType.GuildAnnouncement) { const textChannel = channel as TextChannel; return { ...baseInfo, topic: textChannel.topic, nsfw: textChannel.nsfw, rateLimitPerUser: textChannel.rateLimitPerUser, }; } // Add voice channel specific info if (channel.type === ChannelType.GuildVoice || channel.type === ChannelType.GuildStageVoice) { const voiceChannel = channel as VoiceChannel; return { ...baseInfo, bitrate: voiceChannel.bitrate, userLimit: voiceChannel.userLimit, rtcRegion: voiceChannel.rtcRegion, }; } return baseInfo; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
  • src/index.ts:55-55 (registration)
    Invocation of registerChannelTools in the main MCP server setup.
    registerChannelTools(server);
  • src/index.ts:12-12 (registration)
    Import of the registerChannelTools function.
    import { registerChannelTools } from './tools/channel-tools.js';

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

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