take_rest
Process short or long rests for D&D 5e characters to heal using hit dice, restore health points, and clear conditions. Supports batch processing for party management.
Instructions
Process short or long rest for D&D 5e character. Short rest: spend hit dice to heal. Long rest: restore all HP, half hit dice (rounded up), and clear until_rest conditions. Supports batch for party rests.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| characterId | No | ||
| characterName | No | ||
| restType | No | ||
| hitDiceToSpend | No | ||
| restoreHp | No | ||
| restoreSpellSlots | No | ||
| restoreHitDice | No | ||
| clearConditions | No | ||
| uninterrupted | No | ||
| batch | No |
Implementation Reference
- src/registry.ts:540-562 (registration)Registration of the 'take_rest' MCP tool. Defines name, description, converts Zod schema to JSON schema for MCP compatibility, and provides typed handler that validates input and delegates to core takeRest implementation.take_rest: { name: 'take_rest', description: 'Process short or long rest for D&D 5e character. Short rest: spend hit dice to heal. Long rest: restore all HP, half hit dice (rounded up), and clear until_rest conditions. Supports batch for party rests.', inputSchema: toJsonSchema(takeRestSchema), handler: async (args) => { try { const validated = takeRestSchema.parse(args); const result = takeRest(validated); if (!result.success) { return error(result.error || 'Failed to process rest'); } 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:544-561 (handler)The tool handler function. Performs Zod validation on input arguments using takeRestSchema, executes the core takeRest logic function with validated args, handles success/error responses with markdown formatting, and catches validation/runtime errors.handler: async (args) => { try { const validated = takeRestSchema.parse(args); const result = takeRest(validated); if (!result.success) { return error(result.error || 'Failed to process rest'); } 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:546-547 (schema)Reference to takeRestSchema used for input validation (Zod schema parsed from args before calling handler). Schema imported from './modules/characters.js'.const validated = takeRestSchema.parse(args); const result = takeRest(validated);
- src/registry.ts:206-223 (helper)Import statement for character-related tools including the core takeRest function (implements rest mechanics) and takeRestSchema (Zod input schema) from characters module.import { createCharacter, createCharacterSchema, getCharacter, getCharacterSchema, updateCharacter, updateCharacterSchema, deleteCharacter, deleteCharacterSchema, takeRest, takeRestSchema, manageSpellSlots, manageSpellSlotsSchema, rollCheck, rollCheckSchema, levelUp, levelUpSchema } from './modules/characters.js';