Skip to content

Latest commit

 

History

History

README.md

AI MCP App Builder

Describe an MCP app in chat and get a live, sandboxed instance back. Built with CopilotKit, AG-UI, Mastra, and E2B sandboxes.

Gen UI concept — agent-generated apps. Most generative UI picks from a fixed catalogue of components. This goes a step further: the agent authors a brand-new MCP app at runtime, the builder provisions an E2B sandbox to host it, and the app renders inline with full bidirectional tool access. The "component" the agent emits is a whole app.

This monorepo wires up the MCP App builder web UI (apps/web) to a Mastra agent (/api/mastra-agent) that provisions E2B sandboxes running the mcp-use-server template (apps/mcp-use-server). An optional local sample is the Three.js MCP example in apps/threejs-server (used for sidebar defaults when running everything locally).

demo-mcp-app-builder.mp4

Prerequisites

  • Node.js 20+
  • pnpm (required for the workspace)
  • OpenAI API key (OPENAI_API_KEY); optional OPENAI_MODEL for /api/mastra-agent (default gpt-5.5)

Getting started

From the project root (generative_ui_agents/ai-mcp-app-builder):

pnpm i
Copy-Item .env.example .env
# Edit .env: set OPENAI_API_KEY=sk-proj-... at minimum; add E2B_* for sandbox provisioning (see below)
pnpm dev

pnpm dev runs Turbo and starts workspace dev tasks (the Next.js app and other configured apps — see root package.json / turbo.json).

Run pieces individually

Goal Command
Web app only pnpm --filter web dev (from repo root) or cd apps/web && pnpm dev
Three.js MCP sample (local sidebar default) cd apps/threejs-server && pnpm dev
mcp-use-server (local MCP, not the E2B image) cd apps/mcp-use-server && pnpm dev

Open the URL shown by Next (usually http://localhost:3000).

Dynamic MCP UI (sidebar)

  • MCP servers: add/remove by URL (+ optional serverId); list is sent as x-mcp-servers. Built-in default: Excalidraw (https://mcp.excalidraw.com). Override via NEXT_PUBLIC_DEFAULT_MCP_SERVERS / DEFAULT_MCP_SERVERS.
  • Tools: compact list; open a tool for detail + preview in a modal (not a third mobile tab).
  • Chat: CopilotKit v2 chat with suggestions.

Mobile layout

  • Tabs: Chat and Tools (servers + tool list). Tool preview / detail opens in a modal.
  • Desktop: sidebar + chat column (md+).
  • Chat UX: spacing and bottom padding so the composer does not cover the latest messages.

Environment variables (E2B)

Variable Description
E2B_API_KEY From e2b.dev/dashboard
E2B_TEMPLATE templateId from Template.build output after build.dev.ts / build.prod.ts
E2B_REPO_URL Used when E2B_TEMPLATE is empty — clones repo into sandbox (slower cold start). Default in code: mcp-use-server-template GitHub URL

Documentation

UI entry: apps/web/app/page.tsx (theme, layout, CopilotKit wiring).

External