Skip to content

feat(MCP UI) chat widgets#2052

Open
dimetron wants to merge 1 commit into
kagent-dev:mainfrom
dimetron:feature/chat-mcp-ui-widgets
Open

feat(MCP UI) chat widgets#2052
dimetron wants to merge 1 commit into
kagent-dev:mainfrom
dimetron:feature/chat-mcp-ui-widgets

Conversation

@dimetron

Copy link
Copy Markdown
Contributor

This pull request adds support for rendering interactive MCP UI widgets (MCP Apps) directly within the chat interface. It introduces backend and frontend changes to detect, handle, and render tools that provide UI resources, ensuring a richer and more interactive user experience. The backend now distinguishes between regular tools and those with UI widgets, compacts tool responses sent to the model to prevent unnecessary repeated calls, and exposes new endpoints for MCP-app interactions. The UI is updated to render these widgets inline and broker interactions between the app and the chat.

Backend: MCP App tool detection and handling

  • The CreateToolsets function in registry.go now returns both the toolsets and a set of tool names that support MCP Apps, enabling the agent to treat these tools differently. [1] [2] [3] [4] [5] [6]
  • A new callback (MakeMCPAppModelResultCallback in mcp_apps.go) is added to compact the payload sent to the model for MCP App tools, replacing heavy render payloads with a terminal notice to prevent the model from re-invoking rendering tools unnecessarily. [1] [2]
  • The agent is updated to wire in the MCP App callback only when MCP App tools are present, ensuring efficient handling.

Testing and validation

  • Comprehensive unit tests are added in mcp_apps_test.go to verify correct compaction of responses, error handling, and that only MCP App tools are affected by the new logic.

Documentation and design

  • A detailed design document (EP-2046-chat-mcp-ui-widgets.md) describes the motivation, goals, implementation details, test plan, and open questions for this feature.

Copilot AI review requested due to automatic review settings June 18, 2026 17:19
@github-actions github-actions Bot added the enhancement-proposal Indicates that this PR is for an enhancement proposal label Jun 18, 2026

Copilot AI 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.

Pull request overview

This PR adds end-to-end support for rendering interactive MCP UI widgets (“MCP Apps”) inline in the chat UI, including: backend endpoints to proxy MCP app tool/resource calls, agent-side toolset detection and model-payload compaction for UI-capable tools, and frontend components/context to render and broker interactions with the embedded app.

Changes:

  • Backend: detect MCP App-capable tools, filter app-only tools, and compact model-visible tool results to avoid repeated render/poll loops.
  • Backend: add /api/mcp-apps/... endpoints to list tools, call tools, and read ui:// resources from RemoteMCPServer.
  • Frontend: render MCP apps within tool call UI; add MCP app inspector route; add (adjacent) file attachments + chat minimap UI.

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ui/src/lib/messageHandlers.ts Preserves raw tool results + surfaces file artifacts and file parts for rendering on reload.
ui/src/lib/fileUpload.ts Adds client-side file allowlist/size guard and conversion to A2A FilePart.
ui/src/components/ToolDisplay.tsx Adds MCP App renderer embedding for completed tool calls with UI resources.
ui/src/components/mcp/McpServersView.tsx Adds “MCP Apps” navigation entry for servers.
ui/src/components/mcp-apps/McpAppsInspector.tsx Adds a UI to browse/invoke MCP App-capable tools and render their resources.
ui/src/components/mcp-apps/McpAppRenderer.tsx Implements the sandboxed MCP app renderer and host↔app bridging.
ui/src/components/chat/ToolCallDisplay.tsx Threads MCP app metadata + raw tool results into the tool call display pipeline.
ui/src/components/chat/FileAttachment.tsx Renders file parts as thumbnails/download chips.
ui/src/components/chat/ChatMinimap.tsx Adds a scroll minimap for chat history navigation.
ui/src/components/chat/ChatMessage.tsx Renders file attachments and forwards MCP app hooks into tool-call rendering.
ui/src/components/chat/ChatMcpAppsContext.tsx Adds chat-level registry and routing logic for MCP App-capable tools.
ui/src/components/chat/ChatInterface.tsx Wires MCP app message/tool-call promotion, file upload UI, and minimap integration.
ui/src/components/chat/tests/ChatMcpAppsContext.test.tsx Unit tests for app/tool registration behavior and app-only filtering.
ui/src/app/servers/[namespace]/[name]/apps/page.tsx Adds a route for the MCP Apps inspector.
ui/src/app/api/mcp-apps/[namespace]/[name]/tools/[toolName]/call/route.ts Next.js API proxy for MCP app tool calls.
ui/src/app/api/mcp-apps/[namespace]/[name]/resources/route.ts Next.js API proxy for MCP app resource reads.
ui/src/app/api/mcp-apps/_utils.ts Shared proxy helpers + OPTIONS handler for MCP apps API routes.
ui/src/app/actions/mcp-apps.ts Server actions for listing tools, calling tools, and reading resources.
ui/src/app/actions/tests/mcp-apps.test.ts Unit tests for MCP apps server actions path encoding and payloads.
ui/public/sandbox_proxy.html Adds the sandbox proxy document used by the MCP app iframe renderer.
ui/public/mockServiceWorker.js Updates MSW generated worker version.
ui/package.json Adds MCP UI / MCP SDK dependencies.
ui/package-lock.json Locks new MCP UI / MCP SDK dependency tree.
go/core/internal/httpserver/server.go Adds route wiring for MCP Apps endpoints.
go/core/internal/httpserver/handlers/mcpapps.go Implements MCP Apps list-tools/call-tool/read-resource handlers.
go/core/internal/httpserver/handlers/handlers.go Registers the new MCPApps handler.
go/build.err Adds a build log artifact (should not be committed).
go/adk/pkg/mcp/registry.go Toolset creation now identifies MCP App tools and filters app-only tools.
go/adk/pkg/mcp/registry_test.go Adds tests for MCP app detection and app-only visibility logic.
go/adk/pkg/agent/mcp_apps.go Adds model-result compaction callback for MCP App tool renders.
go/adk/pkg/agent/mcp_apps_test.go Tests for model-result compaction behavior.
go/adk/pkg/agent/agent.go Wires MCP App callback only when MCP App-capable tools are present.
design/EP-2046-chat-mcp-ui-widgets.md Design doc describing goals, approach, and test plan.
Files not reviewed (1)
  • ui/package-lock.json: Generated file
