Skip to main content
Glama

create_encounter

Generate D&D 5e combat encounters with participants, terrain, and initiative tracking for roleplaying games.

Instructions

Create a D&D 5e combat encounter with participants, terrain, and initiative tracking

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
seedNo
participantsYes
terrainNo
lightingNobright
surpriseNo

Implementation Reference

  • Registration of the 'create_encounter' tool, including name, description, input schema conversion from Zod schema, and handler function that validates arguments using createEncounterSchema and calls the createEncounter function to perform the logic.
    create_encounter: { name: 'create_encounter', description: 'Create a D&D 5e combat encounter with participants, terrain, and initiative tracking', inputSchema: toJsonSchema(createEncounterSchema), handler: async (args) => { try { const validated = createEncounterSchema.parse(args); const result = createEncounter(validated); return success(result); } 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 executes the core logic: Zod validation with createEncounterSchema, execution of createEncounter(validated), and formatting success/error response.
    handler: async (args) => { try { const validated = createEncounterSchema.parse(args); const result = createEncounter(validated); return success(result); } 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); } },
  • Usage of createEncounterSchema for input validation (schema imported from './modules/combat.js'). The schema definition itself is not in this file.
    const validated = createEncounterSchema.parse(args);
  • Call to the helper function createEncounter which contains the detailed implementation logic (imported from './modules/combat.js').
    const result = createEncounter(validated);
  • Import statement bringing in createEncounter function and createEncounterSchema from the combat module.
    import { manageCondition, manageConditionSchema, createEncounter, createEncounterSchema, executeAction, executeActionSchema, advanceTurn, advanceTurnSchema, rollDeathSave, rollDeathSaveSchema, modifyTerrain, modifyTerrainSchema, renderBattlefield, renderBattlefieldSchema, getEncounter, getEncounterSchema, endEncounter, endEncounterSchema, manageEncounter, manageEncounterSchema } from './modules/combat.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