add_event
Create new events on RPG Maker MZ maps by specifying coordinates, IDs, and names to build interactive game elements and narrative content.
Instructions
Add a new event to a map
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_id | Yes | Event ID | |
| map_id | Yes | Map ID | |
| name | Yes | Event name | |
| project_path | Yes | Path to the RPG Maker MZ project directory | |
| x | Yes | X coordinate | |
| y | Yes | Y coordinate |
Implementation Reference
- src/game-creation-tools.ts:172-190 (handler)The core handler function that implements the 'add_event' tool logic. Loads the map JSON file, creates a default event object, inserts it into the map's events array at the specified eventId, and saves the updated map file.export async function addEvent( projectPath: string, mapId: number, eventId: number, name: string, x: number, y: number ) { 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); const event = getDefaultEvent(eventId, name, x, y); map.events[eventId] = event; await fs.writeFile(mapPath, JSON.stringify(map, null, 0), "utf-8"); return { success: true, eventId }; }
- src/index.ts:290-323 (schema)The input schema and metadata definition for the 'add_event' tool, provided in the MCP server's listTools response.{ name: "add_event", description: "Add a new event to a map", 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", }, name: { type: "string", description: "Event name", }, x: { type: "number", description: "X coordinate", }, y: { type: "number", description: "Y coordinate", }, }, required: ["project_path", "map_id", "event_id", "name", "x", "y"], }, },
- src/index.ts:1179-1189 (registration)The registration and dispatching logic in the MCP server's CallToolRequest handler that extracts parameters from the tool call and invokes the addEvent handler function.case "add_event": { const projectPath = args.project_path as string; const mapId = args.map_id as number; const eventId = args.event_id as number; const name = args.name as string; const x = args.x as number; const y = args.y as number; const result = await addEvent(projectPath, mapId, eventId, name, x, y); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], };