Skip to main content
Glama

advance_turn

Progress combat encounters by moving to the next combatant's turn, managing round transitions, updating conditions, and tracking initiative order.

Instructions

Advance to the next combatant's turn in an encounter. Handles round transitions when all combatants have acted, ticks condition durations (removing expired conditions), clears action economy for the previous combatant, and provides death save reminders for combatants at 0 HP. Returns ASCII-formatted turn info with initiative order preview.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
encounterIdYesActive encounter ID
processEffectsNoProcess start/end turn effects
processAurasNoProcess aura effects

Implementation Reference

  • Registration of the 'advance_turn' MCP tool, including metadata, input schema reference (advanceTurnSchema), and handler wrapper that validates arguments and delegates to the core advanceTurn function.
    advance_turn: { name: 'advance_turn', description: 'Advance to the next combatant\'s turn in an encounter. Handles round transitions when all combatants have acted, ticks condition durations (removing expired conditions), clears action economy for the previous combatant, and provides death save reminders for combatants at 0 HP. Returns ASCII-formatted turn info with initiative order preview.', inputSchema: toJsonSchema(advanceTurnSchema), handler: async (args) => { try { const validated = advanceTurnSchema.parse(args); const result = advanceTurn(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 MCP tool handler for 'advance_turn'. Performs Zod validation on input args using advanceTurnSchema, executes the core advanceTurn(validated) logic, and handles success/error responses.
    handler: async (args) => { try { const validated = advanceTurnSchema.parse(args); const result = advanceTurn(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); } },
  • Reference to the Zod input schema (advanceTurnSchema) converted to JSON Schema for MCP tool input validation. Schema imported from './modules/combat.js'.
    inputSchema: toJsonSchema(advanceTurnSchema),
  • Import statement bringing in the advanceTurn function (core handler logic) and advanceTurnSchema 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