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