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
| Name | Required | Description | Default |
|---|---|---|---|
| characterId | No | ||
| characterName | No | ||
| batch | No |
Implementation Reference
- src/registry.ts:465-488 (registration)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); } }, },
- src/registry.ts:469-487 (handler)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); } },
- src/registry.ts:209-210 (schema)Import of getCharacterSchema (Zod schema for input validation) and getCharacter (core handler function) from './modules/characters.js'.getCharacter, getCharacterSchema,