Editor/Tools/WorldBuildingTools.Mesh.cs

Editor tool definitions for two MCP (message/command) actions. Exposes MeshGenerate and MappingPrimitive methods that call ProceduralMeshDriver to create meshes or mapping primitives and return results serialized via McpJson, with exception handling reporting failures.

File Access
#nullable enable
using System;
using System.ComponentModel;

namespace Editor.Mcp
{
	public static partial class SboxMcpAssistant
	{
		[McpTool( "pocketknife_mesh_generate" )]
		public static string MeshGenerate(
			[Description( "Target GameObject name" )] string? targetName = null,
			[Description( "Shape: box, prism, cylinder" )] string shape = "box",
			[Description( "Width (X)" )] float width = 100.0f,
			[Description( "Height (Y)" )] float height = 100.0f,
			[Description( "Depth (Z)" )] float depth = 100.0f,
			[Description( "Material path (.vmat)" )] string? materialPath = null,
			[Description( "Generate matching box collider" )] bool addCollider = true )
		{
			try
			{
				return McpJson.Write( ProceduralMeshDriver.GenerateMesh( targetName, shape, width, height, depth, materialPath, addCollider ) );
			}
			catch ( Exception ex )
			{
				return McpJson.Write( ToolOutcome<object>.Failure( null, ToolStatus.Failed, "mesh.generate_failed", "Procedural mesh generation failed.", ex ) );
			}
		}

		[McpTool( "pocketknife_mapping_primitive" )]
		public static string MappingPrimitive(
			[Description( "Primitive type: block, cylinder, wedge" )] string primitiveType = "block",
			[Description( "Size X" )] float sizeX = 128.0f,
			[Description( "Size Y" )] float sizeY = 128.0f,
			[Description( "Size Z" )] float sizeZ = 128.0f )
		{
			try
			{
				return McpJson.Write( ProceduralMeshDriver.CreateMappingPrimitive( primitiveType, sizeX, sizeY, sizeZ ) );
			}
			catch ( Exception ex )
			{
				return McpJson.Write( ToolOutcome<object>.Failure( null, ToolStatus.Failed, "mapping.primitive_failed", "Mapping primitive creation failed.", ex ) );
			}
		}
	}
}