Skip to main content
Glama
hanweg

mcp-discord

by hanweg

remove_role

Remove a specific role from a user in a Discord server by providing server ID, user ID, and role ID. Simplify role management with this integration tool.

Instructions

Remove a role from a user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
role_idYesRole ID to remove
server_idYesDiscord server ID
user_idYesUser to remove role from

Implementation Reference

  • Handler for the 'remove_role' tool. It retrieves the guild, member, and role using Discord API, then removes the role from the member with a specified reason.
    elif name == "remove_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.remove_roles(role, reason="Role removed via MCP")
        return [TextContent(
            type="text",
            text=f"Removed role {role.name} from user {member.name}"
        )]
  • Schema definition for the 'remove_role' tool, specifying required input parameters: server_id, user_id, role_id as strings.
    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"]
        }
    ),
  • The list_tools function registers all available tools, including 'remove_role', by returning a list of Tool objects to the MCP server.
    @app.list_tools()
    async def list_tools() -> List[Tool]:
        """List available Discord tools."""
        return [
            # Server Information Tools
            Tool(
                name="get_server_info",
                description="Get information about a Discord server",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "server_id": {
                            "type": "string",
                            "description": "Discord server (guild) ID"
                        }
                    },
                    "required": ["server_id"]
                }
            ),
            Tool(
                name="get_channels",
                description="Get a list of all channels in a Discord server",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "server_id": {
                            "type": "string",
                            "description": "Discord server (guild) ID"
                        }
                    },
                    "required": ["server_id"]
                }
            ),
            Tool(
                name="list_members",
                description="Get a list of members in a server",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "server_id": {
                            "type": "string",
                            "description": "Discord server (guild) ID"
                        },
                        "limit": {
                            "type": "number",
                            "description": "Maximum number of members to fetch",
                            "minimum": 1,
                            "maximum": 1000
                        }
                    },
                    "required": ["server_id"]
                }
            ),
    
            # Role Management Tools
            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"]
                }
            ),
            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"]
                }
            ),
    
            # Channel Management Tools
            Tool(
                name="create_text_channel",
                description="Create a new text channel",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "server_id": {
                            "type": "string",
                            "description": "Discord server ID"
                        },
                        "name": {
                            "type": "string",
                            "description": "Channel name"
                        },
                        "category_id": {
                            "type": "string",
                            "description": "Optional category ID to place channel in"
                        },
                        "topic": {
                            "type": "string",
                            "description": "Optional channel topic"
                        }
                    },
                    "required": ["server_id", "name"]
                }
            ),
            Tool(
                name="delete_channel",
                description="Delete a channel",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "channel_id": {
                            "type": "string",
                            "description": "ID of channel to delete"
                        },
                        "reason": {
                            "type": "string",
                            "description": "Reason for deletion"
                        }
                    },
                    "required": ["channel_id"]
                }
            ),
    
            # Message Reaction Tools
            Tool(
                name="add_reaction",
                description="Add a reaction to a message",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "channel_id": {
                            "type": "string",
                            "description": "Channel containing the message"
                        },
                        "message_id": {
                            "type": "string",
                            "description": "Message to react to"
                        },
                        "emoji": {
                            "type": "string",
                            "description": "Emoji to react with (Unicode or custom emoji ID)"
                        }
                    },
                    "required": ["channel_id", "message_id", "emoji"]
                }
            ),
            Tool(
                name="add_multiple_reactions",
                description="Add multiple reactions to a message",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "channel_id": {
                            "type": "string",
                            "description": "Channel containing the message"
                        },
                        "message_id": {
                            "type": "string",
                            "description": "Message to react to"
                        },
                        "emojis": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "description": "Emoji to react with (Unicode or custom emoji ID)"
                            },
                            "description": "List of emojis to add as reactions"
                        }
                    },
                    "required": ["channel_id", "message_id", "emojis"]
                }
            ),
            Tool(
                name="remove_reaction",
                description="Remove a reaction from a message",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "channel_id": {
                            "type": "string",
                            "description": "Channel containing the message"
                        },
                        "message_id": {
                            "type": "string",
                            "description": "Message to remove reaction from"
                        },
                        "emoji": {
                            "type": "string",
                            "description": "Emoji to remove (Unicode or custom emoji ID)"
                        }
                    },
                    "required": ["channel_id", "message_id", "emoji"]
                }
            ),
            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"]
                }
            ),
            Tool(
                name="read_messages",
                description="Read recent messages from a channel",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "channel_id": {
                            "type": "string",
                            "description": "Discord channel ID"
                        },
                        "limit": {
                            "type": "number",
                            "description": "Number of messages to fetch (max 100)",
                            "minimum": 1,
                            "maximum": 100
                        }
                    },
                    "required": ["channel_id"]
                }
            ),
            Tool(
                name="get_user_info",
                description="Get information about a Discord user",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "user_id": {
                            "type": "string",
                            "description": "Discord user ID"
                        }
                    },
                    "required": ["user_id"]
                }
            ),
            Tool(
                name="moderate_message",
                description="Delete a message and optionally timeout the user",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "channel_id": {
                            "type": "string",
                            "description": "Channel ID containing the message"
                        },
                        "message_id": {
                            "type": "string",
                            "description": "ID of message to moderate"
                        },
                        "reason": {
                            "type": "string",
                            "description": "Reason for moderation"
                        },
                        "timeout_minutes": {
                            "type": "number",
                            "description": "Optional timeout duration in minutes",
                            "minimum": 0,
                            "maximum": 40320  # Max 4 weeks
                        }
                    },
                    "required": ["channel_id", "message_id", "reason"]
                }
            ),
            Tool(
                name="list_servers",
                description="Get a list of all Discord servers the bot has access to with their details such as name, id, member count, and creation date.",
                inputSchema={
                    "type": "object",
                    "properties": {},
                    "required": []
                }
            )
        ]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Remove' implies a destructive mutation, the description doesn't specify whether this action is reversible, what permissions are required, or any side effects (e.g., role removal notifications). For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core action and target, making it easy to parse quickly. Every word earns its place, achieving optimal conciseness for this simple tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a destructive mutation with 3 required parameters) and the lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects like permissions, reversibility, or error conditions, nor does it explain the result of the operation. For a mutation tool, this leaves critical gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with all three parameters clearly documented in the input schema (role_id, server_id, user_id). The description adds no additional meaning beyond what the schema provides, such as explaining relationships between parameters or usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Remove') and target ('a role from a user'), which is specific and unambiguous. It distinguishes from sibling tools like 'add_role' by specifying removal rather than addition. However, it doesn't explicitly mention the Discord server context, which is implied but could be more precise.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing proper permissions), when not to use it, or how it relates to sibling tools like 'add_role' or 'list_members'. This leaves the agent with insufficient context for decision-making.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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