Skip to main content
Glama

MCP-Discord

import { SendMessageSchema } from '../schemas.js'; import { ToolHandler } from './types.js'; import { handleDiscordError } from "../errorHandler.js"; export const sendMessageHandler: ToolHandler = async (args, { client }) => { const { channelId, message } = SendMessageSchema.parse(args); try { if (!client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in." }], isError: true }; } const channel = await client.channels.fetch(channelId); if (!channel || !channel.isTextBased()) { return { content: [{ type: "text", text: `Cannot find text channel ID: ${channelId}` }], isError: true }; } // Ensure channel is text-based and can send messages if ('send' in channel) { await channel.send(message); return { content: [{ type: "text", text: `Message successfully sent to channel ID: ${channelId}` }] }; } else { return { content: [{ type: "text", text: `This channel type does not support sending messages` }], isError: true }; } } catch (error) { return handleDiscordError(error); } };

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

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