Editor/Mcp/BridgeWorkflowTools.cs

Editor toolset wrapper for MCP bridge workflow. Exposes three MCP tools: checkpoint_scene to snapshot the entire open scene to temp storage, list_checkpoints to enumerate saved snapshots, and restore_checkpoint to replace the open scene with a checkpoint by id.

Networking
// AUTO-GENERATED by scripts/emit-mcp-wrappers.mjs — DO NOT EDIT.
// Regenerate: node scripts/extract-manifest.mjs && node scripts/emit-mcp-wrappers.mjs
// Source of truth: sbox-mcp-server/src/tools/ (zod schemas) → scripts/tools-manifest.json

using System.Text.Json.Nodes;
using System.Threading.Tasks;
using Editor.Mcp;

/// <summary>
/// Agent workflow safety net: snapshot the whole scene to temp storage before risky changes
/// (checkpoint_scene), browse snapshots (list_checkpoints), and roll the scene back
/// (restore_checkpoint). The undo story for bridge mutations while the engine's snapshot API stays
/// addon-inaccessible.
/// </summary>
[McpToolset( "bridge_workflow", "Agent workflow safety net: snapshot the whole scene to temp storage before risky changes (checkpoint_scene), browse snapshots (list_checkpoints), and roll the scene back (restore_checkpoint). The undo story for bridge mutations while the engine's snapshot API stays addon-inaccessible." )]
public static class BridgeWorkflowTools
{
	/// <summary>
	/// Snapshot the ENTIRE open scene (every root GameObject, full serialization) to temp storage
	/// OUTSIDE the project. The agent-side undo: checkpoint before risky batch edits or experimental
	/// changes, roll back with restore_checkpoint if they go wrong. Returns { checkpointed, id, label,
	/// scene, rootObjects, sizeBytes } — keep the id. Refused during play mode (runtime state would
	/// poison the snapshot). Snapshots survive editor restarts (temp dir, subject to OS cleanup);
	/// browse them with list_checkpoints.
	/// </summary>
	/// <param name="label">Short label baked into the checkpoint id (e.g. 'before-batch-tint'). Defaults to 'checkpoint'.</param>
	[McpTool.ReadOnly( "checkpoint_scene" )]
	public static Task<object> CheckpointScene( string label = null )
		=> McpGate.Run( "checkpoint_scene", McpGate.Args( ( "label", label ) ) );

	/// <summary>
	/// List this project's scene checkpoints (newest first). Returns { total, checkpoints } — each {
	/// id, createdUtc, sizeBytes }. Pass an id to restore_checkpoint to roll the scene back, or create
	/// one first with checkpoint_scene. Read-only; no limit (checkpoints are few).
	/// </summary>
	[McpTool.ReadOnly( "list_checkpoints" )]
	public static Task<object> ListCheckpoints()
		=> McpGate.Run( "list_checkpoints", McpGate.Args() );

	/// <summary>
	/// REPLACE the open scene's entire contents with a checkpoint_scene snapshot: destroys every
	/// current root object, then rebuilds the snapshot's tree (guids preserved, so internal references
	/// stay wired). DESTRUCTIVE — requires an explicit id (from checkpoint_scene or list_checkpoints),
	/// never guesses. Returns { restored, id, destroyedRoots, restoredRoots }. The scene FILE on disk
	/// is untouched until save_scene. Scene-mutating: refused during play mode.
	/// </summary>
	/// <param name="id">Checkpoint id to restore (e.g. 'cp_20260709_153000_before-batch-tint').</param>
	[McpTool( "restore_checkpoint" )]
	public static Task<object> RestoreCheckpoint( string id )
		=> McpGate.Run( "restore_checkpoint", McpGate.Args( ( "id", id ) ) );
}