Skip to main content
Glama
scarecr0w12

discord-mcp

assign_role

Assign a specific role to a Discord server member using guild, member, and role IDs to manage permissions and organization.

Instructions

Assign a role to a member

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
memberIdYesThe ID of the member
roleIdYesThe ID of the role to assign
reasonNoReason for assigning the role

Implementation Reference

  • The handler function for the 'assign_role' tool. It fetches the Discord guild, member, and role, then adds the role to the member using `member.roles.add()`. Handles errors with `withErrorHandling` and formats the response as JSON or error text.
    async ({ guildId, memberId, roleId, reason }) => {
      const result = await withErrorHandling(async () => {
        const client = await getDiscordClient();
        const guild = await client.guilds.fetch(guildId);
        const member = await guild.members.fetch(memberId);
        const role = await guild.roles.fetch(roleId);
        if (!role) throw new Error('Role not found');
    
        await member.roles.add(role, reason);
        return {
          memberId,
          roleId,
          roleName: role.name,
          memberName: member.displayName,
          message: 'Role assigned successfully',
        };
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Zod input schema defining parameters for the 'assign_role' tool: required guildId, memberId, roleId; optional reason.
    {
      guildId: z.string().describe('The ID of the server (guild)'),
      memberId: z.string().describe('The ID of the member'),
      roleId: z.string().describe('The ID of the role to assign'),
      reason: z.string().optional().describe('Reason for assigning the role'),
    },
  • The server.tool() call that registers the 'assign_role' tool on the MCP server, including description, input schema, and handler function.
    server.tool(
      'assign_role',
      'Assign a role to a member',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        memberId: z.string().describe('The ID of the member'),
        roleId: z.string().describe('The ID of the role to assign'),
        reason: z.string().optional().describe('Reason for assigning the role'),
      },
      async ({ guildId, memberId, roleId, reason }) => {
        const result = await withErrorHandling(async () => {
          const client = await getDiscordClient();
          const guild = await client.guilds.fetch(guildId);
          const member = await guild.members.fetch(memberId);
          const role = await guild.roles.fetch(roleId);
          if (!role) throw new Error('Role not found');
    
          await member.roles.add(role, reason);
          return {
            memberId,
            roleId,
            roleName: role.name,
            memberName: member.displayName,
            message: 'Role assigned successfully',
          };
        });
    
        if (!result.success) {
          return { content: [{ type: 'text', text: result.error }], isError: true };
        }
    
        return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • src/index.ts:57-57 (registration)
    Top-level call to registerRoleTools(server), which includes registration of the 'assign_role' tool among other role tools.
    registerRoleTools(server);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('assign') but doesn't explain what this entails—whether it requires specific permissions, if it's idempotent, what happens on conflicts, or what the response looks like. For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps.

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 no wasted words, making it easy to parse and front-loaded with the core action. It's appropriately sized for a straightforward tool, though this conciseness comes at the cost of depth.

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 that this is a mutation tool with no annotations and no output schema, the description is insufficiently complete. It lacks critical context like required permissions, error conditions, return values, or how it differs from sibling tools, leaving the agent with incomplete operational understanding.

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 input schema has 100% description coverage, with clear parameter documentation (guildId, memberId, roleId, reason). The description doesn't add any meaning beyond what the schema already provides, such as explaining relationships between parameters or usage nuances, so it meets the baseline for high schema coverage.

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 ('assign') and target ('a role to a member'), making the purpose immediately understandable. It doesn't differentiate from sibling tools like 'remove_role' or 'modify_member', but it's specific enough to convey the core function without being tautological.

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 like 'remove_role' or 'modify_member', nor does it mention prerequisites such as required permissions or contextual constraints. It's a bare statement of function without usage context.

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

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

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