docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class McpSchemaAttribute

    Marks a static method as providing a custom input schema for an MCP tool. Use this when a tool takes JObject parameters and needs a schema more specific than the default.

    Inheritance
    object
    Attribute
    McpSchemaAttribute
    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 McpSchemaAttribute : Attribute, _Attribute
    Remarks

    The schema method must:

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

    The ToolName must match the name used in the [McpTool] attribute. This attribute is only needed for tools using JObject parameters; typed parameter tools automatically generate schemas from the parameter type.

    Examples
    [McpTool("custom_action", "Performs a custom action")]
    public static object CustomAction(JObject params)
    {
        // Tool implementation
    }
    
    [McpSchema("custom_action")]
    public static object CustomActionSchema()
    {
        return new
        {
            type = "object",
            properties = new
            {
                action = new { type = "string", enum = new[] { "create", "delete" } },
                target = new { type = "string", description = "Target to act upon" }
            },
            required = new[] { "action" }
        };
    }

    Constructors

    McpSchemaAttribute(string)

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

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

    The name of the tool this 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 input 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)