feat(mcp-app-sample): Add new simple MCP App sample#1133
Open
feat(mcp-app-sample): Add new simple MCP App sample#1133
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds a standalone sample for integrating Model Context Protocol (MCP) Apps into the A2UI environment, featuring a FastAPI agent and a Lit-based client. The implementation uses a double-sandboxed iframe architecture for security. Feedback focuses on resolving local environment dependencies in the agent's HTML, fixing a memory leak from an unremoved global message listener, and removing redundant component registration. Additionally, improvements were suggested for server response error handling and aligning Python version requirements between the project configuration and documentation.
samples/client/lit/mcp-app-sample/ui/custom-components/mcp-apps-component.ts
Outdated
Show resolved
Hide resolved
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.
Description:
This PR introduces a new sample application demonstrating how to integrate a secure MCP (Model Context Protocol) App within the A2UI environment. It provides a complete, minimal reference implementation covering both the agent-side logic and the client-side UI components.
Key Features:
Native Module Resolution: Uses an <script type="importmap"> inside the sandboxed iframe to resolve the @modelcontextprotocol/sdk at runtime, avoiding complex bundler workarounds.
Specification Alignment: Implements the recommended "Double-Iframe" security model (Host -> Proxy -> Guest) and uses allow-same-origin as specified by the community guidelines.
Documentation: Includes a detailed README.md covering architecture, setup steps, and security considerations for production deployment.
Files Added/Modified:
samples/agent/adk/mcp-app-sample/: New directory containing the Python agent server (agent.py) and instructions.
samples/client/lit/mcp-app-sample/: New directory containing the Lit-based client UI, custom component wrapper, and optimized Vite configuration.
Verification:
Verified that the client successfully renders the injected HTML content.
Verified that clicking the button inside the sandboxed iframe successfully triggers the expected JSON-RPC tool call to the agent.
Pre-launch Checklist
If you need help, consider asking for advice on the discussion board.