Skip to main content
Glama

get_role_info

Retrieve detailed information about a Discord role using server and role IDs to manage permissions and member assignments.

Instructions

Get detailed information about a specific role

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
roleIdYesThe ID of the role

Implementation Reference

  • Registration of the 'get_role_info' tool using server.tool(), including description, input schema with Zod, and the complete handler function.
    server.tool( 'get_role_info', 'Get detailed information about a specific role', { guildId: z.string().describe('The ID of the server (guild)'), roleId: z.string().describe('The ID of the role'), }, async ({ guildId, roleId }) => { 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'); return { id: role.id, name: role.name, color: role.hexColor, position: role.position, hoist: role.hoist, mentionable: role.mentionable, managed: role.managed, permissions: role.permissions.toArray(), createdAt: role.createdAt.toISOString(), icon: role.iconURL(), unicodeEmoji: role.unicodeEmoji, members: role.members.map((m) => ({ id: m.id, username: m.user.username })), editable: role.editable, }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
  • The core handler logic for 'get_role_info': fetches guild and role via Discord.js, collects comprehensive role details (id, name, color, permissions, members, etc.), wraps in withErrorHandling, and returns formatted JSON response.
    async ({ guildId, roleId }) => { 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'); return { id: role.id, name: role.name, color: role.hexColor, position: role.position, hoist: role.hoist, mentionable: role.mentionable, managed: role.managed, permissions: role.permissions.toArray(), createdAt: role.createdAt.toISOString(), icon: role.iconURL(), unicodeEmoji: role.unicodeEmoji, members: role.members.map((m) => ({ id: m.id, username: m.user.username })), editable: role.editable, }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
  • Input schema using Zod validators for required parameters: guildId (server ID) and roleId.
    { guildId: z.string().describe('The ID of the server (guild)'), roleId: z.string().describe('The ID of the role'), },
  • src/index.ts:56-56 (registration)
    Invocation of registerRoleTools(server) which registers the 'get_role_info' tool (and other role tools) to the MCP server instance.
    registerRoleTools(server);

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