Skip to main content
Glama

generate_and_implement_scenario

Create and automatically implement complete RPG scenarios in RPG Maker MZ projects. Specify theme, style, and length to generate story content, characters, and game events directly into your project directory.

Instructions

Generate and immediately implement a complete RPG scenario (all-in-one)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
api_keyNoGemini API key (optional)
lengthYesLength of the game scenario
project_pathYesPath to the RPG Maker MZ project directory
styleYesStyle or tone
themeYesTheme or genre of the game

Implementation Reference

  • Core handler function that orchestrates scenario generation using Gemini AI and implementation into the RPG Maker MZ project by creating maps, characters, events, items, skills, and saving metadata.
    export async function generateAndImplementScenario(request: ScenarioGenerationRequest): Promise<{ success: boolean; scenario?: GeneratedScenario; implementation?: any; error?: string }> { // Generate scenario const genResult = await generateScenarioWithGemini(request); if (!genResult.success || !genResult.scenario) { return { success: false, error: genResult.error }; } // Implement scenario const implResult = await implementScenario(request.projectPath, genResult.scenario); if (!implResult.success) { return { success: false, scenario: genResult.scenario, error: `Scenario generated but implementation failed: ${implResult.error}` }; } // Save scenario metadata try { const scenarioFile = path.join(request.projectPath, "scenario.json"); await fs.writeFile(scenarioFile, JSON.stringify(genResult.scenario, null, 2), "utf-8"); } catch { // Non-critical error } return { success: true, scenario: genResult.scenario, implementation: implResult.details }; }
  • src/index.ts:1313-1325 (registration)
    MCP tool dispatch/registration in the CallToolRequestSchema handler. Parses arguments, calls the generateAndImplementScenario function, and returns the result as MCP content.
    case "generate_and_implement_scenario": { const request: ScenarioGenerationRequest = { projectPath: args.project_path as string, theme: args.theme as string, style: args.style as string, length: args.length as "short" | "medium" | "long", apiKey: args.api_key as string | undefined, }; const result = await generateAndImplementScenario(request); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
  • JSON input schema definition for the tool, registered in the ListToolsRequestSchema response.
    name: "generate_and_implement_scenario", description: "Generate and immediately implement a complete RPG scenario (all-in-one)", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to the RPG Maker MZ project directory", }, theme: { type: "string", description: "Theme or genre of the game", }, style: { type: "string", description: "Style or tone", }, length: { type: "string", enum: ["short", "medium", "long"], description: "Length of the game scenario", }, api_key: { type: "string", description: "Gemini API key (optional)", }, }, required: ["project_path", "theme", "style", "length"], }, },
  • TypeScript type definition for the tool input parameters, used in the handler and dispatch.
    export interface ScenarioGenerationRequest { projectPath: string; theme: string; style: string; length: "short" | "medium" | "long"; apiKey?: string; }
  • Helper function that implements the generated scenario by calling low-level tools to add classes, actors, maps, items, skills, and events to the project.
    export async function implementScenario(projectPath: string, scenario: GeneratedScenario): Promise<{ success: boolean; details?: any; error?: string }> { try { const results: any = { maps: [], characters: [], events: [], items: [], skills: [] }; // Create classes first const createdClasses = new Set<number>(); for (const char of scenario.characters) { if (!createdClasses.has(char.classId)) { await addClass(projectPath, char.classId, char.className); createdClasses.add(char.classId); } } // Create characters/actors for (const char of scenario.characters) { const result = await addActor(projectPath, char.id, char.name); results.characters.push(result); } // Create maps for (const map of scenario.maps) { const result = await createMap(projectPath, map.id, map.name, map.width, map.height); results.maps.push(result); } // Create items for (const item of scenario.items) { const result = await addItem(projectPath, item.id, item.name); results.items.push(result); } // Create skills for (const skill of scenario.skills) { const result = await addSkill(projectPath, skill.id, skill.name); results.skills.push(result); } // Create events with dialogues for (const event of scenario.events) { // Add event await addEvent(projectPath, event.mapId, event.eventId, event.name, event.x, event.y); // Add dialogue commands for (let i = 0; i < event.dialogues.length; i++) { const dialogue = event.dialogues[i]; if (i === 0) { // First dialogue uses Show Text command (101) await addEventCommand(projectPath, event.mapId, event.eventId, 0, { code: 101, indent: 0, parameters: ["", 0, 0, 2] }); } // Add dialogue text (401) await addEventCommand(projectPath, event.mapId, event.eventId, 0, { code: 401, indent: 0, parameters: [dialogue] }); } results.events.push({ eventId: event.eventId, mapId: event.mapId }); } return { success: true, details: results }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } }

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