CopilotKit_Generative_UI_MCP_Framework
CLAUDE.md1 starsChanged 10 months agoMITView on GitHub
You're working inside the CopilotKit Generative UI MCP Framework, a project that combines CopilotKit's MCP Apps pattern with a suite of pre-configu*red MCP server integrations. The architecture enables AI agents to return interactive UI components that render directly in a browser-based chat interface. This project has three key layers: Layer 1: CopilotKit Frontend (Next.js) Layer 2: HTTP MCP Server Layer 3: MCP Server Integrations The core pattern works like this: 1. Look for existing tools first Before building anything new,…
- Reads credentials
The file
We split this CLAUDE.md into the rules it gives an agent
6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 45
Create a self-contained HTML file in mcp-server/src/apps/
- Very specific: line 53
Before building anything new, check mcp-server/src/ for existing tools.
- Distinctive: line 57
When you hit an error:
- Distinctive: line 59
Read the full error message and trace
- Distinctive: line 61
Document what you learned so it doesn't happen again
- Distinctive: line 64
When you find better methods, discover constraints, or encounter recurring issues, update the relevant code and documentation.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Instructions
You're working inside the CopilotKit Generative UI MCP Framework, a project that combines CopilotKit's MCP Apps pattern with a suite of pre-configu*red MCP server integrations. The architecture enables AI agents to return interactive UI components that render directly in a browser-based chat interface.
Architecture Overview
This project has three key layers:
Layer 1: CopilotKit Frontend (Next.js)
- Located in
src/app/ - Provides a browser-based chat sidebar powered by CopilotKit
- The API route at
src/app/api/copilotkit/route.tswires together the CopilotRuntime, BuiltInAgent, and MCPAppsMiddleware - Uses OpenRouter as the LLM provider (configured via
OPENAI_BASE_URLandOPENAI_API_KEY) - Model selection is configurable via
OPENROUTER_MODELenvironment variable (defaults toopenai/gpt-4o)
Layer 2: HTTP MCP Server
- Located in
mcp-server/ - An Express server using StreamableHTTPServerTransport from the MCP SDK
- Registers tools that return
_meta.ui/resourceUrireferences to HTML app resources - Serves self-contained HTML apps that CopilotKit renders in sandboxed iframes
- Runs on port 3001 by default
Layer 3: MCP Server Integrations
- Configured in
.mcp.jsonwith 9 pre-configured servers - These use stdio transport and are designed for Claude Code CLI/IDE usage
- Includes: n8n (workflow automation), Tavily (search), Vapi (voice), Zep (docs/memory), Pinecone (vectors), Apify (scraping), Supabase (database), OpenRouter (LLM routing), Google Workspace
The MCP Apps Pattern
The core pattern works like this:
- A user sends a message in the CopilotSidebar
- CopilotKit's BuiltInAgent processes the message via OpenRouter
- The agent decides to call an MCP tool (e.g.,
get-workflow-status) - MCPAppsMiddleware sends the tool call to the HTTP MCP server
- The tool returns data + a
_meta.ui/resourceUrireference - CopilotKit fetches the referenced HTML resource from the MCP server
- The HTML app is rendered in a sandboxed iframe within the chat
How to Add New MCP Apps
- Create a self-contained HTML file in
mcp-server/src/apps/ - Register a new tool in
mcp-server/src/server.tswith_meta.ui/resourceUri - Register a new resource in
mcp-server/src/server.tsthat serves the HTML - Restart the MCP server
How to Operate
1. Look for existing tools first
Before building anything new, check mcp-server/src/ for existing tools. Only add new ones when nothing covers the task.
2. Learn and adapt when things fail
When you hit an error:
- Read the full error message and trace
- Fix the code and retest
- Document what you learned so it doesn't happen again
3. Keep things current When you find better methods, discover constraints, or encounter recurring issues, update the relevant code and documentation.
File Structure
.claude/ # Claude Code settings
mcp-server/ # HTTP MCP server with UI-generating tools
src/server.ts # Express + MCP SDK server
src/apps/ # Self-contained HTML apps for UI rendering
src/app/ # Next.js App Router pages and API routes
api/copilotkit/ # CopilotKit runtime endpoint
.env # API keys and environment variables (NEVER commit)
.env.example # Template showing required env vars
.mcp.json # MCP server configuration (9 pre-configured servers)
CLAUDE.md # This file
README.md # Project setup and usage guideRunning the Project
npm run setup # Install all dependencies (root + mcp-server)
npm run dev:all # Start Next.js (port 3000) + MCP server (port 3001)Bottom Line
This framework connects CopilotKit's generative UI capabilities with MCP servers. The HTTP MCP server demonstrates how tools can return interactive HTML interfaces. The pre-configured MCP integrations provide a starting point for extending the system with real data sources.
Stay pragmatic. Stay reliable. Keep learning.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

