Editor/Mcp/BridgePlayModeTools.cs

Editor bridge toolset for play mode. Provides async wrappers that call McpGate to get/set component properties on live runtime objects, and to start/stop/check play mode state.

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>
/// Enter/exit play mode, check play state, and read/write component properties on live runtime
/// objects while playing.
/// </summary>
[McpToolset( "bridge_playmode", "Enter/exit play mode, check play state, and read/write component properties on live runtime objects while playing." )]
public static class BridgePlayModeTools
{
	/// <summary>
	/// Read a component property value during play mode. Must call start_play first.
	/// </summary>
	/// <param name="id">GUID of the GameObject.</param>
	/// <param name="component">Component type name.</param>
	/// <param name="property">Property name to read.</param>
	[McpTool.ReadOnly( "get_runtime_property" )]
	public static Task<object> GetRuntimeProperty( string id, string component, string property )
		=> McpGate.Run( "get_runtime_property", McpGate.Args( ( "id", id ), ( "component", component ), ( "property", property ) ) );

	/// <summary>
	/// Check current play state — returns 'playing', 'paused', or 'stopped'.
	/// </summary>
	[McpTool.ReadOnly( "is_playing" )]
	public static Task<object> IsPlaying()
		=> McpGate.Run( "is_playing", McpGate.Args() );

	/// <summary>
	/// Set a component property value during play mode — tweak values live while the game runs. Errors
	/// if the game is not playing (start_play first). Returns { set, id, component, property, value }
	/// like set_property; read it back with get_runtime_property. Runtime changes are DISCARDED when
	/// play mode stops — use set_property in edit mode to persist.
	/// </summary>
	/// <param name="id">GUID of the GameObject.</param>
	/// <param name="component">Component type name.</param>
	/// <param name="property">Property name to set.</param>
	/// <param name="value">New value. JSON value.</param>
	[McpTool( "set_runtime_property" )]
	public static Task<object> SetRuntimeProperty( string id, string component, string property, JsonNode value )
		=> McpGate.Run( "set_runtime_property", McpGate.Args( ( "id", id ), ( "component", component ), ( "property", property ), ( "value", value ) ) );

	/// <summary>
	/// Enter play mode — starts running the game in the editor. Scripts execute, physics simulate,
	/// everything goes live. Returns { started, method } (method 'EditorScene.Play', or 'SetPlaying
	/// (fallback)' with editorErrorSkipped when the safe path failed). While playing, scene-mutating
	/// tools refuse — use get/set_runtime_property, capture_view, and playtest, then stop_play to edit
	/// again.
	/// </summary>
	[McpTool( "start_play" )]
	public static Task<object> StartPlay()
		=> McpGate.Run( "start_play", McpGate.Args() );

	/// <summary>
	/// Exit play mode — stops the game and returns to editor. All runtime changes are discarded.
	/// </summary>
	[McpTool( "stop_play" )]
	public static Task<object> StopPlay()
		=> McpGate.Run( "stop_play", McpGate.Args() );
}