Skip to main content
Glama

get_character

Retrieve existing D&D 5e character data by ID or name to access character sheets and stats for role-playing games.

Instructions

Retrieve an existing D&D 5e character by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
characterIdNo
characterNameNo
batchNo

Implementation Reference

  • Registration of the 'get_character' tool in toolRegistry. Defines name, description, converts getCharacterSchema to JSON schema for input validation, and provides a handler that parses arguments with getCharacterSchema and executes getCharacter function, returning formatted markdown success or error.
    get_character: {
      name: 'get_character',
      description: 'Retrieve an existing D&D 5e character by ID',
      inputSchema: toJsonSchema(getCharacterSchema),
      handler: async (args) => {
        try {
          const validated = getCharacterSchema.parse(args);
          const result = getCharacter(validated);
    
          if (!result.success) {
            return error(result.error || 'Failed to retrieve character');
          }
    
          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 main handler function for the get_character tool. Validates input arguments using getCharacterSchema, calls the getCharacter helper with validated args, and returns success with markdown or error based on result.
    handler: async (args) => {
      try {
        const validated = getCharacterSchema.parse(args);
        const result = getCharacter(validated);
    
        if (!result.success) {
          return error(result.error || 'Failed to retrieve character');
        }
    
        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 of getCharacterSchema (Zod schema for input validation) and getCharacter (core handler function) from './modules/characters.js'.
    getCharacter,
    getCharacterSchema,

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