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.
Implements
Inherited Members
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 |