Comments suppressed due to low confidence (1)

go/build.err:39

  • go/build.err looks like a locally-captured build log and is now stale (it reports CreateToolsets returning 2 values while the PR updates agent.go accordingly). This file shouldn't be committed; it will also confuse CI/reviewers about the current build state. Please remove it from the PR (and rely on CI logs instead).
# github.com/kagent-dev/kagent/go/adk/pkg/agent
adk/pkg/agent/agent.go:58:14: assignment mismatch: 1 variable but mcp.CreateToolsets returns 2 values


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/src/components/chat/ChatMinimap.tsx
Comment thread ui/public/sandbox_proxy.html
@dimetron dimetron marked this pull request as draft June 18, 2026 17:26
@dimetron dimetron changed the title feature/chat mcp UI widgets feat(MCP UI) chat widgets Jun 18, 2026
Comment thread go/adk/pkg/agent/mcp_apps.go
Comment thread go/adk/pkg/mcp/registry.go Outdated
Comment thread go/adk/pkg/mcp/registry.go Outdated
@dimetron dimetron force-pushed the feature/chat-mcp-ui-widgets branch from 4371099 to 794c8f4 Compare June 19, 2026 04:55
@dimetron dimetron marked this pull request as ready for review June 19, 2026 11:16
@dimetron dimetron requested a review from peterj June 19, 2026 11:16
@dimetron dimetron marked this pull request as draft June 19, 2026 12:28
@dimetron

Copy link
Copy Markdown
Contributor Author
Screenshot 2026-06-19 at 14 44 11

@dimetron dimetron force-pushed the feature/chat-mcp-ui-widgets branch from 00d6a01 to 9943ffe Compare June 19, 2026 12:48
@dimetron dimetron marked this pull request as ready for review June 19, 2026 12:50
Add end-to-end support for rendering interactive MCP "App" UI resources
inline in the chat instead of raw tool-call JSON.

Backend:
- registry.CreateToolsets returns the set of MCP-app-capable tool names
  (MCPAppToolNames) so the agent treats their results specially; tool
  classification is expressed via a single mcpToolKind classifier.
- MakeMCPAppModelResultCallback keeps the rich tool payload in chat history
  for UI rendering while compacting what is sent to the model (avoids
  redundant polling/tool churn), wired in agent.go only when MCP-app tools
  are present; uses the typed MCP CallToolResult from the go-sdk.
- /api/mcp-apps/{namespace}/{name}/... endpoints to list tools, call tools,
  and read ui:// resources from a RemoteMCPServer.

UI:
- Sandboxed McpAppRenderer (@mcp-ui/client) + ChatMcpAppsContext broker
  host<->app messaging (sendMessage, visible tool calls, resource/tool-call
  proxying); ChatLayoutUI mounts ChatMcpAppsProvider so widgets render.
- McpAppsInspector view (servers/[ns]/[name]/apps) reachable from the server
  menu; ToolDisplay/ChatMessage/ToolCallDisplay render app widgets.
- sandbox_proxy.html restricts postMessage to the expected parent origin.

Tests: Go registry / model-result callback; UI context mapping, mcp-apps
server actions, and a ChatLayoutUI provider-mount regression test.

Adjacent chat file-upload/minimap UI is included to compile but is out of
scope (file-upload backend excluded), per the EP.

Includes design/EP-2046-chat-mcp-ui-widgets.md.

Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
@dimetron dimetron force-pushed the feature/chat-mcp-ui-widgets branch from 9943ffe to 09d6d13 Compare June 20, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement-proposal Indicates that this PR is for an enhancement proposal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants