Skip to main content
Glama

list_channel_webhooks

Retrieve all webhooks configured in a specific Discord channel. Use this tool to manage automated messaging and integrations by identifying existing webhook connections.

Instructions

List all webhooks in a channel

Input Schema

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

Implementation Reference

  • The main execution handler for the list_channel_webhooks tool. Fetches the Discord guild and channel, validates channel type, retrieves webhooks, formats their data (redacting tokens), handles errors via withErrorHandling, and returns a JSON-formatted response.
    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 (!isWebhookableChannel(channel)) { throw new Error('Channel does not support webhooks'); } const webhooks = await channel.fetchWebhooks(); return webhooks.map((wh) => ({ id: wh.id, name: wh.name, type: wh.type, channelId: wh.channelId, guildId: wh.guildId, avatar: wh.avatar, token: wh.token ? '[REDACTED]' : null, owner: wh.owner ? { id: wh.owner.id, username: wh.owner.username } : null, applicationId: wh.applicationId, sourceGuild: wh.sourceGuild ? { id: wh.sourceGuild.id, name: wh.sourceGuild.name } : null, sourceChannel: wh.sourceChannel ? { id: wh.sourceChannel.id, name: wh.sourceChannel.name } : null, url: wh.url, createdAt: wh.createdAt?.toISOString(), })); }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
  • Zod schema defining input parameters: guildId (string) and channelId (string) for the tool.
    { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel'), },
  • Direct registration of the list_channel_webhooks tool using server.tool() within the registerWebhookTools function.
    server.tool( 'list_channel_webhooks', 'List all webhooks in a 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 (!isWebhookableChannel(channel)) { throw new Error('Channel does not support webhooks'); } const webhooks = await channel.fetchWebhooks(); return webhooks.map((wh) => ({ id: wh.id, name: wh.name, type: wh.type, channelId: wh.channelId, guildId: wh.guildId, avatar: wh.avatar, token: wh.token ? '[REDACTED]' : null, owner: wh.owner ? { id: wh.owner.id, username: wh.owner.username } : null, applicationId: wh.applicationId, sourceGuild: wh.sourceGuild ? { id: wh.sourceGuild.id, name: wh.sourceGuild.name } : null, sourceChannel: wh.sourceChannel ? { id: wh.sourceChannel.id, name: wh.sourceChannel.name } : null, url: wh.url, createdAt: wh.createdAt?.toISOString(), })); }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
  • Type guard helper function used in the handler to validate if the channel supports webhooks (GuildText, GuildAnnouncement, GuildVoice, GuildForum).
    function isWebhookableChannel(channel: unknown): channel is WebhookableChannel { if (!channel || typeof channel !== 'object') return false; const ch = channel as { type?: number }; return ch.type === ChannelType.GuildText || ch.type === ChannelType.GuildAnnouncement || ch.type === ChannelType.GuildVoice || ch.type === ChannelType.GuildForum; }
  • src/index.ts:60-60 (registration)
    Top-level call to register all webhook tools (including list_channel_webhooks) in the main MCP server setup.
    registerWebhookTools(server);

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