Table of Contents

Class McpApps

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

Provides constants and helper methods for building MCP Apps-enabled servers.

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

Remarks

MCP Apps is an extension to the Model Context Protocol that enables MCP servers to deliver interactive user interfaces — dashboards, forms, visualizations, and more — directly inside conversational AI clients.

Use the constants in this class when populating the extensions capability and the _meta field of tools and resources. Use GetUiCapability(ClientCapabilities?) to check whether the connected client supports the MCP Apps extension.

Use SetAppUi(McpServerTool, McpUiToolMeta) to set the _meta.ui metadata on a tool, or ApplyAppUiAttributes(IEnumerable<McpServerTool>) to automatically process McpAppUiAttribute instances on tools created from methods.

Fields

ExtensionId

The extension identifier used for MCP Apps capability negotiation.

public const string ExtensionId = "io.modelcontextprotocol/ui"

Field Value

string

Remarks

This key is used in the Extensions and Extensions dictionaries to advertise support for the MCP Apps extension.

HtmlMimeType

The MIME type used for MCP App HTML resources.

public const string HtmlMimeType = "text/html;profile=mcp-app"

Field Value

string

Remarks

This MIME type should be used when registering UI resources with text/html;profile=mcp-app to indicate they are MCP App resources.

Properties

SerializerOptions

Gets the JsonSerializerOptions configured with source-generated metadata for MCP Apps extension types.

public static JsonSerializerOptions SerializerOptions { get; }

Property Value

JsonSerializerOptions

Remarks

Use these options when serializing or deserializing MCP Apps types such as McpUiToolMeta, McpUiClientCapabilities, and McpUiResourceMeta.

Methods

ApplyAppUiAttributes(McpServerTool)

Processes a single tool, applying McpAppUiAttribute metadata if the tool's underlying method has the attribute.

public static McpServerTool ApplyAppUiAttributes(McpServerTool tool)

Parameters

tool McpServerTool

The tool to process.

Returns

McpServerTool

The same tool instance, for chaining.

Remarks

If the tool has a McpAppUiAttribute in its Metadata, this method sets the ui key in the tool's Meta if not already present.

Exceptions

ArgumentNullException

tool is null.

ApplyAppUiAttributes(IEnumerable<McpServerTool>)

Processes a collection of tools, applying McpAppUiAttribute metadata to any tool whose underlying method has the attribute.

public static IEnumerable<McpServerTool> ApplyAppUiAttributes(IEnumerable<McpServerTool> tools)

Parameters

tools IEnumerable<McpServerTool>

The tools to process.

Returns

IEnumerable<McpServerTool>

The same tools enumerable, for chaining.

Remarks

For each tool that has a McpAppUiAttribute in its Metadata, this method sets the ui key in the tool's Meta if not already present.

If Meta already contains a ui key (e.g., set explicitly via Meta), the attribute is not applied.

Exceptions

ArgumentNullException

tools is null.

GetUiCapability(ClientCapabilities?)

Gets the MCP Apps client capability, if advertised by the connected client.

public static McpUiClientCapabilities? GetUiCapability(ClientCapabilities? capabilities)

Parameters

capabilities ClientCapabilities

The client capabilities received during the MCP initialize handshake.

Returns

McpUiClientCapabilities

A McpUiClientCapabilities instance if the client advertises support for the MCP Apps extension; otherwise, null.

Remarks

Use this method to determine whether the connected client supports the MCP Apps extension and to read the client's supported MIME types.

SetAppUi(McpServerTool, McpUiToolMeta)

Sets the MCP Apps UI metadata on a tool's Meta property.

public static McpServerTool SetAppUi(McpServerTool tool, McpUiToolMeta appUi)

Parameters

tool McpServerTool

The tool to set the UI metadata on.

appUi McpUiToolMeta

The UI metadata to apply.

Returns

McpServerTool

The same tool instance, for chaining.

Remarks

This method sets the ui key in the tool's Meta object. If a ui key is already present in Meta, it is not overwritten.

Exceptions

ArgumentNullException

tool or appUi is null.

SetResourceUi(McpServerResource, McpUiResourceMeta)

Sets the MCP Apps UI metadata on a resource's Meta property.

public static McpServerResource SetResourceUi(McpServerResource resource, McpUiResourceMeta resourceUi)

Parameters

resource McpServerResource

The resource to set the UI metadata on.

resourceUi McpUiResourceMeta

The UI metadata to apply.

Returns

McpServerResource

The same resource instance, for chaining.

Remarks

This method sets the ui key in the resource's Meta object. If a ui key is already present in Meta, it is not overwritten.

Exceptions

ArgumentNullException

resource or resourceUi is null.