discord_create_role
Create a new role in a Discord server with custom name, color, permissions, and display settings to organize members and manage access.
Instructions
Create a new role in a guild.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guild_id | Yes | ||
| name | Yes | ||
| color | No | Hex color e.g. #FF5733 | |
| hoist | No | ||
| mentionable | No | ||
| permissions | No | e.g. ['SendMessages','ViewChannel'] |
Implementation Reference
- src/tools/roles.ts:134-147 (handler)The handler logic for "discord_create_role" which interacts with the discord.js library to create a role in a guild.
case "discord_create_role": { const guild = await discord.guilds.fetch(validateId(args.guild_id, "guild_id")); const perms = parsePerms(args.permissions); const role = await guild.roles.create({ name: args.name as string, color: args.color as ColorResolvable | undefined, hoist: args.hoist as boolean | undefined, mentionable: args.mentionable as boolean | undefined, permissions: perms ? new PermissionsBitField(perms.map((p) => PermissionsBitField.Flags[p as keyof typeof PermissionsBitField.Flags])) : undefined, }); return { content: [{ type: "text", text: `✅ Role "${role.name}" created (id: ${role.id}).` }] }; } - src/tools/roles.ts:16-31 (schema)The MCP tool definition (schema) for "discord_create_role".
{ name: "discord_create_role", description: "Create a new role in a guild.", inputSchema: { type: "object", properties: { guild_id: { type: "string" }, name: { type: "string" }, color: { type: "string", description: "Hex color e.g. #FF5733" }, hoist: { type: "boolean" }, mentionable: { type: "boolean" }, permissions: { type: "array", items: { type: "string" }, description: "e.g. ['SendMessages','ViewChannel']" }, }, required: ["guild_id", "name"], }, },