Editor toolset wrapper for prefab operations. Declares MCP RPC methods to create, inspect, instantiate, list prefabs and to set prefab references on components by calling McpGate.Run with appropriate arguments.
// 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>
/// Create prefabs from scene objects, instantiate them, list and inspect them, and wire prefab
/// references into component properties.
/// </summary>
[McpToolset( "bridge_prefab", "Create prefabs from scene objects, instantiate them, list and inspect them, and wire prefab references into component properties." )]
public static class BridgePrefabTools
{
/// <summary>
/// Save an existing GameObject as a real .prefab file — FULL engine serialization: every component
/// with its property values, and all children, in the same JSON format the editor writes. Returns {
/// created, path, sourceId, components, children } — pass path to instantiate_prefab to spawn
/// copies or get_prefab_info to inspect. Errors if the source GameObject is missing; overwrites an
/// existing file at path.
/// </summary>
/// <param name="id">GUID of the GameObject to save as prefab.</param>
/// <param name="path">Path for the prefab file relative to project root (e.g. 'prefabs/enemies/grunt.prefab').</param>
[McpTool( "create_prefab" )]
public static Task<object> CreatePrefab( string id, string path )
=> McpGate.Run( "create_prefab", McpGate.Args( ( "id", id ), ( "path", path ) ) );
/// <summary>
/// Inspect a prefab file as a structured summary: { path, name, size, modified, totalObjects,
/// maxDepth, referencedPrefabs, tree } — tree is the object hierarchy with per-node component type
/// lists (children capped at 8 per node with a truncation count). referencedPrefabs lists other
/// .prefab files this one links to. Use before instantiate_prefab; find prefabs with list_prefabs;
/// raw JSON via read_file if needed.
/// </summary>
/// <param name="path">Path to the .prefab file (e.g. 'prefabs/enemies/grunt.prefab').</param>
[McpTool.ReadOnly( "get_prefab_info" )]
public static Task<object> GetPrefabInfo( string path )
=> McpGate.Run( "get_prefab_info", McpGate.Args( ( "path", path ) ) );
/// <summary>
/// Spawn a FULL prefab instance into the active scene — components and children recreated. Uses the
/// engine's GameObject.Clone for registered prefabs, with a guid-remapped deserialize fallback for
/// freshly-written files (repeat instantiations never collide). Returns { instantiated, prefab,
/// method, gameObject, components, childCount } — gameObject.id is the new GUID for
/// set_transform/set_property follow-ups. Optional name/position/rotation override the spawned
/// root.
/// </summary>
/// <param name="path">Path to the .prefab file (e.g. 'prefabs/enemies/grunt.prefab').</param>
/// <param name="name">Rename the spawned root (defaults to the prefab's root name).</param>
/// <param name="position">World position to spawn at — object {x,y,z} or comma string "x,y,z". Defaults to origin. As "x,y,z" (or JSON {x,y,z}).</param>
/// <param name="rotation">Rotation as euler angles. Defaults to identity. As "pitch,yaw,roll" degrees.</param>
/// <param name="scale">Uniform scale multiplier. Defaults to 1.0.</param>
/// <param name="parent">GUID of parent GameObject to attach to.</param>
[McpTool( "instantiate_prefab" )]
public static Task<object> InstantiatePrefab( string path, string name = null, string position = null, string rotation = null, double? scale = null, string parent = null )
=> McpGate.Run( "instantiate_prefab", McpGate.Args( ( "path", path ), ( "name", name ), ( "position", position ), ( "rotation", rotation ), ( "scale", scale ), ( "parent", parent ) ) );
/// <summary>
/// List all .prefab files in the project. Filter by name or path.
/// </summary>
/// <param name="filter">Search filter for prefab name or path.</param>
/// <param name="maxResults">Maximum results to return. Defaults to 100.</param>
[McpTool.ReadOnly( "list_prefabs" )]
public static Task<object> ListPrefabs( string filter = null, double? maxResults = null )
=> McpGate.Run( "list_prefabs", McpGate.Args( ( "filter", filter ), ( "maxResults", maxResults ) ) );
/// <summary>
/// Set a GameObject-typed property on a component to a loaded prefab. Use this when set_property
/// can't handle prefab references (which it can't, because prefabs are GameObjects not primitives).
/// </summary>
/// <param name="id">GUID of the GameObject holding the component.</param>
/// <param name="component">Component type name.</param>
/// <param name="property">Property name to set (must be GameObject-typed).</param>
/// <param name="prefabPath">Prefab asset path (e.g. 'prefabs/player.prefab').</param>
[McpTool( "set_prefab_ref" )]
public static Task<object> SetPrefabRef( string id, string component, string property, string prefabPath )
=> McpGate.Run( "set_prefab_ref", McpGate.Args( ( "id", id ), ( "component", component ), ( "property", property ), ( "prefabPath", prefabPath ) ) );
}