Summary
manage_prefabs fails to save prefab-stage edits because save_prefab_stage appears to save the prefab preview scene with scene-save APIs instead of writing the prefab asset itself.
Error
Error saving prefab stage: EditorSceneManager.SetActive failed; you can not save a preview scene
Minimal Repro
- Open any prefab through
manage_prefabs(action="open_prefab_stage", prefab_path="Assets/.../Example.prefab").
- Make a simple change inside the prefab stage, such as adding a child GameObject.
- Call
manage_prefabs(action="save_prefab_stage").
- Observe the save failure instead of the prefab asset being persisted.
Likely Root Cause
save_prefab_stage appears to use scene-save APIs on a prefab preview scene. In MCPForUnity/Editor/Tools/Prefabs/ManagePrefabs.cs, the current implementation marks prefabStage.scene dirty and then calls EditorSceneManager.SaveScene(prefabStage.scene), but prefab stages use preview scenes rather than normal savable editor scenes.
The prefab-stage save path likely needs to use the prefab asset workflow instead (for example, saving prefabStage.prefabContentsRoot back to prefabStage.assetPath) and close_prefab_stage(saveBeforeClose: true) should reuse the same path.
Summary
manage_prefabsfails to save prefab-stage edits becausesave_prefab_stageappears to save the prefab preview scene with scene-save APIs instead of writing the prefab asset itself.Error
Error saving prefab stage: EditorSceneManager.SetActive failed; you can not save a preview sceneMinimal Repro
manage_prefabs(action="open_prefab_stage", prefab_path="Assets/.../Example.prefab").manage_prefabs(action="save_prefab_stage").Likely Root Cause
save_prefab_stageappears to use scene-save APIs on a prefab preview scene. InMCPForUnity/Editor/Tools/Prefabs/ManagePrefabs.cs, the current implementation marksprefabStage.scenedirty and then callsEditorSceneManager.SaveScene(prefabStage.scene), but prefab stages use preview scenes rather than normal savable editor scenes.The prefab-stage save path likely needs to use the prefab asset workflow instead (for example, saving
prefabStage.prefabContentsRootback toprefabStage.assetPath) andclose_prefab_stage(saveBeforeClose: true)should reuse the same path.