Add MCP Apps extension support (typed metadata, attribute, and helpers)#1484
Add MCP Apps extension support (typed metadata, attribute, and helpers)#1484
Conversation
Agent-Logs-Url: https://github.com/modelcontextprotocol/csharp-sdk/sessions/5ec8e2cd-39e5-4b4c-a18e-182ccaaa7637 Co-authored-by: mikekistler <85643503+mikekistler@users.noreply.github.com>
|
Any idea when this will be merged? Would love to see this feature in the SDK. |
|
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 you please merge this 🙏 |
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>
|
👀 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"; |
There was a problem hiding this comment.
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>
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.AppsA new package (
ModelContextProtocol.Extensions.Apps) houses all MCP Apps types and helpers. It referencesModelContextProtocol.Corefor access to server primitives.New APIs
Constants (
McpApps)McpApps.ResourceMimeType→"text/html;profile=mcp-app"McpApps.ExtensionId→"io.modelcontextprotocol/ui"McpApps.SerializerOptions→ pre-configuredJsonSerializerOptionsfor MCP Apps typesTyped metadata models
McpUiToolMeta–ResourceUri,VisibilityMcpUiToolVisibility–Model/Appstring constantsMcpUiResourceMeta–Csp,Permissions,Domain,PrefersBorderMcpUiResourceCsp–ConnectDomains,ResourceDomains,FrameDomains,BaseUrisMcpUiResourcePermissions–AllowMcpUiClientCapabilities–MimeTypesClient capability helper
[McpAppUi]attribute (declarative path)When processed by
McpApps.ApplyAppUiAttributes()(or theWithMcpApps()builder extension), this populates the structured_meta.uiobject in the tool's metadata.McpApps.SetAppUi(programmatic path)Explicit
Meta["ui"]entries (set viaMcpServerToolCreateOptions.Meta) take precedence overSetAppUi;SetAppUitakes precedence over[McpAppUi]attribute.WithMcpApps()builder extensionAutomatically processes
[McpAppUi]attributes on all registered tools viaIPostConfigureOptions<McpServerOptions>.Notes
[Experimental(MCPEXP003)]— a dedicated diagnostic ID for MCP Apps.McpAppsJsonContext.docs/concepts/apps/apps.md.