Skip to main content
Glama

level_up

Increase character levels in ChatRPG by adjusting HP, proficiency bonus, spell slots, and tracking new features. Supports multi-level jumps and batch processing for party advancement.

Instructions

Level up a character. Increases level, HP (roll/average/max/manual), proficiency bonus, and spell slots. Supports custom class hit dice and resource scaling. Multi-level jumps allowed (e.g., 1→5). Batch support for party level-ups. Optionally track new features and spells learned.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
characterIdNo
characterNameNo
targetLevelNo
hpMethodNoaverage
manualHpNo
manualRollNo
newFeaturesNo
newSpellsNo
batchNo

Implementation Reference

  • Handler function that executes the level_up tool: validates input using levelUpSchema, executes levelUp(validated), processes the result (expects {success, markdown, error}), returns formatted success/error response.
    handler: async (args) => {
      try {
        const validated = levelUpSchema.parse(args);
        const result = levelUp(validated);
    
        if (!result.success) {
          return error(result.error || 'Failed to level up');
        }
    
        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);
      }
    },
  • Registration of the 'level_up' tool in the toolRegistry object, defining name, description, input schema, and handler.
    level_up: {
      name: 'level_up',
      description: 'Level up a character. Increases level, HP (roll/average/max/manual), proficiency bonus, and spell slots. Supports custom class hit dice and resource scaling. Multi-level jumps allowed (e.g., 1→5). Batch support for party level-ups. Optionally track new features and spells learned.',
      inputSchema: toJsonSchema(levelUpSchema),
      handler: async (args) => {
        try {
          const validated = levelUpSchema.parse(args);
          const result = levelUp(validated);
    
          if (!result.success) {
            return error(result.error || 'Failed to level up');
          }
    
          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 levelUpSchema Zod schema imported from './modules/characters.js' and used for input validation in the level_up handler.
    levelUpSchema

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