What Are MCP Apps?
MCP Apps are interactive UI components that render inside chat conversationsβthink of them as "widgets in chat" that can display rich interfaces, handle user interactions, and communicate with your agent.
Why MCP Apps?
Rich Interfaces
Show data visualizations, interactive forms, product cards, document editorsβanything HTML can do.
Two-Way Communication
Apps can send messages, call tools, and persist state. Agents can stream updates and results back.
Secure & Sandboxed
Runs in isolated iframe with CSP enforcement, protecting your app from malicious content.
Built on Open Standards
MCP Apps are defined by SEP-1865, part of the Model Context Protocol (MCP) specification. This ensures compatibility across different MCP-enabled hosts and clients.
How to Define MCP Apps
1. Add UI Metadata to Your Tool
Tools can reference an MCP App by adding _meta.ui metadata. This tells the host which UI resource to render when the tool is called.
2. Provide the UI Resource
Add a resource with matching URI that returns HTML content. The MIME type must be text/html;profile=mcp-app.
π‘ Tip: You can deliver MCP Apps as inline HTML (bundled string) or remote HTTPS URL. See Inline vs Remote guide for details.
Building MCP Apps with useMcpApp Hook
The useMcpApp hook from mcp-app-view (open source) handles the MCP protocol communication, making it easy to build interactive widgets.
Secure Hosting with MCP App Proxy
For security, MCP Apps must run in a sandboxed iframe with a different origin than your host app. BotDojo provides an open-source proxy server that implements the double-iframe architecture required by SEP-1865.
Public Proxy Instance
https://mcp-app-proxy.botdojo.com/Open Source Repository
How the Proxy Works
The different origin prevents MCP Apps from accessing your host app's cookies, localStorage, or making authenticated requests. The proxy forwards all JSON-RPC messages transparently while enforcing Content Security Policy.
β Implementation Checklist
- Define tool with UI metadata: Add
_meta.ui.resourceUrito your tool - Provide UI resource: Add resource with MIME type
text/html;profile=mcp-app - Build your widget: Use
useMcpApphook from mcp-app-view - Handle callbacks: Implement
onToolCall,onUiMessage,onOpenLinkin your host - Set cache key: Provide
cacheKeyprop for optimal performance
π Examples & Guides
Tool Progress Example
Streaming progress updates, state persistence, and tool interactions
Product Enhancement
Real-world example with side-by-side comparison UI
Bonsai Shop Demo
Full e-commerce demo with product browsing and cart
useMcpApp Hook Guide
Complete reference for building MCP App widgets