Skip to content

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

Open
Copilot wants to merge 14 commits into
mainfrom
copilot/add-mcp-apps-support
Open

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

Conversation

Copilot AI commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

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.

Comment thread src/ModelContextProtocol.Extensions.Apps/Server/McpApps.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@weng5e

weng5e commented May 12, 2026

Copy link
Copy Markdown

It is so great to see this PR! Really looking forward to use this in our product!

@Pari-Dhanakoti

Copy link
Copy Markdown

+1 for code review and merging this. Will be super useful to have the attribute instead of band-aid code

@FelixOhlhof

Copy link
Copy Markdown

any updates on this?

Comment thread src/ModelContextProtocol.Extensions.Apps/Server/McpApps.cs
Comment thread src/ModelContextProtocol.Extensions.Apps/Server/McpApps.cs
Comment thread tests/ModelContextProtocol.Tests/Server/McpAppsTests.cs
Comment thread samples/WeatherAppServer/WeatherResources.cs
Comment thread docs/concepts/apps/apps.md
@mikekistler

Copy link
Copy Markdown
Contributor

@halter73 Copilot claims that all your comments are resolved (some just by opening followup issues). I've left our comments as unresolved to aid in your re-review. Please feel free to mark them resolved if the changes address your concerns.

@halter73 halter73 left a comment

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.

ModelContextProtocol.AotCompatibility.TestApp only roots Core, ModelContextProtocol, and AspNetCore. The new Extensions.Apps package isn't referenced or trimmer-rooted, so make test-aot doesn't exercise it at all. (McpAppsTests itself is in the existing ModelContextProtocol.Tests project, which is fine, but unit tests aren't AOT-published.)

Convention seems to be that every shipped src package gets AOT publish coverage. Worth doing in this PR rather than deferring:

<ProjectReference Include="..\..\src\ModelContextProtocol.Extensions.Apps\ModelContextProtocol.Extensions.Apps.csproj" />
<TrimmerRootAssembly Include="ModelContextProtocol.Extensions.Apps" />

And extend Program.cs to actually exercise the surface by registering a tool with [McpAppUi], call WithMcpApps(), round-trip ListToolsAsync(), and assert _meta.ui is present. Without something exercising the API, the trimmer will just drop everything from the package and the publish "passes" vacuously.

Honest caveat: even with this coverage, the specific new { } issue I commented inline about wouldn't surface as an AOT analyzer warning at publish time. The value flows through IDictionary<string, object> (boxed, polymorphic), so the trimmer can't statically trace it. It would only manifest as a runtime serialization fallback (or NotSupportedException in strict AOT) when the initialize handshake runs. But the trimmer coverage still catches a broad class of other AOT problems and matches the convention for new packages.

Comment thread docs/concepts/apps/apps.md Outdated
Comment thread samples/WeatherAppServer/WeatherResources.cs
Comment thread src/ModelContextProtocol.Extensions.Apps/Server/McpAppsBuilderExtensions.cs Outdated
Comment thread docs/concepts/apps/apps.md Outdated
Comment thread docs/concepts/apps/apps.md Outdated
@mikekistler mikekistler requested a review from halter73 June 9, 2026 22:22
@mikekistler

Copy link
Copy Markdown
Contributor

@halter73 I think I've addressed all your comments and CI is green, so please give another review.

@FelixOhlhof

Copy link
Copy Markdown

@halter73 when will this be released? This has been open for several months now. We are currently considering switching to another solution.

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