Table of Contents

Class McpAppUiAttribute

Namespace
ModelContextProtocol.Extensions.Apps
Assembly
ModelContextProtocol.Extensions.Apps.dll

Specifies MCP Apps UI metadata for a tool method.

[AttributeUsage(AttributeTargets.Method)]
[Experimental("MCPEXP003", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp003")]
public sealed class McpAppUiAttribute : Attribute
Inheritance
McpAppUiAttribute
Inherited Members

Examples

[McpServerTool]
[McpAppUi(ResourceUri = "ui://weather/view.html")]
[Description("Get current weather for a location")]
public string GetWeather(string location) => ...;

// Restrict visibility to model only:
[McpServerTool]
[McpAppUi(ResourceUri = "ui://weather/view.html", Visibility = [McpUiToolVisibility.Model])]
public string GetWeatherModelOnly(string location) => ...;

Remarks

Apply this attribute alongside McpServerToolAttribute to associate an MCP Apps UI resource with the tool. When processed by ApplyAppUiAttributes(McpServerTool) or ApplyAppUiAttributes(IEnumerable<McpServerTool>), it populates the structured _meta.ui object in the tool's metadata.

Explicit Meta["ui"] set via McpServerToolCreateOptions or a raw [McpMeta("ui", ...)] attribute takes precedence over this attribute: if the tool already has a ui key in Meta, this attribute is ignored.

Properties

ResourceUri

Gets or sets the URI of the UI resource associated with this tool.

public string? ResourceUri { get; set; }

Property Value

string

Remarks

This should be a ui:// URI pointing to the HTML resource registered with the server (e.g., "ui://weather/view.html").

Visibility

Gets or sets the visibility of the tool, controlling which principals can invoke it.

public string[]? Visibility { get; set; }

Property Value

string[]

Remarks

Allowed values are Model and App. When null or empty, the tool is visible to both the model and the app (the default).