generate_asset_batch
Generate multiple RPG Maker MZ assets in batch to streamline game development workflow by processing multiple asset creation requests simultaneously.
Instructions
Generate multiple RPG Maker MZ assets in batch
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| requests | Yes | Array of asset generation requests |
Implementation Reference
- src/asset-generation.ts:202-209 (handler)Core handler function that executes the batch asset generation by iterating over requests and invoking the single asset generator.export async function generateAssetBatch(requests: AssetGenerationRequest[]): Promise<Array<{ success: boolean; path?: string; error?: string }>> { const results = []; for (const request of requests) { const result = await generateAssetWithGemini(request); results.push(result); } return results; }
- src/asset-generation.ts:13-19 (schema)TypeScript type definition for individual asset generation requests used in the batch.export interface AssetGenerationRequest { projectPath: string; assetType: "character" | "face" | "tileset" | "battleback" | "enemy" | "sv_actor" | "picture"; prompt: string; filename: string; apiKey?: string; }
- src/index.ts:504-526 (registration)MCP tool registration including name, description, and input schema in the list_tools handler.name: "generate_asset_batch", description: "Generate multiple RPG Maker MZ assets in batch", inputSchema: { type: "object", properties: { requests: { type: "array", description: "Array of asset generation requests", items: { type: "object", properties: { project_path: { type: "string" }, asset_type: { type: "string" }, prompt: { type: "string" }, filename: { type: "string" }, api_key: { type: "string" }, }, }, }, }, required: ["requests"], }, },
- src/index.ts:1271-1277 (handler)MCP server request handler that processes tool calls for generate_asset_batch by delegating to the core function.case "generate_asset_batch": { const requests = args.requests as AssetGenerationRequest[]; const results = await generateAssetBatch(requests); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; }
- src/asset-generation.ts:41-117 (helper)Supporting function that performs the actual single asset generation using Gemini API, called by the batch handler.export async function generateAssetWithGemini(request: AssetGenerationRequest): Promise<{ success: boolean; path?: string; error?: string }> { try { // Validate inputs await validateProjectPath(request.projectPath); Validator.requireEnum( request.assetType, "assetType", ["character", "face", "tileset", "battleback", "enemy", "sv_actor", "picture"] as const ); Validator.requireString(request.prompt, "prompt"); Validator.requireString(request.filename, "filename"); const apiKey = validateGeminiAPIKey(request.apiKey); await Logger.info("Generating asset with Gemini", { projectPath: request.projectPath, assetType: request.assetType, filename: request.filename }); const specs = ASSET_SPECS[request.assetType]; const enhancedPrompt = buildPrompt(request.assetType, request.prompt, specs); // Call Gemini 2.5 Flash API with image generation const response = await APIHelper.fetchWithRetry( `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent?key=${apiKey}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ contents: [{ parts: [{ text: enhancedPrompt }] }], generationConfig: { temperature: 1.0, topK: 40, topP: 0.95, maxOutputTokens: 8192, } }) } ); if (!response.ok) { return { success: false, error: `API error: ${response.statusText}` }; } const data = await response.json(); // Extract image data (assuming Gemini returns base64 or URL) // Note: Gemini 2.5 Flash may not support direct image generation // This is a placeholder for the actual implementation const imageData = extractImageData(data); if (!imageData) { return { success: false, error: "No image data in response" }; } // Save image to appropriate directory const assetPath = getAssetPath(request.projectPath, request.assetType); await fs.mkdir(assetPath, { recursive: true }); const fullPath = path.join(assetPath, request.filename); await saveImage(fullPath, imageData); return { success: true, path: fullPath }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } }