You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+113-7Lines changed: 113 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,25 +31,124 @@ Start the OAuth demo (port 3001):
31
31
npm run dev:oauth
32
32
```
33
33
34
-
Start the MCP server (port 3000). By default, local runs use opaque tokens via the demo OAuth server (introspection mode). Place your env in `.env` and run dev for hot reload:
34
+
## Tool Modes & Development
35
+
36
+
This server supports three distinct tool modes, each optimized for different use cases. Choose the mode that best fits your needs:
The basic mode provides core MCP functionality with simple text-based tool responses. Perfect for understanding the MCP protocol without UI complexity.
35
43
36
44
```bash
37
-
# .env (local opaque token default)
38
-
# OAUTH_SERVER_URL defaults to http://localhost:3001
39
-
# OAUTH_INTROSPECT_URL defaults to ${OAUTH_SERVER_URL}/introspect
45
+
npm run dev
46
+
```
40
47
41
-
DISABLE_AUTH=false
42
-
AUTH_TOKEN_MODE=introspection
48
+
**Features:**
49
+
- Pure MCP protocol implementation
50
+
- Text-based tool responses
51
+
- Minimal dependencies
52
+
- Fast and lightweight
53
+
54
+
### 🎨 HTML UI Mode
55
+
56
+
**Best for:** Quick prototypes, simple forms, and lightweight interactive components.
57
+
58
+
HTML UI mode enables rich, interactive components using vanilla HTML, CSS, and JavaScript. Components are served as standalone HTML files that can be embedded in MCP clients.
59
+
60
+
```bash
61
+
npm run dev:ui-html
62
+
```
63
+
64
+
**Features:**
65
+
- Interactive HTML components
66
+
- No build step required
67
+
- Fast iteration
68
+
- Lightweight bundle size
69
+
70
+
### ⚛️ React UI Mode
71
+
72
+
**Best for:** Complex, stateful components and modern React-based UIs.
73
+
74
+
React UI mode provides full React component support with TypeScript, enabling sophisticated user interfaces with state management, hooks, and modern React patterns.
75
+
76
+
```bash
77
+
npm run dev:ui-react
78
+
```
79
+
80
+
**Features:**
81
+
- Full React 18+ support
82
+
- TypeScript for type safety
83
+
- Component state management
84
+
- Modern React patterns (hooks, context, etc.)
85
+
86
+
### 🧪 React Component Development
43
87
88
+
The `web/` directory contains a lightweight React development environment for designing and testing your UI components locally.
89
+
90
+
**Start the development server:**
91
+
```bash
92
+
cd web
44
93
npm run dev
45
94
```
46
95
47
-
Tip: If you want to run MCP without auth locally, set the explicit flag (in env or inline):
96
+
This launches a Vite-powered dev server with:
97
+
- ⚡ Hot module replacement (instant updates)
98
+
- 🔍 Component preview in browser
99
+
- 🎯 Mock `window.openai` API for testing
100
+
- 📦 Automatic TypeScript compilation
101
+
102
+
Edit `web/src/components/greet.tsx` and see your changes instantly. The mock API simulates tool calls, so you can develop and test your component's behavior without running the full MCP server.
48
103
104
+
**Build for production:**
105
+
```bash
106
+
cd web
107
+
npm run build
108
+
```
109
+
110
+
This generates `web/dist/greet.js`, which is automatically included when running the MCP server in React UI mode.
111
+
112
+
### 🐳 Docker Configuration
113
+
114
+
In production deployments, configure the tool mode by changing the `CMD` in your Dockerfile to use the appropriate npm script. The npm scripts already set the `TOOL_MODE` environment variable internally, so you don't need to set it separately.
115
+
116
+
**Dockerfile:**
117
+
```dockerfile
118
+
# Choose the start script that matches your desired mode:
-**Basic mode:** Returns simple text response: `"Hello, Elin!"`
300
+
-**HTML UI mode:** Returns HTML component template (`ui://widget/greet.html`) with structured content for hydration
301
+
-**React UI mode:** Returns React component template (`ui://widget/greet.js`) with full React support and state management
302
+
303
+
In UI modes, rich clients can render interactive components that allow users to interact directly with the tool, and components can initiate tool calls via the `window.openai.callTool` API when supported.
0 commit comments