Skip to main content
Glama

modify_terrain

Modify combat terrain by adding, removing, or clearing obstacles, difficult terrain, water, and hazards to simulate spells, abilities, and environmental effects.

Instructions

Add, remove, or clear terrain in a combat encounter. Supports obstacles, difficult terrain, water, and hazards. Use for dynamic battlefield changes from spells (Wall of Stone, Spike Growth), abilities, or environmental effects.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
encounterIdYesThe encounter to modify
operationYesOperation type
terrainTypeYesType of terrain
positionsNoArray of "x,y" coordinate strings
hazardDetailsNoDetails for hazard terrain
sourceNoSource of terrain change (spell, ability, etc.)
durationNoRounds until auto-removed

Implementation Reference

  • Registration of the 'modify_terrain' tool in the central registry. Includes description, input schema conversion from Zod schema, and a handler that performs validation and delegates to the core modifyTerrain implementation.
    modify_terrain: { name: 'modify_terrain', description: 'Add, remove, or clear terrain in a combat encounter. Supports obstacles, difficult terrain, water, and hazards. Use for dynamic battlefield changes from spells (Wall of Stone, Spike Growth), abilities, or environmental effects.', inputSchema: toJsonSchema(modifyTerrainSchema), handler: async (args) => { try { const validated = modifyTerrainSchema.parse(args); const result = modifyTerrain(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 function for modify_terrain. It validates the input arguments using modifyTerrainSchema, calls the modifyTerrain function with validated args, and returns the result wrapped in a success response. Handles Zod validation errors and general exceptions.
    handler: async (args) => { try { const validated = modifyTerrainSchema.parse(args); const result = modifyTerrain(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 input schema for the tool, converted from the Zod schema modifyTerrainSchema using toJsonSchema for MCP compatibility.
    inputSchema: toJsonSchema(modifyTerrainSchema),
  • Import statement bringing in the modifyTerrain function (handler logic) and modifyTerrainSchema 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