Skip to main content
Glama
scarecr0w12

discord-mcp

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
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
roleIdYesThe ID of the role

Implementation Reference

  • 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) }] };
    }
  • 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'),
    },
  • 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';

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