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
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| roleId | Yes | The ID of the role |
Implementation Reference
- src/tools/role-tools.ts:43-80 (registration)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) }] }; } );
- src/tools/role-tools.ts:50-79 (handler)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) }] }; }
- src/tools/role-tools.ts:46-49 (schema)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);