send_message
Send messages to Discord text channels or threads using this tool, enabling communication within Discord servers through direct message delivery.
Instructions
Send a message to a Discord text channel or thread.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel_id | Yes | ||
| message | Yes |
Implementation Reference
- The main handler function that implements the send_message tool. It fetches the Discord channel by ID, sends the provided content as a message, and returns a confirmation with the channel name and message ID.async def handle_send_message(discord_client, arguments: Dict[str, Any]) -> List[TextContent]: """Send a message to a channel""" channel = await discord_client.fetch_channel(int(arguments["channel_id"])) message = await channel.send(arguments["content"]) return [TextContent( type="text", text=f"Message sent successfully to #{channel.name}. Message ID: {message.id}" )]
- The tool schema definition in the list_tools() function, specifying the input parameters channel_id (string) and content (string) as required for the send_message tool.name="send_message", description="Send a message to a specific channel", inputSchema={ "type": "object", "properties": { "channel_id": { "type": "string", "description": "Discord channel ID" }, "content": { "type": "string", "description": "Message content" } }, "required": ["channel_id", "content"] } ),
- src/discord_mcp/integrated_server.py:1021-1032 (registration)The registration and dispatching logic in the call_tool() function. It checks if the tool name is in core_tool_names (which includes 'send_message') and dynamically calls CoreToolHandlers.handle_send_message.core_tool_names = [ "get_server_info", "list_servers", "get_channels", "list_members", "get_user_info", "send_message", "read_messages", "add_reaction", "add_multiple_reactions", "remove_reaction", "moderate_message", "create_text_channel", "delete_channel", "add_role", "remove_role" ] if name in core_tool_names: handler_method = f"handle_{name}" if hasattr(CoreToolHandlers, handler_method): return await getattr(CoreToolHandlers, handler_method)(discord_client, arguments)
- src/discord_mcp/integrated_server.py:20-20 (registration)Import of the CoreToolHandlers class, which contains the send_message handler, enabling its use in the dispatch logic.from .core_tool_handlers import CoreToolHandlers