@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.
Files changed (3) hide show
  1. package/README.md +477 -368
  2. package/dist/index.js +120 -22
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,368 +1,477 @@
1
- <p align="center">
2
- <img
3
- src="https://raw.githubusercontent.com/LeanMCP/leanmcp-sdk/refs/heads/main/assets/logo.png"
4
- alt="LeanMCP Logo"
5
- width="400"
6
- />
7
- </p>
8
-
9
- <p align="center">
10
- <strong>@leanmcp/cli</strong><br/>
11
- Command-line tool for creating, developing, and deploying LeanMCP projects.
12
- </p>
13
-
14
- <p align="center">
15
- <a href="https://www.npmjs.com/package/@leanmcp/cli">
16
- <img src="https://img.shields.io/npm/v/@leanmcp/cli" alt="npm version" />
17
- </a>
18
- <a href="https://www.npmjs.com/package/@leanmcp/cli">
19
- <img src="https://img.shields.io/npm/dm/@leanmcp/cli" alt="npm downloads" />
20
- </a>
21
- <a href="https://docs.leanmcp.com/sdk/cli">
22
- <img src="https://img.shields.io/badge/Docs-leanmcp-0A66C2?" />
23
- </a>
24
- <a href="https://discord.com/invite/DsRcA3GwPy">
25
- <img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" />
26
- </a>
27
- <a href="https://x.com/LeanMcp">
28
- <img src="https://img.shields.io/badge/@LeanMCP-f5f5f5?logo=x&logoColor=000000" />
29
- </a>
30
- <a href="https://leanmcp.com/">
31
- <img src="https://img.shields.io/badge/Website-leanmcp-0A66C2?" />
32
- </a>
33
- <a href="https://deepwiki.com/LeanMCP/leanmcp-sdk"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
34
- </p>
35
-
36
- ## Features
37
-
38
- - **Quick Scaffolding** — Create production-ready MCP servers in seconds
39
- - **Hot Reload Development** — `leanmcp dev` with UI component hot-reload
40
- - **Cloud Deployment** — Deploy to LeanMCP Cloud with custom subdomains
41
- - **Project Management** — List, view, and delete cloud projects
42
- - **Interactive Setup** — Guided prompts for dependencies and dev server
43
-
44
- ## Installation
45
-
46
- ```bash
47
- npm install -g @leanmcp/cli
48
- ```
49
-
50
- Or run without installing:
51
-
52
- ```bash
53
- npx @leanmcp/cli create my-mcp-server
54
- ```
55
-
56
- ## Commands Overview
57
-
58
- ```bash
59
- # Local development
60
- leanmcp create <name> # Create a new project
61
- leanmcp add <service> # Add a service to existing project
62
- leanmcp dev # Start development server with hot-reload
63
- leanmcp build # Build for production
64
- leanmcp start # Start production server
65
-
66
- # Cloud commands
67
- leanmcp login # Authenticate with LeanMCP Cloud
68
- leanmcp logout # Remove API key
69
- leanmcp whoami # Show login status
70
- leanmcp deploy <folder> # Deploy to LeanMCP Cloud
71
- leanmcp projects list # List your cloud projects
72
- leanmcp projects get <id> # Get project details
73
- leanmcp projects delete <id> # Delete a project
74
- ```
75
-
76
- ---
77
-
78
- ## Local Development
79
-
80
- ### create
81
-
82
- Create a new MCP server project:
83
-
84
- ```bash
85
- leanmcp create my-sentiment-tool
86
- ```
87
-
88
- Interactive prompts will guide you through:
89
-
90
- 1. Creating the project structure
91
- 2. Installing dependencies (optional)
92
- 3. Starting the dev server (optional)
93
-
94
- **Generated structure:**
95
-
96
- ```
97
- my-mcp-server/
98
- ├── main.ts # Entry point with HTTP server
99
- ├── package.json # Dependencies and scripts
100
- ├── tsconfig.json # TypeScript configuration
101
- └── mcp/ # Services directory
102
- └── example/
103
- └── index.ts # Example service with tools
104
- ```
105
-
106
- ### add
107
-
108
- Add a new service to an existing project:
109
-
110
- ```bash
111
- cd my-mcp-server
112
- leanmcp add weather
113
- ```
114
-
115
- This:
116
-
117
- - Creates `mcp/weather/index.ts` with example Tool, Prompt, and Resource
118
- - Automatically registers the service in `main.ts`
119
- - Includes `@SchemaConstraint` validation examples
120
-
121
- ### dev
122
-
123
- Start the development server with hot-reload:
124
-
125
- ```bash
126
- leanmcp dev
127
- ```
128
-
129
- This command:
130
-
131
- - Scans for `@UIApp` components and builds them
132
- - Starts the HTTP server with `tsx watch`
133
- - Watches `mcp/` directory for changes
134
- - Automatically rebuilds UI components when modified
135
- - Hot-reloads when adding/removing `@UIApp` decorators
136
-
137
- ```bash
138
- $ leanmcp dev
139
-
140
- LeanMCP Development Server
141
-
142
- ℹ Found 2 @UIApp component(s)
143
- ℹ UI components built
144
-
145
- Starting development server...
146
-
147
- [HTTP][INFO] Server running on http://localhost:3001
148
- [HTTP][INFO] MCP endpoint: http://localhost:3001/mcp
149
- ```
150
-
151
- ### build
152
-
153
- Build the project for production:
154
-
155
- ```bash
156
- leanmcp build
157
- ```
158
-
159
- Compiles TypeScript and bundles UI components.
160
-
161
- ### start
162
-
163
- Start the production server:
164
-
165
- ```bash
166
- leanmcp start
167
- ```
168
-
169
- Runs the compiled production build.
170
-
171
- ---
172
-
173
- ## Cloud Commands
174
-
175
- ### login
176
-
177
- Authenticate with LeanMCP Cloud:
178
-
179
- ```bash
180
- leanmcp login
181
- ```
182
-
183
- Steps:
184
-
185
- 1. Go to [ship.leanmcp.com/api-keys](https://ship.leanmcp.com/api-keys)
186
- 2. Create an API key with "BUILD_AND_DEPLOY" scope
187
- 3. Enter the key when prompted
188
-
189
- ### logout
190
-
191
- Remove your API key:
192
-
193
- ```bash
194
- leanmcp logout
195
- ```
196
-
197
- ### whoami
198
-
199
- Check your current login status:
200
-
201
- ```bash
202
- leanmcp whoami
203
- ```
204
-
205
- ### deploy
206
-
207
- Deploy your MCP server to LeanMCP Cloud:
208
-
209
- ```bash
210
- leanmcp deploy .
211
- # Or specify a folder
212
- leanmcp deploy ./my-project
213
- ```
214
-
215
- Deployment process:
216
-
217
- 1. Creates project (or updates existing)
218
- 2. Packages and uploads code
219
- 3. Builds container image
220
- 4. Deploys to serverless Lambda
221
- 5. Configures custom subdomain
222
-
223
- ```bash
224
- $ leanmcp deploy .
225
-
226
- LeanMCP Deploy
227
-
228
- Generated project name: swift-coral-sunset
229
- Path: /path/to/my-project
230
-
231
- ? Subdomain for your deployment: my-api
232
- ✔ Subdomain 'my-api' is available
233
-
234
- ? Proceed with deployment? Yes
235
-
236
- Project created: 7f4a3b2c...
237
- ✔ Project uploaded
238
- ✔ Build complete (45s)
239
- ✔ Deployed
240
- ✔ Subdomain configured
241
-
242
- ============================================================
243
- DEPLOYMENT SUCCESSFUL!
244
- ============================================================
245
-
246
- Your MCP server is now live:
247
-
248
- URL: https://my-api.leanmcp.dev
249
-
250
- Test endpoints:
251
- curl https://my-api.leanmcp.dev/health
252
- curl https://my-api.leanmcp.dev/mcp
253
- ```
254
-
255
- ### projects
256
-
257
- Manage your cloud projects:
258
-
259
- ```bash
260
- # List all projects
261
- leanmcp projects list
262
-
263
- # Get project details
264
- leanmcp projects get <project-id>
265
-
266
- # Delete a project
267
- leanmcp projects delete <project-id>
268
- leanmcp projects delete <project-id> --force # Skip confirmation
269
- ```
270
-
271
- ---
272
-
273
- ## NPM Scripts
274
-
275
- Generated projects include:
276
-
277
- ```bash
278
- npm run dev # Start with hot reload (tsx watch)
279
- npm run build # Build for production
280
- npm run start # Run production build
281
- npm run clean # Remove build artifacts
282
- ```
283
-
284
- ## Configuration
285
-
286
- ### Port
287
-
288
- ```bash
289
- PORT=4000 npm run dev
290
- # Or in .env file
291
- PORT=4000
292
- ```
293
-
294
- ### LeanMCP Config
295
-
296
- Stored in `~/.leanmcp/config.json`:
297
-
298
- ```json
299
- {
300
- "apiKey": "airtrain_...",
301
- "apiUrl": "https://api.leanmcp.com",
302
- "lastUpdated": "2024-01-15T10:30:00.000Z"
303
- }
304
- ```
305
-
306
- ## Troubleshooting
307
-
308
- ### Port Already in Use
309
-
310
- Change the port in `.env`:
311
-
312
- ```bash
313
- PORT=3002
314
- ```
315
-
316
- ### Module Not Found Errors
317
-
318
- Ensure dependencies are installed:
319
-
320
- ```bash
321
- npm install
322
- ```
323
-
324
- ### TypeScript Decorator Errors
325
-
326
- Ensure your `tsconfig.json` has:
327
-
328
- ```json
329
- {
330
- "compilerOptions": {
331
- "experimentalDecorators": true,
332
- "emitDecoratorMetadata": true
333
- }
334
- }
335
- ```
336
-
337
- ### Deploy: Not Logged In
338
-
339
- Run `leanmcp login` first to authenticate with your API key.
340
-
341
- ### Deploy: Subdomain Taken
342
-
343
- Choose a different subdomain when prompted.
344
-
345
- ## Requirements
346
-
347
- - Node.js >= 18.0.0
348
- - npm >= 9.0.0
349
-
350
- ## Documentation
351
-
352
- - [Full Documentation](https://docs.leanmcp.com/sdk/cli)
353
-
354
- ## Related Packages
355
-
356
- - [@leanmcp/core](https://www.npmjs.com/package/@leanmcp/core) Core MCP server functionality
357
- - [@leanmcp/auth](https://www.npmjs.com/package/@leanmcp/auth) — Authentication decorators
358
- - [@leanmcp/ui](https://www.npmjs.com/package/@leanmcp/ui) MCP App UI components
359
-
360
- ## Links
361
-
362
- - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
363
- - [NPM Package](https://www.npmjs.com/package/@leanmcp/cli)
364
- - [LeanMCP Dashboard](https://ship.leanmcp.com)
365
-
366
- ## License
367
-
368
- MIT
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
- * Example service demonstrating LeanMCP SDK decorators
3225
+ * ${projectName} - Production-ready MCP server example
3182
3226
  *
3183
- * This is a simple example to get you started. Add your own tools, resources, and prompts here!
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 schema with validation decorators
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 ExampleService {
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
- @Resource({ description: "Get server information" })
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
- uptime: process.uptime()
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
- @Prompt({ description: "Generate a greeting prompt" })
3284
- async greeting(args: { name?: string }) {
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: \`Hello \${args.name || 'there'}! Welcome to ${projectName}.\`
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.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
+ }