Skip to content

Commit fada403

Browse files
authored
Merge pull request #18 from CopilotKit/feat/mcp-server
Add standalone OpenGenerativeUI MCP Server
2 parents 1fde890 + 82cf3eb commit fada403

18 files changed

+2501
-107
lines changed

README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,60 @@ make dev # Start all services
4242

4343
You can also use `pnpm` directly (`pnpm dev`, `pnpm dev:app`, `pnpm dev:agent`, etc.).
4444

45+
## MCP Server (Self-Hosted)
46+
47+
The repo includes a standalone [Model Context Protocol](https://modelcontextprotocol.io) server that exposes the design system, skill instructions, and an HTML document assembler to any MCP-compatible client — including Claude Desktop, Claude Code, and Cursor.
48+
49+
### What it provides
50+
51+
- **`assemble_document` tool** — wraps HTML fragments with the full design system CSS and bridge JS, returning an iframe-ready document
52+
- **Skill resources** — browse and read skill instruction documents (`skills://list`, `skills://{name}`)
53+
- **Prompt templates** — pre-composed prompts for widgets, SVG diagrams, and advanced visualizations
54+
55+
### Claude Desktop (stdio)
56+
57+
Add to your Claude Desktop config (`claude_desktop_config.json`):
58+
59+
```json
60+
{
61+
"mcpServers": {
62+
"open-generative-ui": {
63+
"command": "node",
64+
"args": ["dist/stdio.js"],
65+
"cwd": "/path/to/apps/mcp"
66+
}
67+
}
68+
}
69+
```
70+
71+
### Claude Code / HTTP clients
72+
73+
```bash
74+
# Start the HTTP server
75+
cd apps/mcp && pnpm dev
76+
```
77+
78+
Add to `.mcp.json`:
79+
80+
```json
81+
{
82+
"openGenerativeUI": {
83+
"url": "http://localhost:3100/mcp"
84+
}
85+
}
86+
```
87+
88+
See [apps/mcp/README.md](apps/mcp/README.md) for full configuration, Docker deployment, and API reference.
89+
4590
## Architecture
4691

47-
Turborepo monorepo with two apps:
92+
Turborepo monorepo with three packages:
4893

4994
```
5095
apps/
5196
├── app/ Next.js 16 frontend (CopilotKit v2, React 19, Tailwind 4)
52-
└── agent/ LangGraph Python agent (GPT-5.4, CopilotKit middleware)
97+
├── agent/ LangGraph Python agent (GPT-5.4, CopilotKit middleware)
98+
└── mcp/ Standalone MCP server (design system + skills + document assembler)
5399
```
54100

55101
### How It Works

apps/mcp/.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules/
2+
npm-debug.log
3+
.git
4+
.gitignore
5+
README.md
6+
.env.example
7+
.DS_Store
8+
dist/
9+
.turbo/

apps/mcp/.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Server Configuration
2+
MCP_PORT=3100
3+
NODE_ENV=development
4+
5+
# CORS (comma-separated origins, default: * for development)
6+
ALLOWED_ORIGINS=*
7+
8+
# Skills directory (default: ./skills relative to package root)
9+
SKILLS_DIR=./skills
10+
11+
# Logging
12+
LOG_LEVEL=info

apps/mcp/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules/
2+
dist/
3+
.env
4+
.env.local
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
.DS_Store
10+
.turbo/
11+
.venv/

apps/mcp/Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Multi-stage build for production
2+
FROM node:20-alpine AS builder
3+
4+
WORKDIR /app
5+
6+
# Install build dependencies
7+
RUN apk add --no-cache python3 make g++
8+
9+
# Copy package files
10+
COPY package.json pnpm-lock.yaml ./
11+
12+
# Install pnpm
13+
RUN npm install -g pnpm@9
14+
15+
# Install dependencies
16+
RUN pnpm install --frozen-lockfile
17+
18+
# Copy source
19+
COPY tsconfig.json ./
20+
COPY src ./src
21+
COPY skills ./skills
22+
23+
# Build
24+
RUN pnpm build
25+
26+
# Production image
27+
FROM node:20-alpine
28+
29+
WORKDIR /app
30+
31+
# Install dumb-init for proper signal handling
32+
RUN apk add --no-cache dumb-init
33+
34+
# Copy built application from builder
35+
COPY --from=builder /app/dist ./dist
36+
COPY --from=builder /app/skills ./skills
37+
COPY --from=builder /app/node_modules ./node_modules
38+
COPY package.json ./
39+
40+
# Non-root user
41+
RUN addgroup -g 1001 -S nodejs && \
42+
adduser -S nodejs -u 1001
43+
44+
USER nodejs
45+
46+
# Health check
47+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
48+
CMD wget --no-verbose --tries=1 --spider http://localhost:${MCP_PORT:-3100}/health || exit 1
49+
50+
EXPOSE 3100
51+
52+
ENTRYPOINT ["/sbin/dumb-init", "--"]
53+
CMD ["node", "dist/index.js"]

0 commit comments

Comments
 (0)