docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class McpDescriptionAttribute

    Provides descriptions and constraints for MCP tool parameter properties. Applied to properties in parameter classes to enhance automatically generated schemas.

    Inheritance
    object
    Attribute
    McpDescriptionAttribute
    Implements
    _Attribute
    Inherited Members
    Attribute.Equals(object)
    Attribute.GetCustomAttribute(Assembly, Type)
    Attribute.GetCustomAttribute(Assembly, Type, bool)
    Attribute.GetCustomAttribute(MemberInfo, Type)
    Attribute.GetCustomAttribute(MemberInfo, Type, bool)
    Attribute.GetCustomAttribute(Module, Type)
    Attribute.GetCustomAttribute(Module, Type, bool)
    Attribute.GetCustomAttribute(ParameterInfo, Type)
    Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(Assembly)
    Attribute.GetCustomAttributes(Assembly, bool)
    Attribute.GetCustomAttributes(Assembly, Type)
    Attribute.GetCustomAttributes(Assembly, Type, bool)
    Attribute.GetCustomAttributes(MemberInfo)
    Attribute.GetCustomAttributes(MemberInfo, bool)
    Attribute.GetCustomAttributes(MemberInfo, Type)
    Attribute.GetCustomAttributes(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(Module)
    Attribute.GetCustomAttributes(Module, bool)
    Attribute.GetCustomAttributes(Module, Type)
    Attribute.GetCustomAttributes(Module, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo)
    Attribute.GetCustomAttributes(ParameterInfo, bool)
    Attribute.GetCustomAttributes(ParameterInfo, Type)
    Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
    Attribute.GetHashCode()
    Attribute.IsDefaultAttribute()
    Attribute.IsDefined(Assembly, Type)
    Attribute.IsDefined(Assembly, Type, bool)
    Attribute.IsDefined(MemberInfo, Type)
    Attribute.IsDefined(MemberInfo, Type, bool)
    Attribute.IsDefined(Module, Type)
    Attribute.IsDefined(Module, Type, bool)
    Attribute.IsDefined(ParameterInfo, Type)
    Attribute.IsDefined(ParameterInfo, Type, bool)
    Attribute.Match(object)
    Attribute.TypeId
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AI.MCP.Editor.ToolRegistry
    Assembly: Unity.AI.MCP.Editor.dll
    Syntax
    [AttributeUsage(AttributeTargets.Property|AttributeTargets.Field)]
    public class McpDescriptionAttribute : Attribute, _Attribute
    Remarks

    This attribute enhances schema generation by providing:

    • Human-readable descriptions for properties
    • Required field markers
    • Enum constraints for string properties
    • Explicit default values (overriding property initializers)

    The SchemaGenerator reads this attribute when generating input schemas for tools using typed parameters.

    Examples
    public class CreateObjectParams
    {
        [McpDescription("Name of the object to create", Required = true)]
        public string Name { get; set; }
    
        [McpDescription("Object type", EnumType = typeof(ObjectType))]
        public string Type { get; set; } = "cube";
    
        [McpDescription("Scale multiplier", Default = 1.0)]
        public float Scale { get; set; }
    
        [McpDescription("Position in world space")]
        public Vector3 Position { get; set; }
    }
    
    public enum ObjectType { Cube, Sphere, Cylinder }

    Constructors

    McpDescriptionAttribute(string)

    Creates a description attribute for an MCP tool parameter property.

    Declaration
    public McpDescriptionAttribute(string description)
    Parameters
    Type Name Description
    string description

    Human-readable description text that explains the parameter's purpose and expected values

    Properties

    Default

    Gets or sets an explicit default value for this parameter. Takes precedence over property initializers when generating the JSON schema.

    Declaration
    public object Default { get; set; }
    Property Value
    Type Description
    object
    Remarks

    When set, this value will be used in the JSON schema's "default" field. If not set, the schema generator will attempt to detect defaults from property initializers. For enum properties, the default will be automatically converted to its string representation.

    Description

    Gets the human-readable description for this parameter property. This appears in the generated JSON schema and helps MCP clients understand the parameter's purpose.

    Declaration
    public string Description { get; }
    Property Value
    Type Description
    string

    EnumType

    Gets or sets an enum type to use for constraining string property values. The enum values will be converted to string constraints in the JSON schema.

    Declaration
    public Type EnumType { get; set; }
    Property Value
    Type Description
    Type
    Remarks

    This is useful when you want to constrain a string property to specific values without changing the property type from string. If the property itself is an enum type, this is not needed.

    HasDefault

    Gets whether an explicit default value was set via the Default property. Used internally by SchemaGenerator to distinguish between null defaults and no defaults.

    Declaration
    public bool HasDefault { get; }
    Property Value
    Type Description
    bool

    Required

    Gets or sets whether this parameter is required. Required parameters must be provided by the MCP client; optional parameters may be omitted.

    Declaration
    public bool Required { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    Value types without default values are automatically considered required. Set this to true to explicitly mark reference types as required.

    Implements

    _Attribute
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)