Skip to main content
Glama

add_role

Assign a Discord role to a user by specifying user and role IDs. This tool manages user permissions and access within Discord servers through the Discord MCP Server.

Instructions

Add a role to a Discord user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYes
role_idYes
server_idNo
reasonNo

Implementation Reference

  • The core handler function that implements the 'add_role' tool logic: fetches guild, member, and role, adds the role to the member, and returns success message or error if role not found.
    @staticmethod async def handle_add_role(discord_client, arguments: Dict[str, Any]) -> List[TextContent]: """Add a role to a user""" guild = await discord_client.fetch_guild(int(arguments["server_id"])) member = await guild.fetch_member(int(arguments["user_id"])) role = guild.get_role(int(arguments["role_id"])) if not role: return [TextContent(type="text", text="Role not found")] await member.add_roles(role, reason="Role added via MCP") return [TextContent( type="text", text=f"Added role '{role.name}' to {member.display_name} in {guild.name}" )]
  • The input schema for the 'add_role' tool, defining the required parameters: server_id, user_id, role_id as strings.
    Tool( name="add_role", description="Add a role to a user", inputSchema={ "type": "object", "properties": { "server_id": { "type": "string", "description": "Discord server ID" }, "user_id": { "type": "string", "description": "User to add role to" }, "role_id": { "type": "string", "description": "Role ID to add" } }, "required": ["server_id", "user_id", "role_id"] } ),
  • The registration logic in the tool dispatcher that routes calls to 'add_role' (included in core_tool_names) to CoreToolHandlers.handle_add_role.
    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)

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

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