Skip to main content
Glama

browse_races

Explore D&D 5e SRD races to view traits, ability bonuses, and subrace options for character creation.

Instructions

Browse D&D 5e SRD races. List all races or view a specific race's traits, ability bonuses, and subraces.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
race_nameNoName of a specific race to look up

Implementation Reference

  • Handler for fetching details of a single specific race.
    function handleSingleRace(db: Database.Database, raceName: string) {
      const race = getRaceByName(db, raceName);
      if (!race) {
        const allRaces = listRaces(db);
        const available = allRaces.map((r) => r.name).join(', ');
        return {
          content: [
            {
              type: 'text' as const,
              text: `Race "${raceName}" not found. Available races: ${available}`,
            },
          ],
          isError: true,
        };
      }
    
      const bonuses = safeJsonParse<AbilityBonus[]>(race.ability_bonuses, []);
      const traits = safeJsonParse<RaceTrait[]>(race.traits, []);
      const languages = safeJsonParse<string[]>(race.languages, []);
      const subraces = safeJsonParse<Subrace[]>(race.subraces, []);
    
      const sections: string[] = [
        `${race.name}`,
        '='.repeat(40),
        `Speed: ${race.speed} ft.`,
        `Size: ${race.size}`,
        `Ability Bonuses: ${formatAbilityBonuses(bonuses)}`,
        `Languages: ${languages.join(', ') || 'None'}`,
      ];
    
      // Traits
      if (traits.length > 0) {
        sections.push(`\nTraits (${traits.length}):`);
        sections.push(formatTraits(traits));
      }
    
      // Subraces
      if (subraces.length > 0) {
        sections.push(`\nSubraces (${subraces.length}):`);
        for (const subrace of subraces) {
          sections.push(`\n  ${subrace.name}`);
          if (subrace.description) {
            sections.push(`    ${subrace.description}`);
          }
          if (subrace.ability_bonuses && subrace.ability_bonuses.length > 0) {
            sections.push(
              `    Additional Ability Bonuses: ${formatAbilityBonuses(subrace.ability_bonuses)}`,
            );
          }
          if (subrace.traits && subrace.traits.length > 0) {
            sections.push(`    Subrace Traits:`);
            for (const trait of subrace.traits) {
              sections.push(`      ${trait.name}: ${trait.description}`);
            }
          }
        }
      }
    
      return { content: [{ type: 'text' as const, text: sections.join('\n') }] };
    }
  • Handler for listing all races.
    function handleListRaces(db: Database.Database) {
      const races = listRaces(db);
      if (races.length === 0) {
        return {
          content: [{ type: 'text' as const, text: 'No races found in the database.' }],
        };
      }
    
      const lines = races.map((race) => {
        const bonuses = safeJsonParse<AbilityBonus[]>(race.ability_bonuses, []);
        return `${race.name}\n  Speed: ${race.speed} ft.\n  Size: ${race.size}\n  Ability Bonuses: ${formatAbilityBonuses(bonuses)}`;
      });
    
      const text = `D&D 5e SRD Races (${races.length})\n${'='.repeat(40)}\n\n${lines.join('\n\n')}`;
      return { content: [{ type: 'text' as const, text }] };
    }
  • Registration function that binds the 'browse_races' tool to the MCP server.
    export function registerBrowseRaces(
      server: McpServer,
      db: Database.Database,
    ): void {
      server.registerTool(
        'browse_races',
        {
          description:
            "Browse D&D 5e SRD races. List all races or view a specific race's traits, ability bonuses, and subraces.",
          inputSchema: {
            race_name: z
              .string()
              .optional()
              .describe('Name of a specific race to look up'),
          },
        },
        async ({ race_name }) => {
          if (race_name) {
            return handleSingleRace(db, race_name);
          }
          return handleListRaces(db);
        },
      );
    }

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/gregario/dnd-oracle'

If you have feedback or need assistance with the MCP directory API, please join our Discord server