get_role_info
Retrieve detailed information about a Discord server role using guild and role IDs to manage permissions and settings.
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:50-79 (handler)The handler function that implements the core logic of get_role_info: fetches the Discord guild and role, extracts detailed properties including permissions, creation date, icon, members list, and returns formatted JSON response or error.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)Zod schema validating the input parameters for the tool: guildId (string) and roleId (string).{ guildId: z.string().describe('The ID of the server (guild)'), roleId: z.string().describe('The ID of the role'), },
- src/tools/role-tools.ts:44-79 (registration)The server.tool() call that registers the get_role_info tool on the MCP server, providing name, description, input schema, and handler function.'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/index.ts:57-57 (registration)Invocation of registerRoleTools(server) in the main MCP server setup, which registers all role tools including get_role_info.registerRoleTools(server);
- src/index.ts:14-14 (registration)Import of the registerRoleTools function used to register role management tools.import { registerRoleTools } from './tools/role-tools.js';