CoplayDev/unity-mcp · error · Exception

Unknown shape type '{shapeTypeStr}'. Valid types: {validType

Error message

Unknown shape type '{shapeTypeStr}'. Valid types: {validTypes}

What it means

Thrown by CreateShapeGeneric when the 'shapeType' string cannot be parsed against the ProBuilder ShapeType enum (Unity.ProBuilder.ShapeType) via Enum.Parse with case-insensitive matching. Valid types include: Cube, Cylinder, Sphere, Plane, Cone, Torus, Pipe, Arch, Stair, CurvedStair, Door, Prism.

Source

Thrown at MCPForUnity/Editor/Tools/ProBuilder/ManageProBuilder.cs:820

                        new object[] { pivot, totalWidth, totalHeight, ledgeHeight, legWidth, d });
                }

                default:
                    return null;
            }
        }

        private static Component CreateShapeGeneric(string shapeTypeStr)
        {
            object shapeTypeValue;
            try
            {
                shapeTypeValue = Enum.Parse(_shapeTypeEnum, shapeTypeStr, true);
            }
            catch
            {
                var validTypes = string.Join(", ", Enum.GetNames(_shapeTypeEnum));
                throw new Exception($"Unknown shape type '{shapeTypeStr}'. Valid types: {validTypes}");
            }

            // Try CreateShape(ShapeType) first
            var createMethod = _shapeGeneratorType.GetMethod("CreateShape",
                BindingFlags.Static | BindingFlags.Public,
                null,
                new[] { _shapeTypeEnum },
                null);

            object[] invokeArgs;
            if (createMethod != null)
            {
                invokeArgs = new[] { shapeTypeValue };
            }
            else if (_pivotLocationType != null)
            {
                createMethod = _shapeGeneratorType.GetMethod("CreateShape",
                    BindingFlags.Static | BindingFlags.Public,

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Use one of the valid ShapeType names: Cube, Cylinder, Sphere, Plane, Cone, Torus, Pipe, Arch, Stair, CurvedStair, Door, Prism.
  2. If you need a standard primitive, use manage_gameobject create with a primitive type instead.
  3. Strip whitespace from the shapeType value before sending.
  4. If a shape type from documentation is rejected, verify your ProBuilder package version supports that enum value.

Example fix

// before
params = {"action": "create", "shapeType": "Box"}
// after
params = {"action": "create", "shapeType": "Cube"}
Defensive patterns

Strategy: validation

Validate before calling

VALID_SHAPE_TYPES = {
    'Cube', 'Cylinder', 'Sphere', 'Plane', 'Cone', 'Torus',
    'Pipe', 'Arch', 'Stair', 'CurvedStair', 'Door', 'Prism'
}

def validate_shape_type(shape_type: str) -> bool:
    return shape_type in VALID_SHAPE_TYPES

Try / catch

try
{
    var shape = CreateShapeGeneric(shapeTypeStr);
}
catch (Exception ex) when (ex.Message.Contains("Unknown shape type"))
{
    return new ErrorResponse(ex.Message);  // message includes valid types
}

Prevention

When it happens

Trigger: Calling create_shape with a shapeType value not in the ShapeType enum. Typo, wrong casing that still fails (though matching is case-insensitive), or using a non-ProBuilder shape name like 'Box', 'Capsule', or 'Quad'.

Common situations: AI uses standard Unity primitive names (Box, Capsule) instead of ProBuilder names; different ProBuilder version exposes a different enum set; typo or trailing whitespace in the shape type.

Related errors


AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13). Data as JSON: /api/errors/bce47df8bbaf7d03. Report an issue: GitHub.