saveScenario
Save generated Kotonoha Sisters Explainer scenarios to the exia novel game engine for future use and reference.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes |
Implementation Reference
- src/server.ts:87-118 (handler)The handler function for the 'saveScenario' MCP tool. It generates a scenario from the input 'topic' using generateVoiceroidScenario, parses it to exia format with parseVoiceroidScenario, saves it via exiaManager.saveScenario, and returns a success or error message.server.tool("saveScenario", { topic: z.string() }, async ({ topic }) => { try { // シナリオの生成 const rawScenario = await generateVoiceroidScenario({ topic, minLength: 2000 }); // シナリオのパースとexia形式への変換 const scenario = parseVoiceroidScenario(rawScenario); // シナリオの保存 await exiaManager.saveScenario(scenario); return { content: [ { type: "text", text: `「${topic}」についてのシナリオを保存しました。`, }, ], }; } catch (error) { console.error("Error saving scenario:", error); return { content: [ { type: "text", text: `シナリオの保存に失敗しました: ${error}`, }, ], isError: true, }; } });
- src/exia.ts:69-89 (helper)The ExiaManager.saveScenario method, which saves the provided Scenario object as JSON to the exia's scenarios directory (S_000.json). Ensures exia is set up and creates directories if needed.async saveScenario(scenario: Scenario): Promise<void> { if (!this.isSetup && !(await this.checkSetup())) { throw new Error("exia is not set up"); } const scenarioPath = path.join(this.exiaPath, "renderer", "src", "scenarios", "S_000.json"); try { // ディレクトリが存在するか確認 const scenarioDir = path.dirname(scenarioPath); if (!fs.existsSync(scenarioDir)) { fs.mkdirSync(scenarioDir, { recursive: true }); } fs.writeFileSync(scenarioPath, JSON.stringify(scenario, null, 2)); console.error("Scenario saved to:", scenarioPath); } catch (error) { console.error("Error saving scenario:", error); throw new Error("Failed to save scenario"); } }
- src/types.ts:30-36 (schema)TypeScript interface definition for the Scenario object used in saveScenario, defining the structure expected by exia's scenario format.export interface Scenario { id: string; backgroundFile: string; currentLineIndex: number; characters: Character[]; lines: Line[]; }