list_guild_webhooks
Retrieve all configured webhooks within a Discord server to manage automated message delivery and integrations.
Instructions
List all webhooks in a server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) |
Implementation Reference
- src/tools/webhook-tools.ts:70-92 (handler)Executes the tool logic: fetches the guild, retrieves all webhooks using guild.fetchWebhooks(), maps them to a simplified object, wraps in error handling, and returns JSON string.async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const webhooks = await guild.fetchWebhooks(); return webhooks.map((wh) => ({ id: wh.id, name: wh.name, type: wh.type, channelId: wh.channelId, avatar: wh.avatar, owner: wh.owner ? { id: wh.owner.id, username: wh.owner.username } : null, 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) }] }; }
- src/tools/webhook-tools.ts:67-69 (schema)Zod input schema defining the required guildId parameter.{ guildId: z.string().describe('The ID of the server (guild)'), },
- src/tools/webhook-tools.ts:64-93 (registration)Registers the list_guild_webhooks tool on the MCP server with name, description, input schema, and handler function.server.tool( 'list_guild_webhooks', 'List all webhooks in a server', { guildId: z.string().describe('The ID of the server (guild)'), }, async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const webhooks = await guild.fetchWebhooks(); return webhooks.map((wh) => ({ id: wh.id, name: wh.name, type: wh.type, channelId: wh.channelId, avatar: wh.avatar, owner: wh.owner ? { id: wh.owner.id, username: wh.owner.username } : null, 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) }] }; } );
- src/index.ts:61-61 (registration)Top-level call to registerWebhookTools which includes the list_guild_webhooks tool.registerWebhookTools(server);
- src/index.ts:18-18 (registration)Import of registerWebhookTools function that defines and registers the tool.import { registerWebhookTools } from './tools/webhook-tools.js';