Skip to main content
Glama

delete_role

Remove a role from a Discord server by specifying the server and role IDs. This tool helps manage server permissions and organization by eliminating unnecessary roles.

Instructions

Delete a role from a Discord server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
roleIdYesThe ID of the role to delete
reasonNoReason for deleting the role

Implementation Reference

  • Full implementation of the 'delete_role' MCP tool: registers the tool with input schema (guildId, roleId, optional reason), fetches Discord guild and role, deletes the role if found, wraps in error handling, and returns JSON response.
    server.tool( 'delete_role', 'Delete a role from a Discord server', { guildId: z.string().describe('The ID of the server (guild)'), roleId: z.string().describe('The ID of the role to delete'), reason: z.string().optional().describe('Reason for deleting the role'), }, async ({ guildId, roleId, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const role = await guild.roles.fetch(roleId); if (!role) throw new Error('Role not found'); const roleName = role.name; await role.delete(reason); return { roleId, roleName, message: 'Role deleted 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 for delete_role tool parameters.
    { guildId: z.string().describe('The ID of the server (guild)'), roleId: z.string().describe('The ID of the role to delete'), reason: z.string().optional().describe('Reason for deleting the role'), },
  • src/index.ts:56-56 (registration)
    Registers all role tools including delete_role by calling registerRoleTools on the MCP server instance.
    registerRoleTools(server);
  • src/index.ts:14-14 (registration)
    Imports the registerRoleTools function used to register the delete_role tool.
    import { registerRoleTools } from './tools/role-tools.js';

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