create-mcp-use-app 0.2.2 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +444 -0
- package/dist/index.js +88 -11
- package/dist/templates/ui/README.md +9 -9
- package/dist/templates/ui/index.ts +12 -0
- package/dist/templates/ui/package.json +6 -5
- package/dist/templates/ui/resources/kanban-board.tsx +1 -1
- package/dist/templates/ui/src/server.ts +17 -103
- package/dist/templates/ui/tsconfig.json +1 -1
- package/package.json +3 -3
- package/dist/templates/ui/resources/data-visualization.tsx +0 -475
- package/dist/templates/ui/resources/todo-list.tsx +0 -408
package/README.md
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
<div align="center" style="margin: 0 auto; max-width: 80%;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mcp-use/mcp-use-ts/main/packages/mcp-use/static/logo_white.svg">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/mcp-use/mcp-use-ts/main/packages/mcp-use/static/logo_black.svg">
|
|
5
|
+
<img alt="mcp use logo" src="https://raw.githubusercontent.com/mcp-use/mcp-use-ts/main/packages/mcp-use/static/logo_white.svg" width="80%" style="margin: 20px auto;">
|
|
6
|
+
</picture>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">Create MCP-Use App</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/create-mcp-use-app" alt="NPM Downloads">
|
|
13
|
+
<img src="https://img.shields.io/npm/dw/create-mcp-use-app.svg"/></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/create-mcp-use-app" alt="NPM Version">
|
|
15
|
+
<img src="https://img.shields.io/npm/v/create-mcp-use-app.svg"/></a>
|
|
16
|
+
<a href="https://github.com/mcp-use/mcp-use-ts/blob/main/LICENSE" alt="License">
|
|
17
|
+
<img src="https://img.shields.io/github/license/mcp-use/mcp-use-ts" /></a>
|
|
18
|
+
<a href="https://github.com/mcp-use/mcp-use-ts/stargazers" alt="GitHub stars">
|
|
19
|
+
<img src="https://img.shields.io/github/stars/mcp-use/mcp-use-ts?style=social" /></a>
|
|
20
|
+
<a href="https://discord.gg/XkNkSkMz3V" alt="Discord">
|
|
21
|
+
<img src="https://dcbadge.limes.pink/api/server/XkNkSkMz3V?style=flat" /></a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
🚀 **Create MCP-Use App** is the fastest way to scaffold a new MCP (Model Context Protocol) application. With just one command, you get a fully configured TypeScript project with hot reload, automatic inspector, and UI widget support - everything you need to build powerful MCP servers.
|
|
25
|
+
|
|
26
|
+
## 📦 Related Packages
|
|
27
|
+
|
|
28
|
+
| Package | Description | Version |
|
|
29
|
+
|---------|-------------|---------|
|
|
30
|
+
| [mcp-use](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/mcp-use) | Core MCP framework | [](https://www.npmjs.com/package/mcp-use) |
|
|
31
|
+
| [@mcp-use/cli](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/cli) | Build tool for MCP apps | [](https://www.npmjs.com/package/@mcp-use/cli) |
|
|
32
|
+
| [@mcp-use/inspector](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/inspector) | Web-based MCP inspector | [](https://www.npmjs.com/package/@mcp-use/inspector) |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## ⚡ Quick Start
|
|
37
|
+
|
|
38
|
+
Create a new MCP application in seconds:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx create-mcp-use-app my-mcp-server
|
|
42
|
+
cd my-mcp-server
|
|
43
|
+
npm run dev
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
That's it! Your MCP server is running at `http://localhost:3000` with the inspector automatically opened in your browser.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 🎯 What It Creates
|
|
51
|
+
|
|
52
|
+
Running `create-mcp-use-app` sets up a complete MCP development environment:
|
|
53
|
+
|
|
54
|
+
### Project Structure
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
my-mcp-server/
|
|
58
|
+
├── package.json # Pre-configured with all scripts
|
|
59
|
+
├── tsconfig.json # TypeScript configuration
|
|
60
|
+
├── .env.example # Environment variables template
|
|
61
|
+
├── .gitignore # Git ignore rules
|
|
62
|
+
├── README.md # Project documentation
|
|
63
|
+
├── src/
|
|
64
|
+
│ └── index.ts # MCP server entry point with example tools
|
|
65
|
+
├── resources/ # UI widgets directory
|
|
66
|
+
│ └── example-widget.tsx # Example React widget
|
|
67
|
+
└── dist/ # Build output (generated)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Pre-configured Features
|
|
71
|
+
|
|
72
|
+
| Feature | Description |
|
|
73
|
+
|---------|-------------|
|
|
74
|
+
| **📝 TypeScript** | Full TypeScript setup with proper types |
|
|
75
|
+
| **🔥 Hot Reload** | Auto-restart on code changes during development |
|
|
76
|
+
| **🔍 Auto Inspector** | Inspector UI opens automatically in dev mode |
|
|
77
|
+
| **🎨 UI Widgets** | React components that compile to standalone pages |
|
|
78
|
+
| **🛠️ Example Tools** | Sample MCP tools, resources, and prompts |
|
|
79
|
+
| **📦 Build Scripts** | Ready-to-use development and production scripts |
|
|
80
|
+
| **🚀 Production Ready** | Optimized build configuration |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 📖 Usage Options
|
|
85
|
+
|
|
86
|
+
### Interactive Mode
|
|
87
|
+
|
|
88
|
+
Run without any arguments to enter interactive mode:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npx create-mcp-use-app
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
You'll be prompted for:
|
|
95
|
+
- Project name
|
|
96
|
+
- Project template
|
|
97
|
+
- Package manager preference
|
|
98
|
+
|
|
99
|
+
### Direct Mode
|
|
100
|
+
|
|
101
|
+
Specify the project name directly:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npx create-mcp-use-app my-project
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### With Options
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Use a specific template
|
|
111
|
+
npx create-mcp-use-app my-project --template advanced
|
|
112
|
+
|
|
113
|
+
# Use a specific package manager
|
|
114
|
+
npx create-mcp-use-app my-project --use-npm
|
|
115
|
+
npx create-mcp-use-app my-project --use-yarn
|
|
116
|
+
npx create-mcp-use-app my-project --use-pnpm
|
|
117
|
+
|
|
118
|
+
# Skip dependency installation
|
|
119
|
+
npx create-mcp-use-app my-project --skip-install
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 🎨 Available Templates
|
|
125
|
+
|
|
126
|
+
### Basic Template (Default)
|
|
127
|
+
|
|
128
|
+
The basic template includes:
|
|
129
|
+
- Simple MCP server setup
|
|
130
|
+
- Example tool, resource, and prompt
|
|
131
|
+
- Basic UI widget example
|
|
132
|
+
- Essential configuration files
|
|
133
|
+
|
|
134
|
+
Perfect for getting started quickly or building simple MCP servers.
|
|
135
|
+
|
|
136
|
+
### Advanced Template
|
|
137
|
+
|
|
138
|
+
The advanced template includes everything from basic plus:
|
|
139
|
+
- Multiple tools with complex schemas
|
|
140
|
+
- OAuth authentication example
|
|
141
|
+
- Database integration patterns
|
|
142
|
+
- Advanced UI widgets with state management
|
|
143
|
+
- Observability setup with Langfuse
|
|
144
|
+
- Docker configuration
|
|
145
|
+
- CI/CD workflows
|
|
146
|
+
|
|
147
|
+
Ideal for production applications or complex integrations.
|
|
148
|
+
|
|
149
|
+
### Minimal Template
|
|
150
|
+
|
|
151
|
+
The minimal template includes:
|
|
152
|
+
- Bare-bones MCP server
|
|
153
|
+
- No example tools or widgets
|
|
154
|
+
- Essential configuration only
|
|
155
|
+
|
|
156
|
+
Best for experienced developers who want full control.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 🏗️ What Gets Installed
|
|
161
|
+
|
|
162
|
+
The scaffolded project includes these dependencies:
|
|
163
|
+
|
|
164
|
+
### Core Dependencies
|
|
165
|
+
- `mcp-use` - The MCP framework
|
|
166
|
+
- `@mcp-use/cli` - Build and development tool
|
|
167
|
+
- `@mcp-use/inspector` - Web-based debugger
|
|
168
|
+
|
|
169
|
+
### Development Dependencies
|
|
170
|
+
- `typescript` - TypeScript compiler
|
|
171
|
+
- `tsx` - TypeScript executor for development
|
|
172
|
+
- `@types/node` - Node.js type definitions
|
|
173
|
+
|
|
174
|
+
### Optional Dependencies (Advanced Template)
|
|
175
|
+
- Database drivers (PostgreSQL, SQLite)
|
|
176
|
+
- Authentication libraries
|
|
177
|
+
- Monitoring tools
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 🚀 After Installation
|
|
182
|
+
|
|
183
|
+
Once your project is created, you can:
|
|
184
|
+
|
|
185
|
+
### Start Development
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
npm run dev
|
|
189
|
+
# or
|
|
190
|
+
yarn dev
|
|
191
|
+
# or
|
|
192
|
+
pnpm dev
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
This will:
|
|
196
|
+
1. Start the MCP server on port 3000
|
|
197
|
+
2. Open the inspector in your browser
|
|
198
|
+
3. Watch for file changes and auto-reload
|
|
199
|
+
|
|
200
|
+
### Build for Production
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
npm run build
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Creates an optimized build in the `dist/` directory.
|
|
207
|
+
|
|
208
|
+
### Start Production Server
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npm run start
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Runs the production build.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 💡 First Steps
|
|
219
|
+
|
|
220
|
+
After creating your app, here's what to do next:
|
|
221
|
+
|
|
222
|
+
### 1. Explore the Example Server
|
|
223
|
+
|
|
224
|
+
Open `src/index.ts` to see how to:
|
|
225
|
+
- Define MCP tools with Zod schemas
|
|
226
|
+
- Create resources for data access
|
|
227
|
+
- Set up prompts for AI interactions
|
|
228
|
+
|
|
229
|
+
### 2. Try the Inspector
|
|
230
|
+
|
|
231
|
+
The inspector automatically opens at `http://localhost:3000/inspector` where you can:
|
|
232
|
+
- Test your tools interactively
|
|
233
|
+
- View available resources
|
|
234
|
+
- Debug tool executions
|
|
235
|
+
- Monitor server status
|
|
236
|
+
|
|
237
|
+
### 3. Create a UI Widget
|
|
238
|
+
|
|
239
|
+
Edit `resources/example-widget.tsx` or create new widgets:
|
|
240
|
+
|
|
241
|
+
```tsx
|
|
242
|
+
import React from 'react'
|
|
243
|
+
import { useMcp } from 'mcp-use/react'
|
|
244
|
+
|
|
245
|
+
export default function MyWidget() {
|
|
246
|
+
const { callTool } = useMcp()
|
|
247
|
+
|
|
248
|
+
const handleClick = async () => {
|
|
249
|
+
const result = await callTool('my_tool', {
|
|
250
|
+
param: 'value'
|
|
251
|
+
})
|
|
252
|
+
console.log(result)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<div>
|
|
257
|
+
<button onClick={handleClick}>
|
|
258
|
+
Call MCP Tool
|
|
259
|
+
</button>
|
|
260
|
+
</div>
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### 4. Connect to AI
|
|
266
|
+
|
|
267
|
+
Use the MCP server with any MCP-compatible client:
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
import { MCPClient, MCPAgent } from 'mcp-use'
|
|
271
|
+
import { ChatOpenAI } from '@langchain/openai'
|
|
272
|
+
|
|
273
|
+
const client = new MCPClient({
|
|
274
|
+
url: 'http://localhost:3000/mcp'
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
const agent = new MCPAgent({
|
|
278
|
+
llm: new ChatOpenAI(),
|
|
279
|
+
client
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
const result = await agent.run('Use my MCP tools')
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 🔧 Configuration
|
|
288
|
+
|
|
289
|
+
### Environment Variables
|
|
290
|
+
|
|
291
|
+
The created project includes a `.env.example` file:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Server Configuration
|
|
295
|
+
PORT=3000
|
|
296
|
+
NODE_ENV=development
|
|
297
|
+
|
|
298
|
+
# OAuth (if using authentication)
|
|
299
|
+
OAUTH_CLIENT_ID=your_client_id
|
|
300
|
+
OAUTH_CLIENT_SECRET=your_client_secret
|
|
301
|
+
|
|
302
|
+
# Database (if using database)
|
|
303
|
+
DATABASE_URL=postgresql://localhost/myapp
|
|
304
|
+
|
|
305
|
+
# Observability (optional)
|
|
306
|
+
LANGFUSE_PUBLIC_KEY=your_public_key
|
|
307
|
+
LANGFUSE_SECRET_KEY=your_secret_key
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Copy to `.env` and configure as needed:
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
cp .env.example .env
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### TypeScript Configuration
|
|
317
|
+
|
|
318
|
+
The `tsconfig.json` is pre-configured for MCP development:
|
|
319
|
+
|
|
320
|
+
```json
|
|
321
|
+
{
|
|
322
|
+
"compilerOptions": {
|
|
323
|
+
"target": "ES2020",
|
|
324
|
+
"module": "ESNext",
|
|
325
|
+
"jsx": "react-jsx",
|
|
326
|
+
"strict": true,
|
|
327
|
+
"esModuleInterop": true,
|
|
328
|
+
"skipLibCheck": true,
|
|
329
|
+
"forceConsistentCasingInFileNames": true
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## 📚 Examples
|
|
337
|
+
|
|
338
|
+
### Creating a Tool
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
server.tool('search_database', {
|
|
342
|
+
description: 'Search for records in the database',
|
|
343
|
+
parameters: z.object({
|
|
344
|
+
query: z.string().describe('Search query'),
|
|
345
|
+
limit: z.number().optional().default(10)
|
|
346
|
+
}),
|
|
347
|
+
execute: async ({ query, limit }) => {
|
|
348
|
+
// Your tool logic here
|
|
349
|
+
const results = await db.search(query, limit)
|
|
350
|
+
return { results }
|
|
351
|
+
}
|
|
352
|
+
})
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Creating a Resource
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
server.resource('user_profile', {
|
|
359
|
+
description: 'Current user profile data',
|
|
360
|
+
uri: 'user://profile',
|
|
361
|
+
mimeType: 'application/json',
|
|
362
|
+
fetch: async () => {
|
|
363
|
+
const profile = await getUserProfile()
|
|
364
|
+
return JSON.stringify(profile)
|
|
365
|
+
}
|
|
366
|
+
})
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Creating a Prompt
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
server.prompt('code_review', {
|
|
373
|
+
description: 'Review code for best practices',
|
|
374
|
+
arguments: [
|
|
375
|
+
{ name: 'code', description: 'Code to review', required: true },
|
|
376
|
+
{ name: 'language', description: 'Programming language', required: false }
|
|
377
|
+
],
|
|
378
|
+
render: async ({ code, language }) => {
|
|
379
|
+
return `Please review this ${language || ''} code for best practices:\n\n${code}`
|
|
380
|
+
}
|
|
381
|
+
})
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
## 🐛 Troubleshooting
|
|
387
|
+
|
|
388
|
+
### Common Issues
|
|
389
|
+
|
|
390
|
+
**Command not found:**
|
|
391
|
+
```bash
|
|
392
|
+
# Make sure you have Node.js 18+ installed
|
|
393
|
+
node --version
|
|
394
|
+
|
|
395
|
+
# Try with npx
|
|
396
|
+
npx create-mcp-use-app@latest
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Permission denied:**
|
|
400
|
+
```bash
|
|
401
|
+
# On macOS/Linux, you might need sudo
|
|
402
|
+
sudo npx create-mcp-use-app my-app
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
**Network issues:**
|
|
406
|
+
```bash
|
|
407
|
+
# Use a different registry
|
|
408
|
+
npm config set registry https://registry.npmjs.org/
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**Port already in use:**
|
|
412
|
+
```bash
|
|
413
|
+
# Change the port in your .env file
|
|
414
|
+
PORT=3001
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## 🤝 Contributing
|
|
420
|
+
|
|
421
|
+
We welcome contributions! To contribute:
|
|
422
|
+
|
|
423
|
+
1. Fork the repository
|
|
424
|
+
2. Create a feature branch
|
|
425
|
+
3. Make your changes
|
|
426
|
+
4. Submit a pull request
|
|
427
|
+
|
|
428
|
+
See our [contributing guide](https://github.com/mcp-use/mcp-use-ts/blob/main/CONTRIBUTING.md) for more details.
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## 📚 Learn More
|
|
433
|
+
|
|
434
|
+
- [MCP-Use Documentation](https://github.com/mcp-use/mcp-use-ts)
|
|
435
|
+
- [Model Context Protocol Spec](https://modelcontextprotocol.io)
|
|
436
|
+
- [Creating MCP Tools](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/mcp-use#-mcp-server-framework)
|
|
437
|
+
- [Building UI Widgets](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/cli#-creating-ui-widgets)
|
|
438
|
+
- [Using the Inspector](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/inspector)
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## 📜 License
|
|
443
|
+
|
|
444
|
+
MIT © [MCP-Use](https://github.com/mcp-use)
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,70 @@ import { Command } from "commander";
|
|
|
10
10
|
var __filename = fileURLToPath(import.meta.url);
|
|
11
11
|
var __dirname = dirname(__filename);
|
|
12
12
|
var program = new Command();
|
|
13
|
-
|
|
13
|
+
var packageJson = JSON.parse(
|
|
14
|
+
readFileSync(join(__dirname, "../package.json"), "utf-8")
|
|
15
|
+
);
|
|
16
|
+
function getCurrentPackageVersions() {
|
|
17
|
+
const versions = {};
|
|
18
|
+
try {
|
|
19
|
+
const possibleRoots = [
|
|
20
|
+
resolve(__dirname, "../../../.."),
|
|
21
|
+
// From dist/templates
|
|
22
|
+
resolve(__dirname, "../../../../.."),
|
|
23
|
+
// From dist
|
|
24
|
+
resolve(process.cwd(), "."),
|
|
25
|
+
// Current working directory
|
|
26
|
+
resolve(process.cwd(), "..")
|
|
27
|
+
// Parent of current directory
|
|
28
|
+
];
|
|
29
|
+
let workspaceRoot = null;
|
|
30
|
+
for (const root of possibleRoots) {
|
|
31
|
+
if (existsSync(join(root, "packages/mcp-use/package.json"))) {
|
|
32
|
+
workspaceRoot = root;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!workspaceRoot) {
|
|
37
|
+
throw new Error("Workspace root not found");
|
|
38
|
+
}
|
|
39
|
+
const mcpUsePackage = JSON.parse(
|
|
40
|
+
readFileSync(join(workspaceRoot, "packages/mcp-use/package.json"), "utf-8")
|
|
41
|
+
);
|
|
42
|
+
versions["mcp-use"] = mcpUsePackage.version;
|
|
43
|
+
const cliPackage = JSON.parse(
|
|
44
|
+
readFileSync(join(workspaceRoot, "packages/cli/package.json"), "utf-8")
|
|
45
|
+
);
|
|
46
|
+
versions["@mcp-use/cli"] = cliPackage.version;
|
|
47
|
+
const inspectorPackage = JSON.parse(
|
|
48
|
+
readFileSync(join(workspaceRoot, "packages/inspector/package.json"), "utf-8")
|
|
49
|
+
);
|
|
50
|
+
versions["@mcp-use/inspector"] = inspectorPackage.version;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.warn("\u26A0\uFE0F Could not read workspace package versions, using defaults");
|
|
53
|
+
console.warn(` Error: ${error}`);
|
|
54
|
+
}
|
|
55
|
+
return versions;
|
|
56
|
+
}
|
|
57
|
+
function processTemplateFile(filePath, versions, isDevelopment = false) {
|
|
58
|
+
const content = readFileSync(filePath, "utf-8");
|
|
59
|
+
let processedContent = content;
|
|
60
|
+
for (const [packageName, version] of Object.entries(versions)) {
|
|
61
|
+
const placeholder = `{{${packageName}_version}}`;
|
|
62
|
+
const versionPrefix = isDevelopment ? "workspace:*" : `^${version}`;
|
|
63
|
+
processedContent = processedContent.replace(new RegExp(placeholder, "g"), versionPrefix);
|
|
64
|
+
}
|
|
65
|
+
if (isDevelopment) {
|
|
66
|
+
processedContent = processedContent.replace(/"mcp-use": "\^[^"]+"/, '"mcp-use": "workspace:*"');
|
|
67
|
+
processedContent = processedContent.replace(/"@mcp-use\/cli": "\^[^"]+"/, '"@mcp-use/cli": "workspace:*"');
|
|
68
|
+
processedContent = processedContent.replace(/"@mcp-use\/inspector": "\^[^"]+"/, '"@mcp-use/inspector": "workspace:*"');
|
|
69
|
+
} else {
|
|
70
|
+
processedContent = processedContent.replace(/"mcp-use": "workspace:\*"/, `"mcp-use": "^${versions["mcp-use"] || "1.0.0"}"`);
|
|
71
|
+
processedContent = processedContent.replace(/"@mcp-use\/cli": "workspace:\*"/, `"@mcp-use/cli": "^${versions["@mcp-use/cli"] || "2.0.0"}"`);
|
|
72
|
+
processedContent = processedContent.replace(/"@mcp-use\/inspector": "workspace:\*"/, `"@mcp-use/inspector": "^${versions["@mcp-use/inspector"] || "0.3.0"}"`);
|
|
73
|
+
}
|
|
74
|
+
return processedContent;
|
|
75
|
+
}
|
|
76
|
+
program.name("create-mcp-use-app").description("Create a new MCP server project").version(packageJson.version).argument("[project-name]", "Name of the MCP server project").option("-t, --template <template>", "Template to use", "ui").option("--no-install", "Skip installing dependencies").option("--dev", "Use workspace dependencies for development").action(async (projectName, options) => {
|
|
14
77
|
try {
|
|
15
78
|
if (!projectName) {
|
|
16
79
|
console.log("\u{1F3AF} Welcome to create-mcp-use-app!");
|
|
@@ -29,7 +92,8 @@ program.name("create-mcp-use-app").description("Create a new MCP server project"
|
|
|
29
92
|
process.exit(1);
|
|
30
93
|
}
|
|
31
94
|
mkdirSync(projectPath, { recursive: true });
|
|
32
|
-
|
|
95
|
+
const versions = getCurrentPackageVersions();
|
|
96
|
+
await copyTemplate(projectPath, options.template, versions, options.dev);
|
|
33
97
|
updatePackageJson(projectPath, projectName);
|
|
34
98
|
if (options.install) {
|
|
35
99
|
console.log("\u{1F4E6} Installing dependencies...");
|
|
@@ -45,6 +109,9 @@ program.name("create-mcp-use-app").description("Create a new MCP server project"
|
|
|
45
109
|
}
|
|
46
110
|
}
|
|
47
111
|
console.log("\u2705 MCP server created successfully!");
|
|
112
|
+
if (options.dev) {
|
|
113
|
+
console.log("\u{1F527} Development mode: Using workspace dependencies");
|
|
114
|
+
}
|
|
48
115
|
console.log("");
|
|
49
116
|
console.log("\u{1F4C1} Project structure:");
|
|
50
117
|
console.log(` ${projectName}/`);
|
|
@@ -55,6 +122,7 @@ program.name("create-mcp-use-app").description("Create a new MCP server project"
|
|
|
55
122
|
console.log(" \u2502 \u251C\u2500\u2500 data-visualization.tsx");
|
|
56
123
|
console.log(" \u2502 \u251C\u2500\u2500 kanban-board.tsx");
|
|
57
124
|
console.log(" \u2502 \u2514\u2500\u2500 todo-list.tsx");
|
|
125
|
+
console.log(" \u251C\u2500\u2500 index.ts");
|
|
58
126
|
console.log(" \u251C\u2500\u2500 package.json");
|
|
59
127
|
console.log(" \u251C\u2500\u2500 tsconfig.json");
|
|
60
128
|
console.log(" \u2514\u2500\u2500 README.md");
|
|
@@ -73,13 +141,17 @@ program.name("create-mcp-use-app").description("Create a new MCP server project"
|
|
|
73
141
|
}
|
|
74
142
|
console.log(" npm run dev");
|
|
75
143
|
console.log("");
|
|
144
|
+
if (options.dev) {
|
|
145
|
+
console.log("\u{1F4A1} Development mode: Your project uses workspace dependencies");
|
|
146
|
+
console.log(" Make sure you're in the mcp-use workspace root for development");
|
|
147
|
+
}
|
|
76
148
|
console.log("\u{1F4DA} Learn more: https://docs.mcp-use.io");
|
|
77
149
|
} catch (error) {
|
|
78
150
|
console.error("\u274C Error creating MCP server:", error);
|
|
79
151
|
process.exit(1);
|
|
80
152
|
}
|
|
81
153
|
});
|
|
82
|
-
async function copyTemplate(projectPath, template) {
|
|
154
|
+
async function copyTemplate(projectPath, template, versions, isDevelopment = false) {
|
|
83
155
|
const templatePath = join(__dirname, "templates", template);
|
|
84
156
|
if (!existsSync(templatePath)) {
|
|
85
157
|
console.error(`\u274C Template "${template}" not found!`);
|
|
@@ -87,27 +159,32 @@ async function copyTemplate(projectPath, template) {
|
|
|
87
159
|
console.log('\u{1F4A1} Tip: Use "ui" template for React components and modern UI features');
|
|
88
160
|
process.exit(1);
|
|
89
161
|
}
|
|
90
|
-
|
|
162
|
+
copyDirectoryWithProcessing(templatePath, projectPath, versions, isDevelopment);
|
|
91
163
|
}
|
|
92
|
-
function
|
|
164
|
+
function copyDirectoryWithProcessing(src, dest, versions, isDevelopment) {
|
|
93
165
|
const entries = readdirSync(src, { withFileTypes: true });
|
|
94
166
|
for (const entry of entries) {
|
|
95
167
|
const srcPath = join(src, entry.name);
|
|
96
168
|
const destPath = join(dest, entry.name);
|
|
97
169
|
if (entry.isDirectory()) {
|
|
98
170
|
mkdirSync(destPath, { recursive: true });
|
|
99
|
-
|
|
171
|
+
copyDirectoryWithProcessing(srcPath, destPath, versions, isDevelopment);
|
|
100
172
|
} else {
|
|
101
|
-
|
|
173
|
+
if (entry.name === "package.json" || entry.name.endsWith(".json")) {
|
|
174
|
+
const processedContent = processTemplateFile(srcPath, versions, isDevelopment);
|
|
175
|
+
writeFileSync(destPath, processedContent);
|
|
176
|
+
} else {
|
|
177
|
+
copyFileSync(srcPath, destPath);
|
|
178
|
+
}
|
|
102
179
|
}
|
|
103
180
|
}
|
|
104
181
|
}
|
|
105
182
|
function updatePackageJson(projectPath, projectName) {
|
|
106
183
|
const packageJsonPath = join(projectPath, "package.json");
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
writeFileSync(packageJsonPath, JSON.stringify(
|
|
184
|
+
const packageJsonContent = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
185
|
+
packageJsonContent.name = projectName;
|
|
186
|
+
packageJsonContent.description = `MCP server: ${projectName}`;
|
|
187
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2));
|
|
111
188
|
}
|
|
112
189
|
function promptForProjectName() {
|
|
113
190
|
return new Promise((resolvePromise) => {
|
|
@@ -234,29 +234,29 @@ if (container) {
|
|
|
234
234
|
npm run build
|
|
235
235
|
|
|
236
236
|
# The built files will be in dist/
|
|
237
|
-
# - dist/
|
|
238
|
-
# - dist/
|
|
237
|
+
# - dist/index.js (MCP server entry point)
|
|
238
|
+
# - dist/src/server.js (MCP server implementation)
|
|
239
|
+
# - dist/resources/ (Compiled TypeScript + UI widget bundles)
|
|
239
240
|
```
|
|
240
241
|
|
|
241
242
|
## Project Structure
|
|
242
243
|
|
|
243
244
|
```
|
|
244
245
|
my-ui-server/
|
|
246
|
+
├── index.ts # Entry point (re-exports server)
|
|
245
247
|
├── src/
|
|
246
248
|
│ └── server.ts # MCP server with UI endpoints
|
|
247
|
-
├── resources/ # React components
|
|
248
|
-
│ ├── kanban-board.html
|
|
249
|
+
├── resources/ # React components (TSX widgets)
|
|
249
250
|
│ ├── kanban-board.tsx
|
|
250
|
-
│ ├── todo-list.html
|
|
251
251
|
│ ├── todo-list.tsx
|
|
252
|
-
│ ├── data-visualization.html
|
|
253
252
|
│ └── data-visualization.tsx
|
|
254
253
|
├── dist/ # Built files
|
|
255
|
-
│ ├──
|
|
256
|
-
│
|
|
254
|
+
│ ├── index.js # Entry point
|
|
255
|
+
│ ├── src/
|
|
256
|
+
│ │ └── server.js # Server implementation
|
|
257
|
+
│ └── resources/ # TypeScript output + bundled widgets
|
|
257
258
|
├── package.json
|
|
258
259
|
├── tsconfig.json
|
|
259
|
-
├── vite.config.ts
|
|
260
260
|
└── README.md
|
|
261
261
|
```
|
|
262
262
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Entry Point
|
|
3
|
+
*
|
|
4
|
+
* This file serves as the main entry point for the MCP server application.
|
|
5
|
+
* It re-exports all functionality from the server implementation, allowing
|
|
6
|
+
* the CLI and other tools to locate and start the server.
|
|
7
|
+
*
|
|
8
|
+
* The server is automatically started when this module is imported, making
|
|
9
|
+
* it suitable for both direct execution and programmatic usage.
|
|
10
|
+
*/
|
|
11
|
+
export * from './src/server.js'
|
|
12
|
+
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "mcp-use-server-with-mcp-ui",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
-
"description": "MCP server:
|
|
5
|
+
"description": "MCP server: mcp-use-server-with-mcp-ui",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"keywords": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"ai",
|
|
15
15
|
"tools"
|
|
16
16
|
],
|
|
17
|
-
"main": "dist/
|
|
17
|
+
"main": "dist/index.js",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "mcp-use build",
|
|
20
20
|
"dev": "mcp-use dev",
|
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
"@mcp-ui/server": "^5.11.0",
|
|
25
25
|
"cors": "^2.8.5",
|
|
26
26
|
"express": "^4.18.0",
|
|
27
|
-
"mcp-use": "
|
|
27
|
+
"mcp-use": "workspace:*"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@mcp-use/cli": "
|
|
30
|
+
"@mcp-use/cli": "workspace:*",
|
|
31
|
+
"@mcp-use/inspector": "workspace:*",
|
|
31
32
|
"@types/cors": "^2.8.0",
|
|
32
33
|
"@types/express": "^4.17.0",
|
|
33
34
|
"@types/node": "^20.0.0",
|
|
@@ -16,7 +16,7 @@ interface KanbanBoardProps {
|
|
|
16
16
|
|
|
17
17
|
const KanbanBoard: React.FC<KanbanBoardProps> = ({ initialTasks = [] }) => {
|
|
18
18
|
const [tasks, setTasks] = useState<Task[]>(initialTasks)
|
|
19
|
-
const [newTask, setNewTask] = useState({ title: '', description: '', priority: 'medium' as
|
|
19
|
+
const [newTask, setNewTask] = useState({ title: '', description: '', priority: 'medium' as Task['priority'] })
|
|
20
20
|
|
|
21
21
|
// Load tasks from URL parameters or use defaults
|
|
22
22
|
useEffect(() => {
|