.NET: Add MCP Apps support to AG-UI (.NET)#5216
Open
halllo wants to merge 2 commits intomicrosoft:mainfrom
Open
.NET: Add MCP Apps support to AG-UI (.NET)#5216halllo wants to merge 2 commits intomicrosoft:mainfrom
halllo wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds MCP Apps support to the .NET AG-UI hosting + shared protocol layers by emitting ACTIVITY_SNAPSHOT events for tool results that include a ui:// resource URI, along with a new end-to-end sample and accompanying unit/conformance tests.
Changes:
- Introduces
ACTIVITY_SNAPSHOTto the AG-UI event model/serializer and emits it after tool results when MCP tool metadata includes a UI resource URI. - Extends
MapAGUIwith an optionalProxiedResultResolverto short-circuit proxied MCPresources/readandtools/callrequests. - Adds the
Step06_McpAppssample (MCP server + AG-UI server + client) and protocol/conformance tests.
Reviewed changes
Copilot reviewed 32 out of 33 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests.csproj | Adds TestHost dependency for new endpoint-level unit tests. |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs | Adds unit tests covering proxied-result short-circuiting behavior. |
| dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/ChatResponseUpdateAGUIExtensionsTests.cs | Adds AsAGUIEventStreamAsync protocol conformance tests including ACTIVITY_SNAPSHOT. |
| dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/EmitToolMetadataMiddleware.cs | New middleware to attach tool metadata onto tool results for downstream AG-UI emission. |
| dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs | Adds MapAGUI overload supporting proxied-result resolution and minimal SSE response path. |
| dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ChatResponseUpdateAGUIExtensions.cs | Emits ACTIVITY_SNAPSHOT after tool results when tool metadata includes MCP Apps UI URI; adds tool-result normalization helper. |
| dotnet/src/Microsoft.Agents.AI.AGUI/Shared/BaseEventJsonConverter.cs | Adds JSON (de)serialization support for ACTIVITY_SNAPSHOT. |
| dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIJsonSerializerContext.cs | Registers ActivitySnapshotEvent for source-generated JSON. |
| dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIEventTypes.cs | Adds ACTIVITY_SNAPSHOT discriminator constant. |
| dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ActivitySnapshotEvent.cs | New event model for ACTIVITY_SNAPSHOT. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/Tests/Tests.csproj | New sample test project for MCP Apps AG-UI conformance tests. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/Tests/ConformanceTests.cs | Adds (skipped by default) integration/conformance tests for SSE + proxy flows. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Server.csproj | New AG-UI server project for the MCP Apps sample. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Properties/launchSettings.json | Launch settings for sample AG-UI server. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Program.cs | Implements AG-UI↔MCP bridge, emits tool metadata, and proxies MCP requests via ProxiedResultResolver. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/appsettings.json | Sample server configuration. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/appsettings.Development.json | Sample server dev configuration. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/README.md | Full guide documenting MCP Apps over AG-UI, proxy flows, and event stream shapes. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/vite.config.ts | Vite config for bundling the MCP App to a single HTML file. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/Properties/launchSettings.json | Launch settings for sample MCP server. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/Program.cs | Sample MCP server exposing get-time tool and ui:// HTML resource. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/package.json | Frontend MCP App build dependencies and script. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/package-lock.json | Locked frontend dependency graph for the MCP App build. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/McpServer.csproj | New MCP server project file. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/get-time.ts | MCP App frontend logic using @modelcontextprotocol/ext-apps. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/get-time.html | MCP App HTML entrypoint for the Vite build. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/appsettings.json | Sample MCP server configuration. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/appsettings.Development.json | Sample MCP server dev configuration. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/Client/Program.cs | Sample console client that streams AG-UI responses and prints ACTIVITY_SNAPSHOT + proxied reads. |
| dotnet/samples/02-agents/AGUI/Step06_McpApps/Client/Client.csproj | New sample client project file. |
| dotnet/samples/02-agents/AGUI/README.md | Links and run instructions for the new Step06 MCP Apps sample. |
| dotnet/Directory.Packages.props | Adds ModelContextProtocol.AspNetCore central package version. |
| dotnet/agent-framework-dotnet.slnx | Includes new Step06 sample projects in the solution. |
Files not reviewed (1)
- dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/package-lock.json: Language not supported
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/EmitToolMetadataMiddleware.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/EmitToolMetadataMiddleware.cs
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ActivitySnapshotEvent.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ChatResponseUpdateAGUIExtensions.cs
Show resolved
Hide resolved
dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/Program.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/02-agents/AGUI/Step06_McpApps/Tests/ConformanceTests.cs
Outdated
Show resolved
Hide resolved
…or AsAGUIEventStreamAsync protocol conformance.
70789ac to
722118b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
MCP Apps is a new MCP extension that allows attaching interactive HTML UI components to MCP tools. When a tool is invoked, the AG-UI host passes a
ui://resource URI alongside the tool result so a capable client can render the HTML app in-place. This PR extends the framework's AG-UI implementation to support MCP Apps, and adds a full end-to-end sample and conformance tests for theAsAGUIEventStreamAsyncprotocol to ensure correctness of the SSE event stream.Description
Framework extensions (
Microsoft.Extensions.AI.Hosting.AGUI.AspNetCore):ACTIVITY_SNAPSHOTevent type toAGUIEventTypes,AGUIJsonSerializerContext, and a newActivitySnapshotEventmodel.ChatResponseUpdateAGUIExtensionsandAGUIEndpointRouteBuilderExtensionsto emitACTIVITY_SNAPSHOTevents when a proxied tool result includes a UI resource URI.EmitToolMetadataMiddlewareto attach tool metadata to the event stream.New sample:
dotnet/samples/02-agents/AGUI/Step06_McpApps/A three-project sample demonstrating MCP Apps over AG-UI end-to-end:
McpServer/— ASP.NET Core MCP server exposing aget-timetool with a bundled HTML app (TypeScript/Vite, compiled to a single HTML file). The tool is annotated with[McpMeta("ui", ...)]to attach theui://resource URI.Server/— AG-UI server that bridges the MCP server to AG-UI clients usingMapAGUIwith aProxiedResultResolveroverload to proxyresources/readandtools/callrequests.Client/— Console client usingAGUIChatClientandRunStreamingAsyncto stream responses and displayACTIVITY_SNAPSHOTevents (which carry theui://URI and tool result for browser-based clients to render).Tests:
ChatResponseUpdateAGUIExtensionsTests.csandAGUIEndpointRouteBuilderExtensionsTests.cs— unit tests for the new/updated extension methods.ConformanceTests.cs— end-to-end tests for the sample, exercising theAsAGUIEventStreamAsyncevent stream.Contribution Checklist