generate_asset
Create RPG Maker MZ game assets including characters, faces, tilesets, and battle backgrounds using AI generation with text prompts.
Instructions
Generate RPG Maker MZ asset using Gemini 2.5 Flash (characters, faces, tilesets, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | Gemini API key (optional, uses GEMINI_API_KEY env var if not provided) | |
| asset_type | Yes | Type of asset to generate | |
| filename | Yes | Filename for the generated asset (with extension) | |
| project_path | Yes | Path to the RPG Maker MZ project directory | |
| prompt | Yes | Description of the asset to generate |
Implementation Reference
- src/index.ts:473-502 (schema)Input schema definition for the 'generate_asset' MCP tool, specifying parameters like project_path, asset_type, prompt, filename, and optional api_key.name: "generate_asset", description: "Generate RPG Maker MZ asset using Gemini 2.5 Flash (characters, faces, tilesets, etc.)", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to the RPG Maker MZ project directory", }, asset_type: { type: "string", enum: ["character", "face", "tileset", "battleback", "enemy", "sv_actor", "picture"], description: "Type of asset to generate", }, prompt: { type: "string", description: "Description of the asset to generate", }, filename: { type: "string", description: "Filename for the generated asset (with extension)", }, api_key: { type: "string", description: "Gemini API key (optional, uses GEMINI_API_KEY env var if not provided)", }, }, required: ["project_path", "asset_type", "prompt", "filename"], }, },
- src/index.ts:1257-1269 (handler)MCP tool dispatcher handler for 'generate_asset' that constructs AssetGenerationRequest and calls generateAssetWithGemini.case "generate_asset": { const request: AssetGenerationRequest = { projectPath: args.project_path as string, assetType: args.asset_type as any, prompt: args.prompt as string, filename: args.filename as string, apiKey: args.api_key as string | undefined, }; const result = await generateAssetWithGemini(request); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- src/asset-generation.ts:41-117 (handler)Core implementation of asset generation using Gemini API: validates input, builds enhanced prompt, calls API, extracts image data, saves to project directory.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) }; } }
- src/asset-generation.ts:13-19 (schema)TypeScript interface defining the input parameters for asset generation, matching the MCP tool schema.export interface AssetGenerationRequest { projectPath: string; assetType: "character" | "face" | "tileset" | "battleback" | "enemy" | "sv_actor" | "picture"; prompt: string; filename: string; apiKey?: string; }
- src/index.ts:24-24 (helper)Import of the generateAssetWithGemini handler and AssetGenerationRequest type from asset-generation.ts.generateAssetWithGemini,