create_character
Generate a complete D&D 5e character with customizable stats, class, race, equipment, and abilities for tabletop roleplaying games.
Instructions
Create a new D&D 5e character with stats, class, race, and equipment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| race | No | Human | |
| class | No | Fighter | |
| level | No | ||
| background | No | ||
| characterType | No | pc | |
| stats | No | ||
| hp | No | ||
| maxHp | No | ||
| ac | No | ||
| speed | No | ||
| resistances | No | ||
| immunities | No | ||
| vulnerabilities | No | ||
| conditionImmunities | No | ||
| spellcastingAbility | No | ||
| knownSpells | No | ||
| preparedSpells | No | ||
| cantrips | No | ||
| skillProficiencies | No | ||
| saveProficiencies | No | ||
| equipment | No | ||
| customClass | No | ||
| customRace | No |
Implementation Reference
- src/registry.ts:449-462 (handler)The handler function for the 'create_character' tool. It parses the input arguments using createCharacterSchema, calls the createCharacter function with validated args, and returns a success response with the generated markdown or handles validation/runtime errors.handler: async (args) => { try { const validated = createCharacterSchema.parse(args); const result = createCharacter(validated); return success(result.markdown); } catch (err) { if (err instanceof z.ZodError) { const messages = err.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', '); return error(`Validation failed: ${messages}`); } const message = err instanceof Error ? err.message : String(err); return error(message); } },
- src/registry.ts:445-463 (registration)The registration entry for the 'create_character' tool in the toolRegistry, defining name, description, input schema (converted from Zod schema), and the handler function.create_character: { name: 'create_character', description: 'Create a new D&D 5e character with stats, class, race, and equipment', inputSchema: toJsonSchema(createCharacterSchema), handler: async (args) => { try { const validated = createCharacterSchema.parse(args); const result = createCharacter(validated); return success(result.markdown); } catch (err) { if (err instanceof z.ZodError) { const messages = err.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', '); return error(`Validation failed: ${messages}`); } const message = err instanceof Error ? err.message : String(err); return error(message); } }, },
- src/registry.ts:451-451 (schema)Usage of createCharacterSchema for input validation within the handler. The schema itself is imported from './modules/characters.js'.const validated = createCharacterSchema.parse(args);
- src/registry.ts:452-452 (helper)Call to the createCharacter helper function, which implements the core logic for creating a D&D 5e character and returns {markdown: string}.const result = createCharacter(validated);