Skip to main content
Glama

roll_check

Roll D&D 5e dice for skill checks, saving throws, attack rolls, and initiative to resolve game actions and determine outcomes.

Instructions

Roll D&D 5e checks including skill checks, ability checks, saving throws, attack rolls, and initiative

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
characterIdNo
characterNameNo
checkTypeYes
skillNo
abilityNo
dcNo
advantageNo
disadvantageNo
bonusNo
contestedByNo
contestedCheckNo

Implementation Reference

  • The registered handler for the 'roll_check' tool. It validates the input arguments using rollCheckSchema, calls the rollCheck function with validated args, and returns a formatted success response with markdown or an error.
    handler: async (args) => {
      try {
        const validated = rollCheckSchema.parse(args);
        const result = rollCheck(validated);
    
        if (!result.success) {
          return error(result.error || 'Failed to roll check');
        }
    
        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 'roll_check' tool in the toolRegistry object, defining name, description, input schema (converted from Zod schema), and handler.
    roll_check: {
      name: 'roll_check',
      description: 'Roll D&D 5e checks including skill checks, ability checks, saving throws, attack rolls, and initiative',
      inputSchema: toJsonSchema(rollCheckSchema),
      handler: async (args) => {
        try {
          const validated = rollCheckSchema.parse(args);
          const result = rollCheck(validated);
    
          if (!result.success) {
            return error(result.error || 'Failed to roll check');
          }
    
          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);
        }
      },
    },
  • Import declaration for rollCheck function and rollCheckSchema Zod schema used by the roll_check tool.
    rollCheck,
    rollCheckSchema,
  • Core execution: parsing with schema and calling rollCheck helper function with validated arguments.
    const validated = rollCheckSchema.parse(args);
    const result = rollCheck(validated);

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