Skip to main content
Glama

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
NameRequiredDescriptionDefault
characterIdNo
characterNameNo
restTypeNo
hitDiceToSpendNo
restoreHpNo
restoreSpellSlotsNo
restoreHitDiceNo
clearConditionsNo
uninterruptedNo
batchNo

Implementation Reference

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

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/Mnehmos/ChatRPG'

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