@leanmcp/cli 0.5.5 → 0.5.6
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 +477 -368
- package/dist/index.js +120 -22
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,368 +1,477 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<a href="https://www.npmjs.com/package/@leanmcp/cli">
|
|
16
|
-
<img src="https://img.shields.io/npm/
|
|
17
|
-
</a>
|
|
18
|
-
<a href="https://
|
|
19
|
-
<img src="https://img.shields.io/
|
|
20
|
-
</a>
|
|
21
|
-
<a href="https://
|
|
22
|
-
<img src="https://
|
|
23
|
-
</a>
|
|
24
|
-
<a href="https://
|
|
25
|
-
<img src="https://img.shields.io/badge
|
|
26
|
-
</a>
|
|
27
|
-
<a href="https://
|
|
28
|
-
<img src="https://img.shields.io/badge
|
|
29
|
-
</a>
|
|
30
|
-
<a href="https://leanmcp.com/">
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
leanmcp
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
leanmcp
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
leanmcp
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
leanmcp
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
leanmcp
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
- [
|
|
363
|
-
- [
|
|
364
|
-
- [
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
1
|
+
# @leanmcp/cli
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img
|
|
5
|
+
src="https://raw.githubusercontent.com/LeanMCP/leanmcp-sdk/refs/heads/main/assets/logo.png"
|
|
6
|
+
alt="LeanMCP Logo"
|
|
7
|
+
width="400"
|
|
8
|
+
/>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@leanmcp/cli">
|
|
13
|
+
<img src="https://img.shields.io/npm/v/@leanmcp/cli" alt="npm version" />
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@leanmcp/cli">
|
|
16
|
+
<img src="https://img.shields.io/npm/dm/@leanmcp/cli" alt="npm downloads" />
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://docs.leanmcp.com/sdk/cli">
|
|
19
|
+
<img src="https://img.shields.io/badge/Docs-leanmcp-0A66C2?" />
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://discord.com/invite/DsRcA3GwPy">
|
|
22
|
+
<img src="https://dcbadge.limes.pink/api/server/DsRcA3GwPy?style=flat" alt="Discord" />
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://x.com/LeanMcp">
|
|
25
|
+
<img src="https://img.shields.io/badge/@LeanMCP-f5f5f5?logo=x&logoColor=000000" />
|
|
26
|
+
</a>
|
|
27
|
+
<a href="https://leanmcp.com/">
|
|
28
|
+
<img src="https://img.shields.io/badge/Website-leanmcp-0A66C2?" />
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://deepwiki.com/LeanMCP/leanmcp-sdk"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"package": "@leanmcp/cli",
|
|
36
|
+
"purpose": "Command-line interface for scaffolding LeanMCP projects",
|
|
37
|
+
"useCases": [
|
|
38
|
+
"Project scaffolding",
|
|
39
|
+
"Local development with hot-reload",
|
|
40
|
+
"Cloud deployment",
|
|
41
|
+
"Project management"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": ["@inquirer/prompts", "commander", "chalk", "vite", "archiver", "fs-extra"],
|
|
44
|
+
"bin": {
|
|
45
|
+
"leanmcp": "bin/leanmcp.js"
|
|
46
|
+
},
|
|
47
|
+
"main": "dist/index.js",
|
|
48
|
+
"exports": {
|
|
49
|
+
".": {
|
|
50
|
+
"types": "./dist/index.d.ts",
|
|
51
|
+
"import": "./dist/index.js"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Overview
|
|
58
|
+
|
|
59
|
+
- **What it is**: Command-line interface for scaffolding LeanMCP projects with hot-reload development and cloud deployment
|
|
60
|
+
- **Purpose**: Streamlines the entire MCP server development workflow from project creation to production deployment
|
|
61
|
+
- **Key benefits**:
|
|
62
|
+
- Quick project scaffolding with production-ready templates
|
|
63
|
+
- Hot-reload development server with UI component building
|
|
64
|
+
- One-command cloud deployment to LeanMCP platform
|
|
65
|
+
- Interactive setup with guided prompts
|
|
66
|
+
- Project management and monitoring tools
|
|
67
|
+
|
|
68
|
+
## When to Use It
|
|
69
|
+
|
|
70
|
+
**Use `@leanmcp/cli` when:**
|
|
71
|
+
|
|
72
|
+
- Starting any new MCP server project (highly recommended)
|
|
73
|
+
- Need local development with hot-reload and UI building
|
|
74
|
+
- Want to deploy to LeanMCP Cloud with custom subdomains
|
|
75
|
+
- Managing multiple MCP projects
|
|
76
|
+
- Need guided setup for dependencies and configuration
|
|
77
|
+
|
|
78
|
+
**You probably do NOT need this if:**
|
|
79
|
+
|
|
80
|
+
- Using custom build systems or deployment pipelines
|
|
81
|
+
- Only working with existing projects without scaffolding needs
|
|
82
|
+
- Building MCP clients (not servers)
|
|
83
|
+
- Working in environments where global CLI tools aren't allowed
|
|
84
|
+
|
|
85
|
+
## Features
|
|
86
|
+
|
|
87
|
+
- **Quick Scaffolding** — Create production-ready MCP servers in seconds
|
|
88
|
+
- **Hot Reload Development** — `leanmcp dev` with UI component hot-reload
|
|
89
|
+
- **Cloud Deployment** — Deploy to LeanMCP Cloud with custom subdomains
|
|
90
|
+
- **Project Management** — List, view, and delete cloud projects
|
|
91
|
+
- **Interactive Setup** — Guided prompts for dependencies and dev server
|
|
92
|
+
|
|
93
|
+
## Installation
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm install -g @leanmcp/cli
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Or run without installing:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx @leanmcp/cli create my-mcp-server
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Requirements:**
|
|
106
|
+
|
|
107
|
+
- Node.js >= 18.0.0
|
|
108
|
+
- npm >= 9.0.0
|
|
109
|
+
|
|
110
|
+
## Usage / Examples
|
|
111
|
+
|
|
112
|
+
### Commands Overview
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Local development
|
|
116
|
+
leanmcp create <name> # Create a new project
|
|
117
|
+
leanmcp add <service> # Add a service to existing project
|
|
118
|
+
leanmcp dev # Start development server with hot-reload
|
|
119
|
+
leanmcp build # Build for production
|
|
120
|
+
leanmcp start # Start production server
|
|
121
|
+
|
|
122
|
+
# Cloud commands
|
|
123
|
+
leanmcp login # Authenticate with LeanMCP Cloud
|
|
124
|
+
leanmcp logout # Remove API key
|
|
125
|
+
leanmcp whoami # Show login status
|
|
126
|
+
leanmcp deploy <folder> # Deploy to LeanMCP Cloud
|
|
127
|
+
leanmcp projects list # List your cloud projects
|
|
128
|
+
leanmcp projects get <id> # Get project details
|
|
129
|
+
leanmcp projects delete <id> # Delete a project
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Local Development
|
|
135
|
+
|
|
136
|
+
### create
|
|
137
|
+
|
|
138
|
+
Create a new MCP server project:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
leanmcp create my-sentiment-tool
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Interactive prompts will guide you through:
|
|
145
|
+
|
|
146
|
+
1. Creating the project structure
|
|
147
|
+
2. Installing dependencies (optional)
|
|
148
|
+
3. Starting the dev server (optional)
|
|
149
|
+
|
|
150
|
+
**Generated structure:**
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
my-mcp-server/
|
|
154
|
+
├── main.ts # Entry point with HTTP server
|
|
155
|
+
├── package.json # Dependencies and scripts
|
|
156
|
+
├── tsconfig.json # TypeScript configuration
|
|
157
|
+
└── mcp/ # Services directory
|
|
158
|
+
└── example/
|
|
159
|
+
└── index.ts # Example service with tools
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### add
|
|
163
|
+
|
|
164
|
+
Add a new service to an existing project:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
cd my-mcp-server
|
|
168
|
+
leanmcp add weather
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
This:
|
|
172
|
+
|
|
173
|
+
- Creates `mcp/weather/index.ts` with example Tool, Prompt, and Resource
|
|
174
|
+
- Automatically registers the service in `main.ts`
|
|
175
|
+
- Includes `@SchemaConstraint` validation examples
|
|
176
|
+
|
|
177
|
+
### dev
|
|
178
|
+
|
|
179
|
+
Start the development server with hot-reload:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
leanmcp dev
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
This command:
|
|
186
|
+
|
|
187
|
+
- Scans for `@UIApp` components and builds them
|
|
188
|
+
- Starts the HTTP server with `tsx watch`
|
|
189
|
+
- Watches `mcp/` directory for changes
|
|
190
|
+
- Automatically rebuilds UI components when modified
|
|
191
|
+
- Hot-reloads when adding/removing `@UIApp` decorators
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
$ leanmcp dev
|
|
195
|
+
|
|
196
|
+
LeanMCP Development Server
|
|
197
|
+
|
|
198
|
+
ℹ Found 2 @UIApp component(s)
|
|
199
|
+
ℹ UI components built
|
|
200
|
+
|
|
201
|
+
Starting development server...
|
|
202
|
+
|
|
203
|
+
[HTTP][INFO] Server running on http://localhost:3001
|
|
204
|
+
[HTTP][INFO] MCP endpoint: http://localhost:3001/mcp
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### build
|
|
208
|
+
|
|
209
|
+
Build the project for production:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
leanmcp build
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Compiles TypeScript and bundles UI components.
|
|
216
|
+
|
|
217
|
+
### start
|
|
218
|
+
|
|
219
|
+
Start the production server:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
leanmcp start
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Runs the compiled production build.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Cloud Commands
|
|
230
|
+
|
|
231
|
+
### login
|
|
232
|
+
|
|
233
|
+
Authenticate with LeanMCP Cloud:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
leanmcp login
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Steps:
|
|
240
|
+
|
|
241
|
+
1. Go to [ship.leanmcp.com/api-keys](https://ship.leanmcp.com/api-keys)
|
|
242
|
+
2. Create an API key with "BUILD_AND_DEPLOY" scope
|
|
243
|
+
3. Enter the key when prompted
|
|
244
|
+
|
|
245
|
+
### logout
|
|
246
|
+
|
|
247
|
+
Remove your API key:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
leanmcp logout
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### whoami
|
|
254
|
+
|
|
255
|
+
Check your current login status:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
leanmcp whoami
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### deploy
|
|
262
|
+
|
|
263
|
+
Deploy your MCP server to LeanMCP Cloud:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
leanmcp deploy .
|
|
267
|
+
# Or specify a folder
|
|
268
|
+
leanmcp deploy ./my-project
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Deployment process:
|
|
272
|
+
|
|
273
|
+
1. Creates project (or updates existing)
|
|
274
|
+
2. Packages and uploads code
|
|
275
|
+
3. Builds container image
|
|
276
|
+
4. Deploys to serverless Lambda
|
|
277
|
+
5. Configures custom subdomain
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
$ leanmcp deploy .
|
|
281
|
+
|
|
282
|
+
LeanMCP Deploy
|
|
283
|
+
|
|
284
|
+
Generated project name: swift-coral-sunset
|
|
285
|
+
Path: /path/to/my-project
|
|
286
|
+
|
|
287
|
+
? Subdomain for your deployment: my-api
|
|
288
|
+
✔ Subdomain 'my-api' is available
|
|
289
|
+
|
|
290
|
+
? Proceed with deployment? Yes
|
|
291
|
+
|
|
292
|
+
✔ Project created: 7f4a3b2c...
|
|
293
|
+
✔ Project uploaded
|
|
294
|
+
✔ Build complete (45s)
|
|
295
|
+
✔ Deployed
|
|
296
|
+
✔ Subdomain configured
|
|
297
|
+
|
|
298
|
+
============================================================
|
|
299
|
+
DEPLOYMENT SUCCESSFUL!
|
|
300
|
+
============================================================
|
|
301
|
+
|
|
302
|
+
Your MCP server is now live:
|
|
303
|
+
|
|
304
|
+
URL: https://my-api.leanmcp.dev
|
|
305
|
+
|
|
306
|
+
Test endpoints:
|
|
307
|
+
curl https://my-api.leanmcp.dev/health
|
|
308
|
+
curl https://my-api.leanmcp.dev/mcp
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### projects
|
|
312
|
+
|
|
313
|
+
Manage your cloud projects:
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# List all projects
|
|
317
|
+
leanmcp projects list
|
|
318
|
+
|
|
319
|
+
# Get project details
|
|
320
|
+
leanmcp projects get <project-id>
|
|
321
|
+
|
|
322
|
+
# Delete a project
|
|
323
|
+
leanmcp projects delete <project-id>
|
|
324
|
+
leanmcp projects delete <project-id> --force # Skip confirmation
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## API Reference
|
|
330
|
+
|
|
331
|
+
### Command Reference
|
|
332
|
+
|
|
333
|
+
| Command | Description | Usage |
|
|
334
|
+
| ---------------------- | ---------------------------------------- | ------------------------------ |
|
|
335
|
+
| `create <name>` | Create new MCP server project | `leanmcp create my-server` |
|
|
336
|
+
| `add <service>` | Add service to existing project | `leanmcp add weather` |
|
|
337
|
+
| `dev` | Start development server with hot-reload | `leanmcp dev` |
|
|
338
|
+
| `build` | Build for production | `leanmcp build` |
|
|
339
|
+
| `start` | Start production server | `leanmcp start` |
|
|
340
|
+
| `login` | Authenticate with LeanMCP Cloud | `leanmcp login` |
|
|
341
|
+
| `logout` | Remove API key | `leanmcp logout` |
|
|
342
|
+
| `whoami` | Show login status | `leanmcp whoami` |
|
|
343
|
+
| `deploy [folder]` | Deploy to LeanMCP Cloud | `leanmcp deploy .` |
|
|
344
|
+
| `projects list` | List cloud projects | `leanmcp projects list` |
|
|
345
|
+
| `projects get <id>` | Get project details | `leanmcp projects get <id>` |
|
|
346
|
+
| `projects delete <id>` | Delete project | `leanmcp projects delete <id>` |
|
|
347
|
+
| `env list [folder]` | List environment variables | `leanmcp env list` |
|
|
348
|
+
| `env set <keyValue>` | Set environment variable | `leanmcp env set KEY=VALUE` |
|
|
349
|
+
| `env get <key>` | Get environment variable value | `leanmcp env get KEY` |
|
|
350
|
+
| `env remove <key>` | Remove environment variable | `leanmcp env remove KEY` |
|
|
351
|
+
| `env pull [folder]` | Download env vars to local file | `leanmcp env pull` |
|
|
352
|
+
| `env push [folder]` | Upload env vars from local file | `leanmcp env push` |
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Integration with Other LeanMCP Packages
|
|
357
|
+
|
|
358
|
+
**@leanmcp/cli** works seamlessly with all LeanMCP packages:
|
|
359
|
+
|
|
360
|
+
- **[@leanmcp/core](https://www.npmjs.com/package/@leanmcp/core)** — Generated projects use `@leanmcp/core` as the foundation
|
|
361
|
+
- **[@leanmcp/auth](https://www.npmjs.com/package/@leanmcp/auth)** — CLI can scaffold projects with authentication setup
|
|
362
|
+
- **[@leanmcp/ui](https://www.npmjs.com/package/@leanmcp/ui)** — `leanmcp dev` automatically builds UI components with hot-reload
|
|
363
|
+
- **[@leanmcp/elicitation](https://www.npmjs.com/package/@leanmcp/elicitation)** — Generated services include elicitation examples
|
|
364
|
+
- **[@leanmcp/env-injection](https://www.npmjs.com/package/@leanmcp/env-injection)** — Deploy command handles user secrets configuration
|
|
365
|
+
|
|
366
|
+
**Generated project structure:**
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
my-mcp-server/
|
|
370
|
+
├── main.ts # Entry point with HTTP server
|
|
371
|
+
├── package.json # Dependencies and scripts
|
|
372
|
+
├── tsconfig.json # TypeScript configuration
|
|
373
|
+
└── mcp/ # Services directory (auto-discovered)
|
|
374
|
+
└── example/
|
|
375
|
+
└── index.ts # Example service with @Tool, @Prompt, @Resource
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Best Practices / Troubleshooting
|
|
381
|
+
|
|
382
|
+
### NPM Scripts
|
|
383
|
+
|
|
384
|
+
Generated projects include:
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
npm run dev # Start with hot reload (tsx watch)
|
|
388
|
+
npm run build # Build for production
|
|
389
|
+
npm run start # Run production build
|
|
390
|
+
npm run clean # Remove build artifacts
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## Configuration
|
|
394
|
+
|
|
395
|
+
### Port
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
PORT=4000 npm run dev
|
|
399
|
+
# Or in .env file
|
|
400
|
+
PORT=4000
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### LeanMCP Config
|
|
404
|
+
|
|
405
|
+
Stored in `~/.leanmcp/config.json`:
|
|
406
|
+
|
|
407
|
+
```json
|
|
408
|
+
{
|
|
409
|
+
"apiKey": "airtrain_...",
|
|
410
|
+
"apiUrl": "https://api.leanmcp.com",
|
|
411
|
+
"lastUpdated": "2024-01-15T10:30:00.000Z"
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
## Troubleshooting
|
|
416
|
+
|
|
417
|
+
### Port Already in Use
|
|
418
|
+
|
|
419
|
+
Change the port in `.env`:
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
PORT=3002
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### Module Not Found Errors
|
|
426
|
+
|
|
427
|
+
Ensure dependencies are installed:
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
npm install
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### TypeScript Decorator Errors
|
|
434
|
+
|
|
435
|
+
Ensure your `tsconfig.json` has:
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
{
|
|
439
|
+
"compilerOptions": {
|
|
440
|
+
"experimentalDecorators": true,
|
|
441
|
+
"emitDecoratorMetadata": true
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Deploy: Not Logged In
|
|
447
|
+
|
|
448
|
+
Run `leanmcp login` first to authenticate with your API key.
|
|
449
|
+
|
|
450
|
+
### Deploy: Subdomain Taken
|
|
451
|
+
|
|
452
|
+
Choose a different subdomain when prompted.
|
|
453
|
+
|
|
454
|
+
## Requirements
|
|
455
|
+
|
|
456
|
+
- Node.js >= 18.0.0
|
|
457
|
+
- npm >= 9.0.0
|
|
458
|
+
|
|
459
|
+
## Documentation
|
|
460
|
+
|
|
461
|
+
- [Full Documentation](https://docs.leanmcp.com/sdk/cli)
|
|
462
|
+
|
|
463
|
+
## Related Packages
|
|
464
|
+
|
|
465
|
+
- [@leanmcp/core](https://www.npmjs.com/package/@leanmcp/core) — Core MCP server functionality
|
|
466
|
+
- [@leanmcp/auth](https://www.npmjs.com/package/@leanmcp/auth) — Authentication decorators
|
|
467
|
+
- [@leanmcp/ui](https://www.npmjs.com/package/@leanmcp/ui) — MCP App UI components
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## Links
|
|
472
|
+
|
|
473
|
+
- **Documentation**: [https://docs.leanmcp.com/sdk/cli](https://docs.leanmcp.com/sdk/cli)
|
|
474
|
+
- **GitHub**: [https://github.com/LeanMCP/leanmcp-sdk/tree/main/packages/cli](https://github.com/LeanMCP/leanmcp-sdk/tree/main/packages/cli)
|
|
475
|
+
- **npm**: [https://www.npmjs.com/package/@leanmcp/cli](https://www.npmjs.com/package/@leanmcp/cli)
|
|
476
|
+
- **LeanMCP Dashboard**: [https://ship.leanmcp.com](https://ship.leanmcp.com)
|
|
477
|
+
- **License**: MIT
|
package/dist/index.js
CHANGED
|
@@ -1786,6 +1786,42 @@ async function debugFetch(url, options = {}) {
|
|
|
1786
1786
|
return response;
|
|
1787
1787
|
}
|
|
1788
1788
|
__name(debugFetch, "debugFetch");
|
|
1789
|
+
async function fetchWithRetry(fetchFn, options = {}) {
|
|
1790
|
+
const maxRetries = options.maxRetries ?? 15;
|
|
1791
|
+
const initialDelay = options.initialDelay ?? 1e3;
|
|
1792
|
+
const maxDelay = options.maxDelay ?? 1e4;
|
|
1793
|
+
const operation = options.operation ?? "Fetch";
|
|
1794
|
+
const spinner = options.spinner;
|
|
1795
|
+
const retryOnHttpErrors = options.retryOnHttpErrors ?? false;
|
|
1796
|
+
let lastError = null;
|
|
1797
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
1798
|
+
try {
|
|
1799
|
+
const response = await fetchFn();
|
|
1800
|
+
if (retryOnHttpErrors && !response.ok && response.status >= 500) {
|
|
1801
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
1802
|
+
}
|
|
1803
|
+
return response;
|
|
1804
|
+
} catch (error) {
|
|
1805
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
1806
|
+
if (attempt < maxRetries) {
|
|
1807
|
+
const delay = Math.min(initialDelay * Math.pow(2, attempt), maxDelay);
|
|
1808
|
+
const message = `${operation} failed. Retrying... (${attempt + 1}/${maxRetries})`;
|
|
1809
|
+
if (spinner) {
|
|
1810
|
+
spinner.text = message;
|
|
1811
|
+
} else {
|
|
1812
|
+
process.stdout.write("\r" + chalk.yellow(message));
|
|
1813
|
+
}
|
|
1814
|
+
debug3(`Retry ${attempt + 1}/${maxRetries}: ${lastError.message}, waiting ${delay}ms`);
|
|
1815
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
if (!spinner) {
|
|
1820
|
+
process.stdout.write("\x1B[2K\r");
|
|
1821
|
+
}
|
|
1822
|
+
throw new Error(`${operation} failed after ${maxRetries + 1} attempts (1 initial + ${maxRetries} retries): ${lastError?.message || "Unknown error"}`);
|
|
1823
|
+
}
|
|
1824
|
+
__name(fetchWithRetry, "fetchWithRetry");
|
|
1789
1825
|
var API_ENDPOINTS = {
|
|
1790
1826
|
// Projects
|
|
1791
1827
|
projects: "/api/projects",
|
|
@@ -1872,10 +1908,14 @@ async function waitForBuild(apiUrl, apiKey, buildId, spinner) {
|
|
|
1872
1908
|
const maxAttempts = 60;
|
|
1873
1909
|
let attempts = 0;
|
|
1874
1910
|
while (attempts < maxAttempts) {
|
|
1875
|
-
const response = await debugFetch(`${apiUrl}${API_ENDPOINTS.getBuild}/${buildId}`, {
|
|
1911
|
+
const response = await fetchWithRetry(() => debugFetch(`${apiUrl}${API_ENDPOINTS.getBuild}/${buildId}`, {
|
|
1876
1912
|
headers: {
|
|
1877
1913
|
Authorization: `Bearer ${apiKey}`
|
|
1878
1914
|
}
|
|
1915
|
+
}), {
|
|
1916
|
+
operation: "Build status check",
|
|
1917
|
+
spinner,
|
|
1918
|
+
maxRetries: 3
|
|
1879
1919
|
});
|
|
1880
1920
|
if (!response.ok) {
|
|
1881
1921
|
throw new Error(`Failed to get build status: ${response.statusText}`);
|
|
@@ -1901,10 +1941,14 @@ async function waitForDeployment(apiUrl, apiKey, deploymentId, spinner) {
|
|
|
1901
1941
|
const maxAttempts = 60;
|
|
1902
1942
|
let attempts = 0;
|
|
1903
1943
|
while (attempts < maxAttempts) {
|
|
1904
|
-
const response = await debugFetch(`${apiUrl}${API_ENDPOINTS.getDeployment}/${deploymentId}`, {
|
|
1944
|
+
const response = await fetchWithRetry(() => debugFetch(`${apiUrl}${API_ENDPOINTS.getDeployment}/${deploymentId}`, {
|
|
1905
1945
|
headers: {
|
|
1906
1946
|
Authorization: `Bearer ${apiKey}`
|
|
1907
1947
|
}
|
|
1948
|
+
}), {
|
|
1949
|
+
operation: "Deployment status check",
|
|
1950
|
+
spinner,
|
|
1951
|
+
maxRetries: 3
|
|
1908
1952
|
});
|
|
1909
1953
|
if (!response.ok) {
|
|
1910
1954
|
throw new Error(`Failed to get deployment status: ${response.statusText}`);
|
|
@@ -3178,12 +3222,16 @@ vite.config.ts.timestamp-*
|
|
|
3178
3222
|
var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import { Tool, Resource, Prompt, SchemaConstraint, Optional } from "@leanmcp/core";
|
|
3179
3223
|
|
|
3180
3224
|
/**
|
|
3181
|
-
*
|
|
3225
|
+
* ${projectName} - Production-ready MCP server example
|
|
3182
3226
|
*
|
|
3183
|
-
* This
|
|
3227
|
+
* This example demonstrates LeanMCP's core features:
|
|
3228
|
+
* - Schema validation with decorators
|
|
3229
|
+
* - Type-safe tool definitions
|
|
3230
|
+
* - Resource and prompt capabilities
|
|
3231
|
+
* - Production-ready structure
|
|
3184
3232
|
*/
|
|
3185
3233
|
|
|
3186
|
-
// Input
|
|
3234
|
+
// Input schemas with validation decorators
|
|
3187
3235
|
class CalculateInput {
|
|
3188
3236
|
@SchemaConstraint({ description: "First number" })
|
|
3189
3237
|
a!: number;
|
|
@@ -3208,13 +3256,13 @@ var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import
|
|
|
3208
3256
|
message!: string;
|
|
3209
3257
|
}
|
|
3210
3258
|
|
|
3211
|
-
export class
|
|
3259
|
+
export class ${projectName}Service {
|
|
3260
|
+
// CALCULATION TOOL - Shows schema validation
|
|
3212
3261
|
@Tool({
|
|
3213
3262
|
description: "Perform arithmetic operations with automatic schema validation",
|
|
3214
3263
|
inputClass: CalculateInput
|
|
3215
3264
|
})
|
|
3216
3265
|
async calculate(input: CalculateInput) {
|
|
3217
|
-
// Ensure numerical operations by explicitly converting to numbers
|
|
3218
3266
|
const a = Number(input.a);
|
|
3219
3267
|
const b = Number(input.b);
|
|
3220
3268
|
let result: number;
|
|
@@ -3243,14 +3291,17 @@ var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import
|
|
|
3243
3291
|
text: JSON.stringify({
|
|
3244
3292
|
operation: input.operation || "add",
|
|
3245
3293
|
operands: { a: input.a, b: input.b },
|
|
3246
|
-
result
|
|
3294
|
+
result,
|
|
3295
|
+
timestamp: new Date().toISOString(),
|
|
3296
|
+
server: "${projectName}"
|
|
3247
3297
|
}, null, 2)
|
|
3248
3298
|
}]
|
|
3249
3299
|
};
|
|
3250
3300
|
}
|
|
3251
3301
|
|
|
3302
|
+
// ECHO TOOL - Shows basic functionality
|
|
3252
3303
|
@Tool({
|
|
3253
|
-
description: "Echo a message back",
|
|
3304
|
+
description: "Echo a message back with timestamp",
|
|
3254
3305
|
inputClass: EchoInput
|
|
3255
3306
|
})
|
|
3256
3307
|
async echo(input: EchoInput) {
|
|
@@ -3259,13 +3310,15 @@ var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import
|
|
|
3259
3310
|
type: "text" as const,
|
|
3260
3311
|
text: JSON.stringify({
|
|
3261
3312
|
echoed: input.message,
|
|
3262
|
-
timestamp: new Date().toISOString()
|
|
3313
|
+
timestamp: new Date().toISOString(),
|
|
3314
|
+
server: "${projectName}"
|
|
3263
3315
|
}, null, 2)
|
|
3264
3316
|
}]
|
|
3265
3317
|
};
|
|
3266
3318
|
}
|
|
3267
3319
|
|
|
3268
|
-
|
|
3320
|
+
// SERVER INFO RESOURCE - Shows resource capabilities
|
|
3321
|
+
@Resource({ description: "Get server information and health status" })
|
|
3269
3322
|
async serverInfo() {
|
|
3270
3323
|
return {
|
|
3271
3324
|
contents: [{
|
|
@@ -3274,25 +3327,45 @@ var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import
|
|
|
3274
3327
|
text: JSON.stringify({
|
|
3275
3328
|
name: "${projectName}",
|
|
3276
3329
|
version: "1.0.0",
|
|
3277
|
-
|
|
3330
|
+
status: "healthy",
|
|
3331
|
+
uptime: Math.floor(process.uptime()),
|
|
3332
|
+
memory: {
|
|
3333
|
+
used: Math.round(process.memoryUsage().heapUsed / 1024 / 1024),
|
|
3334
|
+
total: Math.round(process.memoryUsage().heapTotal / 1024 / 1024)
|
|
3335
|
+
},
|
|
3336
|
+
features: [
|
|
3337
|
+
"Schema validation with decorators",
|
|
3338
|
+
"Type-safe tool definitions",
|
|
3339
|
+
"Resource endpoints",
|
|
3340
|
+
"Prompt templates"
|
|
3341
|
+
],
|
|
3342
|
+
timestamp: new Date().toISOString()
|
|
3278
3343
|
}, null, 2)
|
|
3279
3344
|
}]
|
|
3280
3345
|
};
|
|
3281
3346
|
}
|
|
3282
3347
|
|
|
3283
|
-
|
|
3284
|
-
|
|
3348
|
+
// WELCOME PROMPT - Shows prompt capabilities
|
|
3349
|
+
@Prompt({ description: "Generate a welcome prompt for the server" })
|
|
3350
|
+
async welcome(args: { name?: string }) {
|
|
3285
3351
|
return {
|
|
3286
3352
|
messages: [{
|
|
3287
3353
|
role: "user" as const,
|
|
3288
3354
|
content: {
|
|
3289
3355
|
type: "text" as const,
|
|
3290
|
-
text: \`
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3356
|
+
text: \`Welcome \${args.name || 'there'} to ${projectName}!
|
|
3357
|
+
|
|
3358
|
+
Your MCP server is running with these tools:
|
|
3359
|
+
- calculate: Perform arithmetic operations
|
|
3360
|
+
- echo: Echo messages back
|
|
3361
|
+
- serverInfo: Get server status and information
|
|
3362
|
+
|
|
3363
|
+
Try calling these tools to see LeanMCP in action!\`
|
|
3364
|
+
}
|
|
3365
|
+
}]
|
|
3366
|
+
};
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3296
3369
|
`, "getExampleServiceTemplate");
|
|
3297
3370
|
|
|
3298
3371
|
// src/templates/main_ts_v1.ts
|
|
@@ -3302,6 +3375,14 @@ import { createHTTPServer } from "@leanmcp/core";
|
|
|
3302
3375
|
// Load environment variables
|
|
3303
3376
|
dotenv.config();
|
|
3304
3377
|
|
|
3378
|
+
console.log("Starting ${projectName} MCP Server...");
|
|
3379
|
+
console.log("Features included:");
|
|
3380
|
+
console.log(" Schema validation with decorators");
|
|
3381
|
+
console.log(" Resource endpoints");
|
|
3382
|
+
console.log(" Prompt templates");
|
|
3383
|
+
console.log(" Type-safe tool definitions");
|
|
3384
|
+
console.log("");
|
|
3385
|
+
|
|
3305
3386
|
// Services are automatically discovered from ./mcp directory
|
|
3306
3387
|
await createHTTPServer({
|
|
3307
3388
|
name: "${projectName}",
|
|
@@ -3309,10 +3390,27 @@ await createHTTPServer({
|
|
|
3309
3390
|
port: 3001,
|
|
3310
3391
|
cors: true,
|
|
3311
3392
|
logging: true${dashboardLine}
|
|
3312
|
-
// stateless: false, // Enable stateful mode (uses DynamoDB on Lambda for session persistence)
|
|
3313
3393
|
});
|
|
3314
3394
|
|
|
3315
|
-
console.log("\\n${projectName} MCP Server");
|
|
3395
|
+
console.log("\\n${projectName} MCP Server is running!");
|
|
3396
|
+
console.log("\\nTry these commands to test your server:");
|
|
3397
|
+
console.log("");
|
|
3398
|
+
console.log("# Test calculation tool (schema validation)");
|
|
3399
|
+
console.log('curl -X POST http://localhost:3001/mcp \\\\');
|
|
3400
|
+
console.log(' -H "Content-Type: application/json" \\\\');
|
|
3401
|
+
console.log(' -d '{"method": "tools/call", "params": {"name": "calculate", "arguments": {"a": 10, "b": 5, "operation": "add"}}}'');
|
|
3402
|
+
console.log("");
|
|
3403
|
+
console.log("# Test echo tool");
|
|
3404
|
+
console.log('curl -X POST http://localhost:3001/mcp \\\\');
|
|
3405
|
+
console.log(' -H "Content-Type: application/json" \\\\');
|
|
3406
|
+
console.log(' -d '{"method": "tools/call", "params": {"name": "echo", "arguments": {"message": "Hello LeanMCP!"}}}'');
|
|
3407
|
+
console.log("");
|
|
3408
|
+
console.log("# Get server information (resource)");
|
|
3409
|
+
console.log('curl -X POST http://localhost:3001/mcp \\\\');
|
|
3410
|
+
console.log(' -H "Content-Type: application/json" \\\\');
|
|
3411
|
+
console.log(' -d '{"method": "resources/read", "params": {"uri": "server://info"}}'');
|
|
3412
|
+
console.log("");
|
|
3413
|
+
console.log("Ready to customize - add your own tools, resources, and prompts!");
|
|
3316
3414
|
`, "getMainTsTemplate");
|
|
3317
3415
|
|
|
3318
3416
|
// src/templates/service_index_v1.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leanmcp/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Command-line interface for scaffolding LeanMCP projects",
|
|
5
5
|
"bin": {
|
|
6
6
|
"leanmcp": "bin/leanmcp.js"
|
|
@@ -71,4 +71,4 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
}
|