Editor MCP assistant tools for asset selection and placement. Defines two exposed tools: AssetQuickPlace which calls AssetAndSelectionDriver.QuickPlaceAsync to spawn/place an asset and returns JSON, and EditorSelect which calls AssetAndSelectionDriver.SyncSelection to select an object in the editor and optionally focus the camera, with exception handling returning failure payloads.
#nullable enable
using System;
using System.ComponentModel;
using System.Threading.Tasks;
namespace Editor.Mcp
{
public static partial class SboxMcpAssistant
{
[McpTool( "pocketknife_asset_quick_place" )]
public static async Task<string> AssetQuickPlace(
[Description( "Search keyword for placeholder asset (e.g. 'chair', 'tree', 'sword')" )] string query,
[Description( "Search source: local, cloud, both" )] string source = "both",
[Description( "Spawn world X" )] float posX = 0f,
[Description( "Spawn world Y" )] float posY = 0f,
[Description( "Spawn world Z" )] float posZ = 0f,
[Description( "Uniform scale factor" )] float scale = 1.0f )
{
try
{
var result = await AssetAndSelectionDriver.QuickPlaceAsync( query, source, posX, posY, posZ, scale );
return McpJson.Write( result );
}
catch ( Exception ex )
{
return McpJson.Write( ToolOutcome<object>.Failure( null, ToolStatus.Failed, "asset.quick_place_failed", "Asset quick placement failed.", ex ) );
}
}
[McpTool( "pocketknife_editor_select" )]
public static string EditorSelect(
[Description( "GameObject name to select in editor" )] string targetQuery,
[Description( "Center and focus editor camera on selection" )] bool focusCamera = true )
{
try
{
return McpJson.Write( AssetAndSelectionDriver.SyncSelection( targetQuery, focusCamera ) );
}
catch ( Exception ex )
{
return McpJson.Write( ToolOutcome<object>.Failure( null, ToolStatus.Failed, "editor.select_failed", "Editor selection sync failed.", ex ) );
}
}
}
}