Skip to main content
Glama

add_role

Assign a specific Discord role to a user by specifying the server ID, user ID, and role ID. Simplifies role management within Discord servers for MCP clients.

Instructions

Add a role to a user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
role_idYesRole ID to add
server_idYesDiscord server ID
user_idYesUser to add role to

Implementation Reference

  • Handler function for the 'add_role' tool. Fetches the guild, member, and role using the provided IDs, then adds the role to the member with a reason.
    elif name == "add_role": 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"])) await member.add_roles(role, reason="Role added via MCP") return [TextContent( type="text", text=f"Added role {role.name} to user {member.name}" )]
  • Registration of the 'add_role' tool via the list_tools() decorator. Defines the tool name, description, and input schema requiring server_id, user_id, and role_id.
    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"] } ),

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

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