Skip to content
Back to search

generative-ui-playground

Interact with all three types of generative UI, all in one interface

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/copilotkit--generative-ui-playground/badge.svg)](/listings/copilotkit--generative-ui-playground)

HTML

<a href="/listings/copilotkit--generative-ui-playground"><img src="/api/listings/copilotkit--generative-ui-playground/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Prerequisites

- Node.js 18+ - Python 3.11+ - OpenAI API key

Installation

# Clone and install dependencies
cd ui-protocols-demo
npm install

# Install MCP server dependencies
cd mcp-server
npm install
cd ..

# Install Python A2A agent
cd a2a-agent
pip install -e .
cd ..

Environment Variables

Create a `.env` file:

OPENAI_API_KEY=sk-your-key-here
MCP_SERVER_URL=http://localhost:3001/mcp
A2A_AGENT_URL=http://localhost:10002

Running the Demo

Start all three services:

# Terminal 1: MCP Server (port 3001)
cd mcp-server && npm run dev

# Terminal 2: Python A2A Agent (port 10002)
cd a2a-agent && python -m agent

# Terminal 3: Next.js Frontend (port 3000)
npm run dev

Open http://localhost:3000 to see the demo.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 141 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Generative UI Demo
  2. https://github.com/user-attachments/assets/79ead351-f63c-4119-9d28-9d604e7f8876
  3. A generative UI playground showcasing the three types for building AI-powered user interfaces with CopilotKit.
  4. ## Demo Overview
  5. This demo demonstrates how different types of generative UI can be used to create rich, interactive AI experiences:
  6. | Spec | Description | Use Case |
  7. |----------|-------------|----------|
  8. | **Static GenUI** | Pre-built React components rendered by frontend hooks | Weather cards, stock displays, task approvals |
  9. | **MCP Apps** | HTML/JS apps served by MCP servers in sandboxed iframes | Flight booking, hotel search, trading simulator |
  10. | **A2UI** | Agent-composed declarative JSON UI rendered dynamically | Restaurant finder, booking forms |
  11. ## CopilotKit Features Used
  12. - **CopilotKitProvider** - Main provider with agent switching
  13. - **CopilotSidebar** - Chat interface component
  14. - **useRenderToolCall** - Display-only tool rendering (WeatherCard, StockCard)
  15. - **useHumanInTheLoop** - Interactive approval flows (TaskApprovalCard)
  16. - **A2UIRenderer** - Renders A2UI declarative JSON from agent responses
  17. - **MCPAppsMiddleware** - Bridges MCP server tools with UI resources
  18. - **BasicAgent** - TypeScript agent for Static GenUI + MCP Apps
  19. - **HttpAgent** - Connects to Python A2A backend for A2UI
  20. ## Setup
  21. ### Prerequisites
  22. - Node.js 18+
  23. - Python 3.11+
  24. - OpenAI API key
  25. ### Installation
  26. ```bash
  27. # Clone and install dependencies
  28. cd ui-protocols-demo
  29. npm install
  30. # Install MCP server dependencies
  31. cd mcp-server
  32. npm install
  33. cd ..
  34. # Install Python A2A agent
  35. cd a2a-agent
  36. pip install -e .
  37. cd ..
  38. ```
  39. ### Environment Variables
  40. Create a `.env` file:
  41. ```bash
  42. OPENAI_API_KEY=sk-your-key-here
  43. MCP_SERVER_URL=http://localhost:3001/mcp
  44. A2A_AGENT_URL=http://localhost:10002
  45. ```
  46. ### Running the Demo
  47. Start all three services:
  48. ```bash
  49. # Terminal 1: MCP Server (port 3001)
  50. cd mcp-server && npm run dev
  51. # Terminal 2: Python A2A Agent (port 10002)
  52. cd a2a-agent && python -m agent
  53. # Terminal 3: Next.js Frontend (port 3000)
  54. npm run dev
  55. ```
  56. Open http://localhost:3000 to see the demo.
  57. ## Usage
  58. ### Static + MCP Apps Mode
  59. Click the "Static + MCP Apps" tab to use:
  60. - "What's the weather in Tokyo?" → Weather card
  61. - "Get stock price for AAPL" → Stock card with sparkline
  62. - "Open the calculator" → Interactive calculator app
  63. - "Search for flights to Paris" → Flight booking workflow
  64. ### A2UI Mode
  65. Click the "A2UI" tab to use:
  66. - "Find Italian restaurants nearby" → Restaurant list with booking
  67. - "Show me Chinese food options" → Filtered results
  68. - "Book a table for 4" → Interactive booking form
  69. ## Architecture
  70. ```
  71. Frontend (Next.js) ─────────────────────────────────────────────────────
  72. ├── Protocol tabs switch between agents
  73. ├── Static GenUI: useRenderToolCall, useHumanInTheLoop
  74. ├── MCP Apps: Automatic iframe rendering via middleware events
  75. └── A2UI: A2UIRenderer for declarative JSON
  76. │
  77. ┌─────────┴─────────┐
  78. ▼ ▼
  79. "default" Agent "a2ui" Agent
  80. BasicAgent + MCP HttpAgent → Python
  81. Port 3001 Port 10002
  82. ```
  83. ## Project Structure
  84. ```
  85. ui-protocols-demo/
  86. ├── src/app/ # Next.js frontend
  87. │ ├── page.tsx # Main page with agent switching
  88. │ ├── theme.ts # A2UI theme configuration
  89. │ ├── api/copilotkit/ # CopilotKit API route
  90. │ └── components/ # React components
  91. ├── mcp-server/ # MCP Apps server
  92. │ ├── server.ts # Tool registrations
  93. │ └── apps/ # HTML app files
  94. └── a2a-agent/ # Python A2A agent
  95. └── agent/ # Agent modules
  96. ```
  97. ## Learn More
  98. - [CopilotKit Documentation](https://docs.copilotkit.ai)
  99. - [Generative UI Types](https://www.copilotkit.ai/generative-ui)
  100. - [A2UI Specification](https://a2ui.org)
  101. - [MCP Apps](https://modelcontextprotocol.io)
  102. ---
  103. > **Note:** This project has been consolidated into the [CopilotKit monorepo](https://github.com/CopilotKit/CopilotKit).
  104. > The latest version lives at [`examples/showcases/generative-ui-playground`](https://github.com/CopilotKit/CopilotKit/tree/main/examples/showcases/generative-ui-playground).
  105. > Please open issues and pull requests in the [main CopilotKit repository](https://github.com/CopilotKit/CopilotKit).

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.