Skip to main content
Glama

add_event_command

Insert commands into RPG Maker MZ event pages to control game actions like displaying text, transferring players, or managing variables.

Instructions

Add a command to an event page (e.g., show text, transfer player, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesCommand code (e.g., 101=Show Text, 201=Transfer Player, 122=Control Variables)
event_idYesEvent ID
map_idYesMap ID
page_indexYesPage index (0-based)
parametersYesCommand parameters
project_pathYesPath to the RPG Maker MZ project directory

Implementation Reference

  • Core handler function that loads the map JSON, finds the event page, inserts the new command before the end command (code 0), and saves the map file.
    export async function addEventCommand( projectPath: string, mapId: number, eventId: number, pageIndex: number, command: { code: number; indent: number; parameters: any[] } ) { const mapFilename = `Map${String(mapId).padStart(3, "0")}.json`; const mapPath = path.join(projectPath, "data", mapFilename); const mapContent = await fs.readFile(mapPath, "utf-8"); const map = JSON.parse(mapContent); if (!map.events[eventId]) { throw new Error(`Event ${eventId} not found`); } const page = map.events[eventId].pages[pageIndex]; if (!page) { throw new Error(`Page ${pageIndex} not found`); } // Insert before the end command (code 0) page.list.splice(page.list.length - 1, 0, command); await fs.writeFile(mapPath, JSON.stringify(map, null, 0), "utf-8"); return { success: true }; }
  • src/index.ts:324-357 (registration)
    Tool registration in the ListTools response, defining the tool name, description, and input schema for MCP clients.
    { name: "add_event_command", description: "Add a command to an event page (e.g., show text, transfer player, etc.)", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to the RPG Maker MZ project directory", }, map_id: { type: "number", description: "Map ID", }, event_id: { type: "number", description: "Event ID", }, page_index: { type: "number", description: "Page index (0-based)", }, code: { type: "number", description: "Command code (e.g., 101=Show Text, 201=Transfer Player, 122=Control Variables)", }, parameters: { type: "array", description: "Command parameters", }, }, required: ["project_path", "map_id", "event_id", "page_index", "code", "parameters"], }, },
  • MCP server tool call dispatcher that parses input arguments, constructs the command object (with indent:0), calls the core addEventCommand handler, and returns the result as text content.
    case "add_event_command": { const projectPath = args.project_path as string; const mapId = args.map_id as number; const eventId = args.event_id as number; const pageIndex = args.page_index as number; const code = args.code as number; const parameters = args.parameters as any[]; const command = { code, indent: 0, parameters }; const result = await addEventCommand(projectPath, mapId, eventId, pageIndex, command); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }

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/ShunsukeHayashi/rpgmaker-mz-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server