|
| 1 | +# OpenGenerativeUI MCP Server |
| 2 | + |
| 3 | +A standalone, independently deployable [Model Context Protocol](https://modelcontextprotocol.io) server that exposes OpenGenerativeUI's design system, skills, and document renderer to any MCP-compatible client. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Design System Tool** — `assemble_document` wraps HTML fragments with OpenGenerativeUI's complete CSS design system and bridge JavaScript |
| 8 | +- **Skill Resources** — Browse and read skill instruction documents via `skills://list` and `skills://{name}` |
| 9 | +- **Prompt Templates** — Pre-composed prompts for common visualization tasks: `create_widget`, `create_svg_diagram`, `create_visualization` |
| 10 | +- **Standalone** — No dependencies on other packages; can be deployed independently |
| 11 | +- **Configurable** — Environment variables for port, CORS origins, skills directory, and logging |
| 12 | + |
| 13 | +## Quick Start |
| 14 | + |
| 15 | +### Prerequisites |
| 16 | +- Node.js >= 18 |
| 17 | +- pnpm or npm |
| 18 | + |
| 19 | +### Installation |
| 20 | + |
| 21 | +```bash |
| 22 | +# Navigate to the MCP package |
| 23 | +cd apps/mcp |
| 24 | + |
| 25 | +# Install dependencies |
| 26 | +pnpm install |
| 27 | + |
| 28 | +# Start the development server |
| 29 | +pnpm dev |
| 30 | +# → MCP server running on http://localhost:3100/mcp |
| 31 | + |
| 32 | +# Health check |
| 33 | +curl http://localhost:3100/health |
| 34 | +# → {"status":"ok"} |
| 35 | +``` |
| 36 | + |
| 37 | +### Build for Production |
| 38 | + |
| 39 | +```bash |
| 40 | +pnpm build |
| 41 | +pnpm start |
| 42 | +``` |
| 43 | + |
| 44 | +## Configuration |
| 45 | + |
| 46 | +Create a `.env` file in the package root (copy from `.env.example`): |
| 47 | + |
| 48 | +```bash |
| 49 | +# Server port (default: 3100) |
| 50 | +MCP_PORT=3100 |
| 51 | + |
| 52 | +# CORS origins, comma-separated (default: * for development) |
| 53 | +ALLOWED_ORIGINS=* |
| 54 | + |
| 55 | +# Skills directory path (default: ./skills) |
| 56 | +SKILLS_DIR=./skills |
| 57 | + |
| 58 | +# Log level (default: info) |
| 59 | +LOG_LEVEL=info |
| 60 | +``` |
| 61 | + |
| 62 | +## Usage |
| 63 | + |
| 64 | +### From Claude Code |
| 65 | + |
| 66 | +Add to `.mcp.json`: |
| 67 | + |
| 68 | +```json |
| 69 | +{ |
| 70 | + "openGenerativeUI": { |
| 71 | + "url": "http://localhost:3100/mcp" |
| 72 | + } |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +Then use the available tools and resources in Claude conversations. |
| 77 | + |
| 78 | +### From Any MCP Client |
| 79 | + |
| 80 | +Connect via HTTP MCP transport to `http://localhost:3100/mcp`. |
| 81 | + |
| 82 | +## API Reference |
| 83 | + |
| 84 | +### Tool: `assemble_document` |
| 85 | + |
| 86 | +Wraps an HTML fragment with the complete OpenGenerativeUI design system. |
| 87 | + |
| 88 | +**Input:** |
| 89 | +```typescript |
| 90 | +{ |
| 91 | + title: string; // Short title, e.g., "Binary Search Visualization" |
| 92 | + description: string; // One-sentence explanation |
| 93 | + html: string; // Self-contained HTML fragment (inline <style> and <script> OK) |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +**Output:** |
| 98 | +```typescript |
| 99 | +{ |
| 100 | + content: [{ |
| 101 | + type: "text", |
| 102 | + text: string // Complete HTML document, ready to render in iframe |
| 103 | + }] |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +**Example:** |
| 108 | +```javascript |
| 109 | +const result = await client.callTool("assemble_document", { |
| 110 | + title: "Interactive Algorithm Visualizer", |
| 111 | + description: "Step-by-step visualization of the quicksort algorithm", |
| 112 | + html: ` |
| 113 | + <div id="viz"> |
| 114 | + <p>Click to start visualization</p> |
| 115 | + <script> |
| 116 | + // Your visualization code here |
| 117 | + </script> |
| 118 | + </div> |
| 119 | + ` |
| 120 | +}); |
| 121 | + |
| 122 | +// result.content[0].text is a complete HTML document |
| 123 | +// Render in: <iframe sandbox="allow-scripts allow-same-origin" srcdoc={result.content[0].text} /> |
| 124 | +``` |
| 125 | + |
| 126 | +### Resource: `skills://list` |
| 127 | + |
| 128 | +Returns a JSON array of available skill names. |
| 129 | + |
| 130 | +**Example:** |
| 131 | +```bash |
| 132 | +curl -X POST http://localhost:3100/mcp \ |
| 133 | + -H "Content-Type: application/json" \ |
| 134 | + -d '{ |
| 135 | + "jsonrpc": "2.0", |
| 136 | + "id": 1, |
| 137 | + "method": "resources/read", |
| 138 | + "params": { "uri": "skills://list" } |
| 139 | + }' |
| 140 | +``` |
| 141 | + |
| 142 | +### Resource: `skills://{name}` |
| 143 | + |
| 144 | +Retrieve the full text content of a specific skill. |
| 145 | + |
| 146 | +Available skills: |
| 147 | +- `master-agent-playbook` — When and how to create interactive HTML widgets |
| 148 | +- `svg-diagram-skill` — SVG diagram templates and patterns |
| 149 | +- `agent-skills-vol2` — Advanced visualizations, dashboards, simulations |
| 150 | + |
| 151 | +**Example:** |
| 152 | +```bash |
| 153 | +curl -X POST http://localhost:3100/mcp \ |
| 154 | + -H "Content-Type: application/json" \ |
| 155 | + -d '{ |
| 156 | + "jsonrpc": "2.0", |
| 157 | + "id": 1, |
| 158 | + "method": "resources/read", |
| 159 | + "params": { "uri": "skills://master-agent-playbook" } |
| 160 | + }' |
| 161 | +``` |
| 162 | + |
| 163 | +### Prompts |
| 164 | + |
| 165 | +#### `create_widget` |
| 166 | +Instructions for creating interactive HTML widgets. |
| 167 | + |
| 168 | +#### `create_svg_diagram` |
| 169 | +Instructions for creating inline SVG diagrams with canonical templates. |
| 170 | + |
| 171 | +#### `create_visualization` |
| 172 | +Advanced visualization instructions: dashboards, simulations, UI mockups. |
| 173 | + |
| 174 | +## Deployment |
| 175 | + |
| 176 | +### Docker |
| 177 | + |
| 178 | +```bash |
| 179 | +# Build image |
| 180 | +docker build -t open-generative-ui-mcp . |
| 181 | + |
| 182 | +# Run container |
| 183 | +docker run -p 3100:3100 open-generative-ui-mcp |
| 184 | + |
| 185 | +# With custom port and CORS |
| 186 | +docker run \ |
| 187 | + -p 3100:3100 \ |
| 188 | + -e MCP_PORT=3100 \ |
| 189 | + -e ALLOWED_ORIGINS="http://localhost:3000,https://myapp.com" \ |
| 190 | + open-generative-ui-mcp |
| 191 | +``` |
| 192 | + |
| 193 | +### Node.js |
| 194 | + |
| 195 | +```bash |
| 196 | +# Install globally or locally |
| 197 | +npm install -g open-generative-ui-mcp |
| 198 | + |
| 199 | +# Run |
| 200 | +MCP_PORT=3100 ALLOWED_ORIGINS="*" open-generative-ui-mcp |
| 201 | + |
| 202 | +# Or with node |
| 203 | +node dist/index.js |
| 204 | +``` |
| 205 | + |
| 206 | +### Cloud Deployment |
| 207 | + |
| 208 | +The server is a standard Node.js application and can be deployed to: |
| 209 | +- **Heroku**: `Procfile: web: node dist/index.js` |
| 210 | +- **Railway**: Connect the repo, select Node.js, set `start` script |
| 211 | +- **Vercel**: Use serverless function (requires adapter) |
| 212 | +- **AWS Lambda**: Package with Node.js runtime |
| 213 | +- **Google Cloud Run**: Use Dockerfile |
| 214 | + |
| 215 | +## Development |
| 216 | + |
| 217 | +### Project Structure |
| 218 | + |
| 219 | +``` |
| 220 | +apps/mcp/ |
| 221 | +├── package.json # Standalone package definition |
| 222 | +├── tsconfig.json # TypeScript config |
| 223 | +├── .env.example # Configuration template |
| 224 | +├── Dockerfile # Container definition |
| 225 | +├── skills/ # Skill instruction files (copied from source) |
| 226 | +└── src/ |
| 227 | + ├── index.ts # Hono HTTP server entry point |
| 228 | + ├── server.ts # MCP server construction |
| 229 | + ├── skills.ts # Skill file loader |
| 230 | + └── renderer.ts # Design system CSS + assembleDocument |
| 231 | +``` |
| 232 | + |
| 233 | +### Extending Skills |
| 234 | + |
| 235 | +Add new skill files to `skills/` directory as `.txt` files. They'll automatically be available as resources and can be used in prompts. |
| 236 | + |
| 237 | +### Modifying the Design System |
| 238 | + |
| 239 | +Edit `src/renderer.ts` to update: |
| 240 | +- `THEME_CSS` — Theme colors and variables |
| 241 | +- `SVG_CLASSES_CSS` — Pre-built SVG helper classes |
| 242 | +- `FORM_STYLES_CSS` — Form element styling |
| 243 | +- `BRIDGE_JS` — Communication bridge between iframe and parent |
| 244 | + |
| 245 | +## License |
| 246 | + |
| 247 | +MIT |
| 248 | + |
| 249 | +## Support |
| 250 | + |
| 251 | +For issues, feature requests, or questions, visit the [OpenGenerativeUI repository](https://github.com/CopilotKit/OpenGenerativeUI). |
| 252 | + |
| 253 | +## Contributing |
| 254 | + |
| 255 | +This is a standalone deployment package. To contribute improvements: |
| 256 | + |
| 257 | +1. Fork the main [OpenGenerativeUI repository](https://github.com/CopilotKit/OpenGenerativeUI) |
| 258 | +2. Make changes to `apps/mcp/` (or the source files it's forked from) |
| 259 | +3. Submit a pull request |
| 260 | + |
| 261 | +When updating skills or the design system in the main repo, the MCP package should be updated accordingly. |
0 commit comments