MCP App View
A container for MCP server UIs with security indicators, permission management, and JSON-RPC message logging. Pass srcDoc or src to host a real app in a sandboxed iframe; without them it shows mock content.
Interactive Preview
Toggle connection status and app type to explore different states
Connection States
The component adapts its UI based on the MCP server connection status
Connected
Disconnected
MCP Server Disconnected
Unable to render app content
Error
Connection Error
Failed to establish secure channel with MCP server
Hosted App
Pass srcDoc or src to run a real app. It renders in an iframe with sandbox="allow-scripts" and no same-origin access, so it cannot touch this page
App Types
Four built-in app type simulations with distinct visual layouts
form
dashboard
data-viz
settings
Props
MCPAppView component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
uri | string | 'ui://mcp.data-explorer/main' | The ui:// URI displayed in the address bar |
appName | string | 'Data Explorer' | Display name of the MCP application |
status | ConnectionStatus | 'connected' | Current connection status of the MCP server |
appType | AppType | 'dashboard' | Type of application being rendered in the sandbox |
permissions | MCPPermission[] | (6 default permissions) | List of permissions with granted/denied status |
messages | JSONRPCMessage[] | (6 default messages) | JSON-RPC message log for postMessage communication |
srcDoc | string | — | App HTML, rendered in an iframe with sandbox="allow-scripts" and no allow-same-origin. Without srcDoc or src the view shows mock content |
src | string | — | App URL, rendered in the same sandboxed iframe |
onAppMessage | (data: unknown) => void | — | Receives postMessage data, only when it comes from the app frame itself |
sandboxLabel | string | 'Sandboxed' with an app, 'Mock preview' without | Label shown in the security bar |
onReload | () => void | — | Callback when the reload button is clicked |
onInspect | () => void | — | Callback when the inspect button is clicked |
onRevokePermission | (name: string) => void | — | Callback when a specific permission is revoked |
onRevokeAll | () => void | — | Callback when all permissions are revoked |
showMessageLog | boolean | true | Whether to show the JSON-RPC message log panel |
showPermissions | boolean | true | Whether to show the permissions panel |
className | string | — | Additional CSS classes for the container |
ConnectionStatus
type ConnectionStatus = 'connected' | 'disconnected' | 'error'AppType
type AppType = 'form' | 'dashboard' | 'data-viz' | 'settings'MCPPermission
interface MCPPermission { name: string // e.g. 'read:files' granted: boolean // whether permission is active description?: string // human-readable description}JSONRPCMessage
interface JSONRPCMessage { id: number direction: 'inbound' | 'outbound' method: string // e.g. 'tools/call' timestamp: string // e.g. '14:23:01.203' params?: Record<string, unknown> result?: unknown error?: string}Usage
Import and implementation examples
import { MCPAppView } from '@/blocks/agentic/mcp-app-view'import type { MCPPermission, JSONRPCMessage } from '@/blocks/agentic/mcp-app-view'import { Button } from '@/components/ui/button'
export default function AgentWorkspace() { const permissions: MCPPermission[] = [ { name: 'read:files', granted: true, description: 'Read local files' }, { name: 'write:files', granted: false, description: 'Modify files' }, { name: 'network:outbound', granted: true, description: 'HTTP requests' }, ]
return ( <MCPAppView uri="ui://mcp.data-explorer/main" appName="Data Explorer" status="connected" appType="dashboard" permissions={permissions} onReload={() => console.log('Reloading...')} onInspect={() => console.log('Opening inspector...')} onRevokePermission={(name) => console.log('Revoked:', name)} onRevokeAll={() => console.log('All permissions revoked')} /> )}Minimal usage
{/* Uses all defaults - just drop it in */}<MCPAppView />
{/* Specific app type */}<MCPAppView appType="form" uri="ui://mcp.form-server/edit" />
{/* Error state without panels */}<MCPAppView status="error" showMessageLog={false} showPermissions={false}/>Built With
3 componentsThis block uses the following UI components from the design system:
Features
Built-in functionality
- Sandboxed container: Hosts the app in an iframe with sandbox="allow-scripts" and no same-origin access; shows mock content when no app is passed
- URI address bar: Displays ui:// URI scheme with shield icon, mimicking browser chrome
- Connection states: Connected (green pulse), disconnected (gray), error (rose) with adaptive UI
- Four app types: Form, dashboard, data-viz, and settings layouts with realistic skeleton content
- Permissions panel: Collapsible list showing granted/denied permissions with per-permission revocation
- JSON-RPC message log: Terminal-style log showing inbound/outbound MCP protocol messages with copy support
- Sandbox controls: Toolbar with reload, inspect, and revoke-all actions
- Security indicators: Visual cues showing sandbox status, lock state, and permission restrictions
- forwardRef support: Properly forwards refs for integration with form libraries and external control
Accessibility
Accessibility considerations
ARIA Attributes
Collapsible panels use native button elements for keyboard accessConnection status communicated through both color and text labelPermission states indicated by icon and granted/denied badge countsKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between toolbar buttons and collapsible panel headers |
| Enter / Space | Toggle permissions or message log panels, activate toolbar buttons |
Notes
- Terminal-style message log uses monospace font for readability
- Copy button in message log appears on hover with descriptive title attribute
- Status changes are reflected in both security bar badge and address bar indicator
- Consider adding aria-expanded to collapsible panel toggles
- Consider adding role="log" to the JSON-RPC message container
- Traffic light dots are decorative and do not require alt text