Skip to main content
Glama

end_encounter

Conclude combat encounters in ChatRPG by recording outcomes like victory or defeat, generating statistics, and preserving logs for review.

Instructions

End a combat encounter with outcome tracking and optional summary generation. Supports victory, defeat, fled, negotiated outcomes. Can preserve encounter log for review.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
encounterIdYesThe encounter to end
outcomeYesHow combat ended
generateSummaryNoInclude combat statistics
preserveLogNoKeep encounter accessible after end
notesNoDM notes about the encounter

Implementation Reference

  • Registration of the 'end_encounter' tool in the central tool registry, including name, description, input schema conversion from Zod endEncounterSchema, and handler wrapper.
    end_encounter: { name: 'end_encounter', description: 'End a combat encounter with outcome tracking and optional summary generation. Supports victory, defeat, fled, negotiated outcomes. Can preserve encounter log for review.', inputSchema: toJsonSchema(endEncounterSchema), handler: async (args) => { try { const validated = endEncounterSchema.parse(args); const result = endEncounter(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 end_encounter. Validates input arguments using endEncounterSchema, executes the core endEncounter function with validated args, and formats success/error responses.
    handler: async (args) => { try { const validated = endEncounterSchema.parse(args); const result = endEncounter(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); }
  • Import statement bringing in endEncounterSchema (Zod schema for input validation) and endEncounter (core handler function) 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