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
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
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
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
toolMcpServerToolThe tool to process.
Returns
- McpServerTool
The same
toolinstance, 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
toolis 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
toolsIEnumerable<McpServerTool>The tools to process.
Returns
- IEnumerable<McpServerTool>
The same
toolsenumerable, 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
toolsis null.
GetUiCapability(ClientCapabilities?)
Gets the MCP Apps client capability, if advertised by the connected client.
public static McpUiClientCapabilities? GetUiCapability(ClientCapabilities? capabilities)
Parameters
capabilitiesClientCapabilitiesThe 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
toolMcpServerToolThe tool to set the UI metadata on.
appUiMcpUiToolMetaThe UI metadata to apply.
Returns
- McpServerTool
The same
toolinstance, 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
toolorappUiis 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
resourceMcpServerResourceThe resource to set the UI metadata on.
resourceUiMcpUiResourceMetaThe UI metadata to apply.
Returns
- McpServerResource
The same
resourceinstance, 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
resourceorresourceUiis null.