docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class McpOutputSchemaAttribute

    Marks a static method as providing a custom output schema for an MCP tool. Output schemas help MCP clients understand the structure of tool return values.

    Inheritance
    object
    Attribute
    McpOutputSchemaAttribute
    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.Method, AllowMultiple = false)]
    public class McpOutputSchemaAttribute : Attribute, _Attribute
    Remarks

    The schema method must:

    • Be public static
    • Return an object representing the JSON schema for the output
    • Have no parameters

    The ToolName must match the name used in the [McpTool] attribute. For class-based tools, implement GetOutputSchema() instead.

    Examples
    [McpTool("calculate", "Performs a calculation")]
    public static object Calculate(JObject params)
    {
        return new { result = 42, unit = "answer" };
    }
    
    [McpOutputSchema("calculate")]
    public static object CalculateOutputSchema()
    {
        return new
        {
            type = "object",
            properties = new
            {
                result = new { type = "number", description = "Calculation result" },
                unit = new { type = "string", description = "Unit of measurement" }
            },
            required = new[] { "result" }
        };
    }

    Constructors

    McpOutputSchemaAttribute(string)

    Creates an output schema attribute linking this method to an MCP tool.

    Declaration
    public McpOutputSchemaAttribute(string toolName)
    Parameters
    Type Name Description
    string toolName

    The name of the tool this output schema is for (must match the [McpTool] name exactly)

    Exceptions
    Type Condition
    ArgumentException

    Thrown if toolName is null or empty

    Properties

    ToolName

    Gets the name of the tool this schema method provides the output schema for. Must exactly match the name used in the corresponding [McpTool] attribute.

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

    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)