Skip to content

Add MCP Apps extension support (typed metadata, attribute, and helpers)#1484

Open
Copilot wants to merge 8 commits intomainfrom
copilot/add-mcp-apps-support
Open

Add MCP Apps extension support (typed metadata, attribute, and helpers)#1484
Copilot wants to merge 8 commits intomainfrom
copilot/add-mcp-apps-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

MCP Apps is the first official MCP extension (io.modelcontextprotocol/ui), enabling servers to deliver interactive UIs inside AI clients. The C# SDK had the foundational primitives (Extensions, _meta) but no typed convenience layer, requiring manual JSON construction that is error-prone and non-discoverable.

New Package: ModelContextProtocol.Extensions.Apps

A new package (ModelContextProtocol.Extensions.Apps) houses all MCP Apps types and helpers. It references ModelContextProtocol.Core for access to server primitives.

New APIs

Constants (McpApps)

  • McpApps.ResourceMimeType"text/html;profile=mcp-app"
  • McpApps.ExtensionId"io.modelcontextprotocol/ui"
  • McpApps.SerializerOptions → pre-configured JsonSerializerOptions for MCP Apps types

Typed metadata models

  • McpUiToolMetaResourceUri, Visibility
  • McpUiToolVisibilityModel/App string constants
  • McpUiResourceMetaCsp, Permissions, Domain, PrefersBorder
  • McpUiResourceCspConnectDomains, ResourceDomains, FrameDomains, BaseUris
  • McpUiResourcePermissionsAllow
  • McpUiClientCapabilitiesMimeTypes

Client capability helper

McpUiClientCapabilities? caps = McpApps.GetUiCapability(clientCapabilities);
if (caps?.MimeTypes?.Contains(McpApps.ResourceMimeType) is true) { ... }

[McpAppUi] attribute (declarative path)

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

When processed by McpApps.ApplyAppUiAttributes() (or the WithMcpApps() builder extension), this populates the structured _meta.ui object in the tool's metadata.

McpApps.SetAppUi (programmatic path)

McpApps.SetAppUi(tool, new McpUiToolMeta
{
    ResourceUri = "ui://weather/view.html",
    Visibility = [McpUiToolVisibility.Model, McpUiToolVisibility.App]
});

Explicit Meta["ui"] entries (set via McpServerToolCreateOptions.Meta) take precedence over SetAppUi; SetAppUi takes precedence over [McpAppUi] attribute.

WithMcpApps() builder extension

builder.Services
    .AddMcpServer()
    .WithTools<MyToolType>()
    .WithMcpApps();

Automatically processes [McpAppUi] attributes on all registered tools via IPostConfigureOptions<McpServerOptions>.

Notes

  • All new APIs are [Experimental(MCPEXP003)] — a dedicated diagnostic ID for MCP Apps.
  • Source-generated JSON serialization for Native AOT compatibility via McpAppsJsonContext.
  • Documentation added in docs/concepts/apps/apps.md.

Copilot AI changed the title [WIP] Add MCP Apps support for typed metadata and helpers Add MCP Apps extension support (typed metadata, attribute, and helpers) Mar 31, 2026
Copilot AI requested a review from mikekistler March 31, 2026 20:37
@gabrielwhitehair
Copy link
Copy Markdown

Any idea when this will be merged? Would love to see this feature in the SDK.

@VinKamat
Copy link
Copy Markdown

This is a key capability for "enterprises", emerging and especially those who are already on the MCP train wanting to deliver UI Apps within convo experiences.
Can't wait to see this merged, let's go please.

@FelixOhlhof
Copy link
Copy Markdown

Can you please merge this 🙏

Comment thread src/ModelContextProtocol.ExtApps/ModelContextProtocol.ExtApps.csproj Outdated
Comment thread docs/list-of-diagnostics.md Outdated
Comment thread src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs Outdated
Comment thread src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs Outdated
Comment thread src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs Outdated
Comment thread src/Common/Experimentals.cs Outdated
Comment thread src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs Outdated
mikekistler and others added 3 commits April 29, 2026 16:59
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mikekistler mikekistler marked this pull request as ready for review April 30, 2026 01:22
@bharathkreddy
Copy link
Copy Markdown

👀 Tracking this closely - and will adopt this surface as soon as it ships. The tool-side [McpAppUi] and McpServerToolCreateOptions.AppUi look great.

One observation that may be worth addressing in this PR or a fast follow-up: the typed McpUiResourceMeta / McpUiResourceCsp models added to Core aren't reachable via resource registration — only via raw JsonObject on TextResourceContents.Meta. Since per-resource CSP is mandatory for any production MCP App, this leaves the most failure-prone part of the API in raw-JSON territory. Would be great to get a typed path for resources too, mirroring the tool-side ergonomics. Filed as a comment on #1431 with more detail.

/// This MIME type should be used when registering UI resources with
/// <c>text/html;profile=mcp-app</c> to indicate they are MCP App resources.
/// </remarks>
public const string ResourceMimeType = "text/html;profile=mcp-app";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this name is too generic. The MCP Apps spec says "The initial specification focuses on HTML resources (text/html;profile=mcp-app) with a clear path for future extensions." To avoid confusion with potential future resource types, I think we should call this "HtmlMimeType".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SEP-1865: MCP Apps - Interactive User Interfaces for MCP

9 participants