Skip to main content
Glama

remove_role

Remove a role from a Discord user by specifying user ID and role ID. This tool helps manage user permissions and access within Discord servers.

Instructions

Remove a role from a Discord user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYes
role_idYes
server_idNo
reasonNo

Implementation Reference

  • The handler function that executes the remove_role tool: fetches guild, member, and role, then removes the role from the member.
    @staticmethod async def handle_remove_role(discord_client, arguments: Dict[str, Any]) -> List[TextContent]: """Remove a role from 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.remove_roles(role, reason="Role removed via MCP") return [TextContent( type="text", text=f"Removed role '{role.name}' from {member.display_name} in {guild.name}" )]
  • Registers the 'remove_role' tool in the MCP server's tool list, including its name, description, and input schema validation.
    Tool( name="remove_role", description="Remove a role from a user", inputSchema={ "type": "object", "properties": { "server_id": { "type": "string", "description": "Discord server ID" }, "user_id": { "type": "string", "description": "User to remove role from" }, "role_id": { "type": "string", "description": "Role ID to remove" } }, "required": ["server_id", "user_id", "role_id"] } ),
  • Routes calls to 'remove_role' (and other core tools) to the corresponding CoreToolHandlers.handle_remove_role method.
    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)
  • Defines the input schema for the 'remove_role' tool, specifying required string parameters: server_id, user_id, role_id.
    inputSchema={ "type": "object", "properties": { "server_id": { "type": "string", "description": "Discord server ID" }, "user_id": { "type": "string", "description": "User to remove role from" }, "role_id": { "type": "string", "description": "Role ID to remove" } }, "required": ["server_id", "user_id", "role_id"] } ),

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