@leanmcp/cli 0.2.12 → 0.2.13

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 LeanMCP Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 LeanMCP Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,428 +1,428 @@
1
- # @leanmcp/cli
2
-
3
- Command-line tool for creating LeanMCP projects with production-ready templates.
4
-
5
- ## Features
6
-
7
- - **Interactive setup** - Guided prompts for dependency installation and dev server
8
- - **Quick project scaffolding** - Create new MCP servers in seconds
9
- - **Complete setup** - Includes TypeScript, dependencies, and configuration
10
- - **Best practices** - Generated projects follow MCP standards
11
- - **Ready to run** - Start developing immediately with hot reload
12
- - **Example service** - Includes working examples to get started
13
- - **Pure ESM** - Modern ES modules with full TypeScript support
14
-
15
- ## Installation
16
-
17
- ```bash
18
- # npm
19
- npm install -g @leanmcp/cli
20
-
21
- # GitHub Packages
22
- npm install -g @leanmcp/cli --registry=https://npm.pkg.github.com
23
- ```
24
-
25
- Or use without installing:
26
- ```bash
27
- npx @leanmcp/cli create my-mcp-server
28
- ```
29
-
30
- ## Usage
31
-
32
- ### Create a New Project
33
-
34
- ```bash
35
- leanmcp create <project-name>
36
- ```
37
-
38
- Or with npx:
39
- ```bash
40
- npx @leanmcp/cli create my-mcp-server
41
- ```
42
-
43
- ### Example
44
-
45
- ```bash
46
- $ leanmcp create my-sentiment-tool
47
- ✔ Project my-sentiment-tool created!
48
-
49
- Success! Your MCP server is ready.
50
-
51
- Next, navigate to your project:
52
- cd my-sentiment-tool
53
-
54
- ? Would you like to install dependencies now? (Y/n) Yes
55
- ✔ Dependencies installed successfully!
56
- ? Would you like to start the development server? (Y/n) Yes
57
-
58
- Starting development server...
59
-
60
- > my-sentiment-tool@1.0.0 dev
61
- > tsx watch main.ts
62
-
63
- [HTTP][INFO] Starting LeanMCP HTTP Server...
64
- [HTTP][INFO] Server running on http://localhost:3001
65
- [HTTP][INFO] MCP endpoint: http://localhost:3001/mcp
66
- ```
67
-
68
- ### Add a New Service
69
-
70
- After creating a project, you can quickly add new services:
71
-
72
- ```bash
73
- leanmcp add <service-name>
74
- ```
75
-
76
- This command:
77
- - Creates a new service file in `mcp/<service-name>.ts`
78
- - Includes example Tool, Prompt, and Resource decorators
79
- - Automatically registers the service in `main.ts`
80
- - Includes schema validation examples
81
-
82
- **Example:**
83
-
84
- ```bash
85
- $ leanmcp add weather
86
- ✔ Created new service: weather
87
- File: mcp/weather.ts
88
- Tool: greet
89
- Prompt: welcomePrompt
90
- Resource: getStatus
91
-
92
- Service automatically registered in main.ts!
93
- ```
94
-
95
- The generated service includes:
96
- - **Tool** - `greet()`: A callable function with schema validation
97
- - **Prompt** - `welcomePrompt()`: A reusable prompt template
98
- - **Resource** - `getStatus()`: A data endpoint
99
-
100
- You can then customize these to fit your needs.
101
-
102
- ## Generated Project Structure
103
-
104
- ```
105
- my-mcp-server/
106
- ├── main.ts # Entry point with HTTP server
107
- ├── package.json # Dependencies and scripts
108
- ├── tsconfig.json # TypeScript configuration
109
- └── mcp/ # Services directory
110
- └── example.ts # Example service with tools
111
- ```
112
-
113
- ## Generated Files
114
-
115
- ### main.ts
116
- Entry point that:
117
- - Loads environment variables
118
- - Creates MCP server instance
119
- - Registers services
120
- - Starts HTTP server with session management
121
-
122
- ### mcp/example.ts
123
- Example service demonstrating:
124
- - `@Tool` decorator for callable functions
125
- - `@Resource` decorator for data sources
126
- - `@Prompt` decorator for prompt templates
127
- - Class-based schema validation with `@SchemaConstraint`
128
- - Input/output type safety
129
-
130
- ### package.json
131
- Includes:
132
- - `@leanmcp/core` - Core MCP functionality
133
- - `@modelcontextprotocol/sdk` - Official MCP SDK
134
- - `express` - HTTP server
135
- - `tsx` - TypeScript execution with hot reload
136
- - All type definitions
137
-
138
- ### tsconfig.json
139
- Configured with:
140
- - ESNext modules
141
- - Decorator support
142
- - Strict type checking
143
- - Source maps
144
-
145
- ## NPM Scripts
146
-
147
- Generated projects include:
148
-
149
- ```bash
150
- npm run dev # Start with hot reload (tsx watch)
151
- npm run build # Build for production
152
- npm run start # Run production build
153
- npm run clean # Remove build artifacts
154
- ```
155
-
156
- ## Development Workflow
157
-
158
- ### Interactive Setup (Recommended)
159
-
160
- The CLI provides an interactive setup experience:
161
-
162
- ```bash
163
- # Create project
164
- leanmcp create my-mcp-server
165
-
166
- # The CLI will:
167
- # 1. Create project structure
168
- # 2. Ask if you want to install dependencies (Y/n)
169
- # 3. If yes, ask if you want to start dev server (Y/n)
170
- # 4. If yes, start server with hot reload
171
-
172
- # If you choose "No" to installation:
173
- cd my-mcp-server
174
- npm install
175
- npm run dev
176
- ```
177
-
178
- ### Manual Setup
179
-
180
- If you prefer manual control:
181
-
182
- ```bash
183
- # 1. Create project (answer "No" to prompts)
184
- leanmcp create my-mcp-server
185
-
186
- # 2. Navigate to project
187
- cd my-mcp-server
188
-
189
- # 3. Install dependencies
190
- npm install
191
-
192
- # 4. Start development server
193
- npm run dev
194
-
195
- # 5. Server starts on http://localhost:3001
196
- # - Endpoint: http://localhost:3001/mcp
197
- # - Health check: http://localhost:3001/health
198
- # - Hot reload enabled
199
-
200
- # 6. Edit files in mcp/ directory
201
- # Server automatically reloads on changes
202
- ```
203
-
204
- ## Testing Your Server
205
-
206
- Test with curl:
207
- ```bash
208
- # List available tools
209
- curl http://localhost:3001/mcp \
210
- -X POST \
211
- -H "Content-Type: application/json" \
212
- -d '{
213
- "jsonrpc": "2.0",
214
- "id": 1,
215
- "method": "tools/list"
216
- }'
217
-
218
- # Call a tool
219
- curl http://localhost:3001/mcp \
220
- -X POST \
221
- -H "Content-Type: application/json" \
222
- -d '{
223
- "jsonrpc": "2.0",
224
- "id": 1,
225
- "method": "tools/call",
226
- "params": {
227
- "name": "calculate",
228
- "arguments": {
229
- "a": 10,
230
- "b": 5,
231
- "operation": "add"
232
- }
233
- }
234
- }'
235
- ```
236
-
237
- ## Customizing Generated Projects
238
-
239
- ### Add New Services
240
-
241
- **Quick Way (Recommended):**
242
-
243
- Use the `add` command to automatically generate and register a new service:
244
-
245
- ```bash
246
- leanmcp add weather
247
- ```
248
-
249
- This creates `mcp/weather.ts` with example Tool, Prompt, and Resource decorators, and automatically registers it in `main.ts`.
250
-
251
- **Manual Way:**
252
-
253
- Create a new file in `mcp/`:
254
-
255
- ```typescript
256
- // mcp/weather.ts
257
- import { Tool } from "@leanmcp/core";
258
-
259
- export class WeatherService {
260
- @Tool({ description: 'Get weather for a city' })
261
- async getWeather(input: { city: string }) {
262
- // Your implementation
263
- return { temperature: 72, condition: 'sunny' };
264
- }
265
- }
266
- ```
267
-
268
- Register in `main.ts`:
269
- ```typescript
270
- import { WeatherService } from "./mcp/weather.js";
271
-
272
- server.registerService(new WeatherService());
273
- ```
274
-
275
- ### Add Authentication
276
-
277
- Install auth package:
278
- ```bash
279
- npm install @leanmcp/auth
280
- ```
281
-
282
- See [@leanmcp/auth](../auth) documentation for details.
283
-
284
- ### Configure Port
285
-
286
- Set in environment variable:
287
- ```bash
288
- PORT=4000 npm run dev
289
- ```
290
-
291
- Or in `.env` file:
292
- ```bash
293
- PORT=4000
294
- ```
295
-
296
- ## Advanced Options
297
-
298
- ### Custom Project Location
299
-
300
- ```bash
301
- leanmcp create my-project
302
- cd my-project
303
- ```
304
-
305
- Project is created in current directory with the specified name.
306
-
307
- ### Modify Template
308
-
309
- The generated project is fully customizable:
310
- - Edit `main.ts` for server configuration
311
- - Add/remove services in `mcp/` directory
312
- - Modify `package.json` for additional dependencies
313
- - Update `tsconfig.json` for compiler options
314
-
315
- ## Troubleshooting
316
-
317
- ### Port Already in Use
318
-
319
- Change the port in `.env`:
320
- ```bash
321
- PORT=3002
322
- ```
323
-
324
- ### Module Not Found Errors
325
-
326
- Ensure you've installed dependencies:
327
- ```bash
328
- npm install
329
- ```
330
-
331
- ### TypeScript Errors
332
-
333
- Check your `tsconfig.json` and ensure:
334
- - `experimentalDecorators: true`
335
- - `emitDecoratorMetadata: true`
336
-
337
- ### Hot Reload Not Working
338
-
339
- Try restarting the dev server:
340
- ```bash
341
- npm run dev
342
- ```
343
-
344
- ## Project Types
345
-
346
- Currently supports:
347
- - **MCP Server** - Standard MCP server with HTTP transport
348
-
349
- Coming soon:
350
- - MCP Server with Auth
351
- - MCP Server with Database
352
- - MCP Server with File Storage
353
-
354
- ## Examples
355
-
356
- See the [examples](../../examples) directory for complete working examples:
357
- - [basic-sentiment-tool](../../examples/basic-sentiment-tool) - Simple sentiment analysis
358
- - [slack-with-auth](../../examples/slack-with-auth) - Slack integration with Cognito auth
359
-
360
- ## Requirements
361
-
362
- - Node.js >= 18.0.0
363
- - npm >= 9.0.0
364
-
365
- ## CLI Commands
366
-
367
- ```bash
368
- leanmcp create <name> # Create new project
369
- leanmcp add <service> # Add new service to existing project
370
- leanmcp --version # Show version
371
- leanmcp --help # Show help
372
- ```
373
-
374
- ### Command Details
375
-
376
- #### `create <project-name>`
377
- Creates a complete MCP server project with:
378
- - Entry point (`main.ts`)
379
- - Example service with Tool, Resource, and Prompt decorators
380
- - TypeScript configuration
381
- - Package.json with all dependencies
382
- - Development and build scripts
383
-
384
- **Interactive Prompts:**
385
- - Asks if you want to install dependencies
386
- - If installed, asks if you want to start dev server
387
- - Runs commands in the project directory automatically
388
-
389
- #### `add <service-name>`
390
- Adds a new service to an existing project:
391
- - Must be run inside a LeanMCP project directory
392
- - Creates `mcp/<service-name>.ts` with template code
393
- - Automatically imports and registers in `main.ts`
394
- - Includes example Tool, Prompt, and Resource implementations
395
- - Uses schema validation with `@SchemaConstraint` decorators
396
-
397
- ## 🌟 Showcase Your MCP Server
398
-
399
- Built something cool with LeanMCP? We'd love to feature it!
400
-
401
- ### How to Get Featured
402
-
403
- 1. **Build** an awesome MCP server using LeanMCP
404
- 2. **Share** your project on GitHub
405
- 3. **Submit** for showcase:
406
- - Open an issue: [Request Showcase](https://github.com/LeanMCP/leanmcp-sdk/issues/new?title=[Showcase]%20Your%20Project%20Name)
407
- - Include:
408
- - Project name and description
409
- - GitHub repository link
410
- - What makes it unique
411
- - Screenshots or demo
412
-
413
-
414
- ## License
415
-
416
- MIT
417
-
418
- ## Related Packages
419
-
420
- - [@leanmcp/core](../core) - Core MCP server functionality
421
- - [@leanmcp/auth](../auth) - Authentication decorators
422
- - [@leanmcp/utils](../utils) - Utility functions
423
-
424
- ## Links
425
-
426
- - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
427
- - [Documentation](https://github.com/LeanMCP/leanmcp-sdk#readme)
428
- - [MCP Specification](https://spec.modelcontextprotocol.io/)
1
+ # @leanmcp/cli
2
+
3
+ Command-line tool for creating LeanMCP projects with production-ready templates.
4
+
5
+ ## Features
6
+
7
+ - **Interactive setup** - Guided prompts for dependency installation and dev server
8
+ - **Quick project scaffolding** - Create new MCP servers in seconds
9
+ - **Complete setup** - Includes TypeScript, dependencies, and configuration
10
+ - **Best practices** - Generated projects follow MCP standards
11
+ - **Ready to run** - Start developing immediately with hot reload
12
+ - **Example service** - Includes working examples to get started
13
+ - **Pure ESM** - Modern ES modules with full TypeScript support
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ # npm
19
+ npm install -g @leanmcp/cli
20
+
21
+ # GitHub Packages
22
+ npm install -g @leanmcp/cli --registry=https://npm.pkg.github.com
23
+ ```
24
+
25
+ Or use without installing:
26
+ ```bash
27
+ npx @leanmcp/cli create my-mcp-server
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ### Create a New Project
33
+
34
+ ```bash
35
+ leanmcp create <project-name>
36
+ ```
37
+
38
+ Or with npx:
39
+ ```bash
40
+ npx @leanmcp/cli create my-mcp-server
41
+ ```
42
+
43
+ ### Example
44
+
45
+ ```bash
46
+ $ leanmcp create my-sentiment-tool
47
+ ✔ Project my-sentiment-tool created!
48
+
49
+ Success! Your MCP server is ready.
50
+
51
+ Next, navigate to your project:
52
+ cd my-sentiment-tool
53
+
54
+ ? Would you like to install dependencies now? (Y/n) Yes
55
+ ✔ Dependencies installed successfully!
56
+ ? Would you like to start the development server? (Y/n) Yes
57
+
58
+ Starting development server...
59
+
60
+ > my-sentiment-tool@1.0.0 dev
61
+ > tsx watch main.ts
62
+
63
+ [HTTP][INFO] Starting LeanMCP HTTP Server...
64
+ [HTTP][INFO] Server running on http://localhost:3001
65
+ [HTTP][INFO] MCP endpoint: http://localhost:3001/mcp
66
+ ```
67
+
68
+ ### Add a New Service
69
+
70
+ After creating a project, you can quickly add new services:
71
+
72
+ ```bash
73
+ leanmcp add <service-name>
74
+ ```
75
+
76
+ This command:
77
+ - Creates a new service file in `mcp/<service-name>.ts`
78
+ - Includes example Tool, Prompt, and Resource decorators
79
+ - Automatically registers the service in `main.ts`
80
+ - Includes schema validation examples
81
+
82
+ **Example:**
83
+
84
+ ```bash
85
+ $ leanmcp add weather
86
+ ✔ Created new service: weather
87
+ File: mcp/weather.ts
88
+ Tool: greet
89
+ Prompt: welcomePrompt
90
+ Resource: getStatus
91
+
92
+ Service automatically registered in main.ts!
93
+ ```
94
+
95
+ The generated service includes:
96
+ - **Tool** - `greet()`: A callable function with schema validation
97
+ - **Prompt** - `welcomePrompt()`: A reusable prompt template
98
+ - **Resource** - `getStatus()`: A data endpoint
99
+
100
+ You can then customize these to fit your needs.
101
+
102
+ ## Generated Project Structure
103
+
104
+ ```
105
+ my-mcp-server/
106
+ ├── main.ts # Entry point with HTTP server
107
+ ├── package.json # Dependencies and scripts
108
+ ├── tsconfig.json # TypeScript configuration
109
+ └── mcp/ # Services directory
110
+ └── example.ts # Example service with tools
111
+ ```
112
+
113
+ ## Generated Files
114
+
115
+ ### main.ts
116
+ Entry point that:
117
+ - Loads environment variables
118
+ - Creates MCP server instance
119
+ - Registers services
120
+ - Starts HTTP server with session management
121
+
122
+ ### mcp/example.ts
123
+ Example service demonstrating:
124
+ - `@Tool` decorator for callable functions
125
+ - `@Resource` decorator for data sources
126
+ - `@Prompt` decorator for prompt templates
127
+ - Class-based schema validation with `@SchemaConstraint`
128
+ - Input/output type safety
129
+
130
+ ### package.json
131
+ Includes:
132
+ - `@leanmcp/core` - Core MCP functionality
133
+ - `@modelcontextprotocol/sdk` - Official MCP SDK
134
+ - `express` - HTTP server
135
+ - `tsx` - TypeScript execution with hot reload
136
+ - All type definitions
137
+
138
+ ### tsconfig.json
139
+ Configured with:
140
+ - ESNext modules
141
+ - Decorator support
142
+ - Strict type checking
143
+ - Source maps
144
+
145
+ ## NPM Scripts
146
+
147
+ Generated projects include:
148
+
149
+ ```bash
150
+ npm run dev # Start with hot reload (tsx watch)
151
+ npm run build # Build for production
152
+ npm run start # Run production build
153
+ npm run clean # Remove build artifacts
154
+ ```
155
+
156
+ ## Development Workflow
157
+
158
+ ### Interactive Setup (Recommended)
159
+
160
+ The CLI provides an interactive setup experience:
161
+
162
+ ```bash
163
+ # Create project
164
+ leanmcp create my-mcp-server
165
+
166
+ # The CLI will:
167
+ # 1. Create project structure
168
+ # 2. Ask if you want to install dependencies (Y/n)
169
+ # 3. If yes, ask if you want to start dev server (Y/n)
170
+ # 4. If yes, start server with hot reload
171
+
172
+ # If you choose "No" to installation:
173
+ cd my-mcp-server
174
+ npm install
175
+ npm run dev
176
+ ```
177
+
178
+ ### Manual Setup
179
+
180
+ If you prefer manual control:
181
+
182
+ ```bash
183
+ # 1. Create project (answer "No" to prompts)
184
+ leanmcp create my-mcp-server
185
+
186
+ # 2. Navigate to project
187
+ cd my-mcp-server
188
+
189
+ # 3. Install dependencies
190
+ npm install
191
+
192
+ # 4. Start development server
193
+ npm run dev
194
+
195
+ # 5. Server starts on http://localhost:3001
196
+ # - Endpoint: http://localhost:3001/mcp
197
+ # - Health check: http://localhost:3001/health
198
+ # - Hot reload enabled
199
+
200
+ # 6. Edit files in mcp/ directory
201
+ # Server automatically reloads on changes
202
+ ```
203
+
204
+ ## Testing Your Server
205
+
206
+ Test with curl:
207
+ ```bash
208
+ # List available tools
209
+ curl http://localhost:3001/mcp \
210
+ -X POST \
211
+ -H "Content-Type: application/json" \
212
+ -d '{
213
+ "jsonrpc": "2.0",
214
+ "id": 1,
215
+ "method": "tools/list"
216
+ }'
217
+
218
+ # Call a tool
219
+ curl http://localhost:3001/mcp \
220
+ -X POST \
221
+ -H "Content-Type: application/json" \
222
+ -d '{
223
+ "jsonrpc": "2.0",
224
+ "id": 1,
225
+ "method": "tools/call",
226
+ "params": {
227
+ "name": "calculate",
228
+ "arguments": {
229
+ "a": 10,
230
+ "b": 5,
231
+ "operation": "add"
232
+ }
233
+ }
234
+ }'
235
+ ```
236
+
237
+ ## Customizing Generated Projects
238
+
239
+ ### Add New Services
240
+
241
+ **Quick Way (Recommended):**
242
+
243
+ Use the `add` command to automatically generate and register a new service:
244
+
245
+ ```bash
246
+ leanmcp add weather
247
+ ```
248
+
249
+ This creates `mcp/weather.ts` with example Tool, Prompt, and Resource decorators, and automatically registers it in `main.ts`.
250
+
251
+ **Manual Way:**
252
+
253
+ Create a new file in `mcp/`:
254
+
255
+ ```typescript
256
+ // mcp/weather.ts
257
+ import { Tool } from "@leanmcp/core";
258
+
259
+ export class WeatherService {
260
+ @Tool({ description: 'Get weather for a city' })
261
+ async getWeather(input: { city: string }) {
262
+ // Your implementation
263
+ return { temperature: 72, condition: 'sunny' };
264
+ }
265
+ }
266
+ ```
267
+
268
+ Register in `main.ts`:
269
+ ```typescript
270
+ import { WeatherService } from "./mcp/weather.js";
271
+
272
+ server.registerService(new WeatherService());
273
+ ```
274
+
275
+ ### Add Authentication
276
+
277
+ Install auth package:
278
+ ```bash
279
+ npm install @leanmcp/auth
280
+ ```
281
+
282
+ See [@leanmcp/auth](../auth) documentation for details.
283
+
284
+ ### Configure Port
285
+
286
+ Set in environment variable:
287
+ ```bash
288
+ PORT=4000 npm run dev
289
+ ```
290
+
291
+ Or in `.env` file:
292
+ ```bash
293
+ PORT=4000
294
+ ```
295
+
296
+ ## Advanced Options
297
+
298
+ ### Custom Project Location
299
+
300
+ ```bash
301
+ leanmcp create my-project
302
+ cd my-project
303
+ ```
304
+
305
+ Project is created in current directory with the specified name.
306
+
307
+ ### Modify Template
308
+
309
+ The generated project is fully customizable:
310
+ - Edit `main.ts` for server configuration
311
+ - Add/remove services in `mcp/` directory
312
+ - Modify `package.json` for additional dependencies
313
+ - Update `tsconfig.json` for compiler options
314
+
315
+ ## Troubleshooting
316
+
317
+ ### Port Already in Use
318
+
319
+ Change the port in `.env`:
320
+ ```bash
321
+ PORT=3002
322
+ ```
323
+
324
+ ### Module Not Found Errors
325
+
326
+ Ensure you've installed dependencies:
327
+ ```bash
328
+ npm install
329
+ ```
330
+
331
+ ### TypeScript Errors
332
+
333
+ Check your `tsconfig.json` and ensure:
334
+ - `experimentalDecorators: true`
335
+ - `emitDecoratorMetadata: true`
336
+
337
+ ### Hot Reload Not Working
338
+
339
+ Try restarting the dev server:
340
+ ```bash
341
+ npm run dev
342
+ ```
343
+
344
+ ## Project Types
345
+
346
+ Currently supports:
347
+ - **MCP Server** - Standard MCP server with HTTP transport
348
+
349
+ Coming soon:
350
+ - MCP Server with Auth
351
+ - MCP Server with Database
352
+ - MCP Server with File Storage
353
+
354
+ ## Examples
355
+
356
+ See the [examples](../../examples) directory for complete working examples:
357
+ - [basic-sentiment-tool](../../examples/basic-sentiment-tool) - Simple sentiment analysis
358
+ - [slack-with-auth](../../examples/slack-with-auth) - Slack integration with Cognito auth
359
+
360
+ ## Requirements
361
+
362
+ - Node.js >= 18.0.0
363
+ - npm >= 9.0.0
364
+
365
+ ## CLI Commands
366
+
367
+ ```bash
368
+ leanmcp create <name> # Create new project
369
+ leanmcp add <service> # Add new service to existing project
370
+ leanmcp --version # Show version
371
+ leanmcp --help # Show help
372
+ ```
373
+
374
+ ### Command Details
375
+
376
+ #### `create <project-name>`
377
+ Creates a complete MCP server project with:
378
+ - Entry point (`main.ts`)
379
+ - Example service with Tool, Resource, and Prompt decorators
380
+ - TypeScript configuration
381
+ - Package.json with all dependencies
382
+ - Development and build scripts
383
+
384
+ **Interactive Prompts:**
385
+ - Asks if you want to install dependencies
386
+ - If installed, asks if you want to start dev server
387
+ - Runs commands in the project directory automatically
388
+
389
+ #### `add <service-name>`
390
+ Adds a new service to an existing project:
391
+ - Must be run inside a LeanMCP project directory
392
+ - Creates `mcp/<service-name>.ts` with template code
393
+ - Automatically imports and registers in `main.ts`
394
+ - Includes example Tool, Prompt, and Resource implementations
395
+ - Uses schema validation with `@SchemaConstraint` decorators
396
+
397
+ ## 🌟 Showcase Your MCP Server
398
+
399
+ Built something cool with LeanMCP? We'd love to feature it!
400
+
401
+ ### How to Get Featured
402
+
403
+ 1. **Build** an awesome MCP server using LeanMCP
404
+ 2. **Share** your project on GitHub
405
+ 3. **Submit** for showcase:
406
+ - Open an issue: [Request Showcase](https://github.com/LeanMCP/leanmcp-sdk/issues/new?title=[Showcase]%20Your%20Project%20Name)
407
+ - Include:
408
+ - Project name and description
409
+ - GitHub repository link
410
+ - What makes it unique
411
+ - Screenshots or demo
412
+
413
+
414
+ ## License
415
+
416
+ MIT
417
+
418
+ ## Related Packages
419
+
420
+ - [@leanmcp/core](../core) - Core MCP server functionality
421
+ - [@leanmcp/auth](../auth) - Authentication decorators
422
+ - [@leanmcp/utils](../utils) - Utility functions
423
+
424
+ ## Links
425
+
426
+ - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
427
+ - [Documentation](https://github.com/LeanMCP/leanmcp-sdk#readme)
428
+ - [MCP Specification](https://spec.modelcontextprotocol.io/)
package/bin/leanmcp.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
2
-
3
- // Always prefer ESM build
4
- import('../dist/index.js');
1
+ #!/usr/bin/env node
2
+
3
+ // Always prefer ESM build
4
+ import('../dist/index.js');
package/dist/index.js CHANGED
@@ -59,14 +59,33 @@ function parseUIAppDecorators(content, filePath) {
59
59
  while ((match = uiAppRegex.exec(content)) !== null) {
60
60
  const decoratorBody = match[1];
61
61
  const methodName = match[2];
62
- const componentMatch = decoratorBody.match(/component\s*:\s*(\w+)/);
63
- if (!componentMatch) continue;
64
- const componentName = componentMatch[1];
65
- const componentPath = importMap[componentName];
66
- if (!componentPath) {
67
- console.warn(`[scanUIApp] Could not resolve import for component: ${componentName}`);
68
- continue;
62
+ let componentPath;
63
+ let componentName;
64
+ const stringMatch = decoratorBody.match(/component\s*:\s*['"]([^'"]+)['"]/);
65
+ if (stringMatch) {
66
+ const relativePath = stringMatch[1];
67
+ const dir = path.dirname(filePath);
68
+ let resolvedPath = path.resolve(dir, relativePath);
69
+ if (!resolvedPath.endsWith(".tsx") && !resolvedPath.endsWith(".ts")) {
70
+ if (fs.existsSync(resolvedPath + ".tsx")) {
71
+ resolvedPath += ".tsx";
72
+ } else if (fs.existsSync(resolvedPath + ".ts")) {
73
+ resolvedPath += ".ts";
74
+ }
75
+ }
76
+ componentPath = resolvedPath;
77
+ componentName = path.basename(relativePath).replace(/\.(tsx?|jsx?)$/, "");
78
+ } else {
79
+ const identifierMatch = decoratorBody.match(/component\s*:\s*(\w+)/);
80
+ if (!identifierMatch) continue;
81
+ componentName = identifierMatch[1];
82
+ componentPath = importMap[componentName];
83
+ if (!componentPath) {
84
+ console.warn(`[scanUIApp] Could not resolve import for component: ${componentName}`);
85
+ continue;
86
+ }
69
87
  }
88
+ if (!componentPath) continue;
70
89
  const servicePrefix = serviceName.replace(/Service$/i, "").toLowerCase();
71
90
  const resourceUri = `ui://${servicePrefix}/${methodName}`;
72
91
  results.push({
@@ -134,11 +153,137 @@ async function buildUIComponent(uiApp, projectDir, isDev = false) {
134
153
  <script type="module" src="./entry.tsx"></script>
135
154
  </body>
136
155
  </html>`);
156
+ const tailwindConfig = path2.join(tempDir, "tailwind.config.js");
157
+ await fs2.writeFile(tailwindConfig, `
158
+ /** @type {import('tailwindcss').Config} */
159
+ module.exports = {
160
+ content: [
161
+ '${path2.join(projectDir, "src/**/*.{ts,tsx}").replace(/\\/g, "/")}',
162
+ '${path2.join(projectDir, "mcp/**/*.{ts,tsx}").replace(/\\/g, "/")}',
163
+ '${path2.join(projectDir, "node_modules/@leanmcp/ui/dist/**/*.{js,mjs}").replace(/\\/g, "/")}',
164
+ '${path2.join(projectDir, "../../packages/ui/src/**/*.{ts,tsx}").replace(/\\/g, "/")}',
165
+ ],
166
+ darkMode: ['class'],
167
+ theme: {
168
+ container: {
169
+ center: true,
170
+ padding: '2rem',
171
+ screens: {
172
+ '2xl': '1400px',
173
+ },
174
+ },
175
+ extend: {
176
+ colors: {
177
+ border: 'hsl(var(--border))',
178
+ input: 'hsl(var(--input))',
179
+ ring: 'hsl(var(--ring))',
180
+ background: 'hsl(var(--background))',
181
+ foreground: 'hsl(var(--foreground))',
182
+ primary: {
183
+ DEFAULT: 'hsl(var(--primary))',
184
+ foreground: 'hsl(var(--primary-foreground))',
185
+ },
186
+ secondary: {
187
+ DEFAULT: 'hsl(var(--secondary))',
188
+ foreground: 'hsl(var(--secondary-foreground))',
189
+ },
190
+ destructive: {
191
+ DEFAULT: 'hsl(var(--destructive))',
192
+ foreground: 'hsl(var(--destructive-foreground))',
193
+ },
194
+ muted: {
195
+ DEFAULT: 'hsl(var(--muted))',
196
+ foreground: 'hsl(var(--muted-foreground))',
197
+ },
198
+ accent: {
199
+ DEFAULT: 'hsl(var(--accent))',
200
+ foreground: 'hsl(var(--accent-foreground))',
201
+ },
202
+ popover: {
203
+ DEFAULT: 'hsl(var(--popover))',
204
+ foreground: 'hsl(var(--popover-foreground))',
205
+ },
206
+ card: {
207
+ DEFAULT: 'hsl(var(--card))',
208
+ foreground: 'hsl(var(--card-foreground))',
209
+ },
210
+ },
211
+ borderRadius: {
212
+ lg: 'var(--radius)',
213
+ md: 'calc(var(--radius) - 2px)',
214
+ sm: 'calc(var(--radius) - 4px)',
215
+ },
216
+ },
217
+ },
218
+ plugins: [],
219
+ }
220
+ `);
221
+ const stylesCss = path2.join(tempDir, "styles.css");
222
+ await fs2.writeFile(stylesCss, `
223
+ @tailwind base;
224
+ @tailwind components;
225
+ @tailwind utilities;
226
+
227
+ @layer base {
228
+ :root {
229
+ --background: 0 0% 100%;
230
+ --foreground: 222.2 84% 4.9%;
231
+ --card: 0 0% 100%;
232
+ --card-foreground: 222.2 84% 4.9%;
233
+ --popover: 0 0% 100%;
234
+ --popover-foreground: 222.2 84% 4.9%;
235
+ --primary: 222.2 47.4% 11.2%;
236
+ --primary-foreground: 210 40% 98%;
237
+ --secondary: 210 40% 96.1%;
238
+ --secondary-foreground: 222.2 47.4% 11.2%;
239
+ --muted: 210 40% 96.1%;
240
+ --muted-foreground: 215.4 16.3% 46.9%;
241
+ --accent: 210 40% 96.1%;
242
+ --accent-foreground: 222.2 47.4% 11.2%;
243
+ --destructive: 0 84.2% 60.2%;
244
+ --destructive-foreground: 210 40% 98%;
245
+ --border: 214.3 31.8% 91.4%;
246
+ --input: 214.3 31.8% 91.4%;
247
+ --ring: 222.2 84% 4.9%;
248
+ --radius: 0.5rem;
249
+ }
250
+
251
+ .dark {
252
+ --background: 222.2 84% 4.9%;
253
+ --foreground: 210 40% 98%;
254
+ --card: 222.2 84% 4.9%;
255
+ --card-foreground: 210 40% 98%;
256
+ --popover: 222.2 84% 4.9%;
257
+ --popover-foreground: 210 40% 98%;
258
+ --primary: 210 40% 98%;
259
+ --primary-foreground: 222.2 47.4% 11.2%;
260
+ --secondary: 217.2 32.6% 17.5%;
261
+ --secondary-foreground: 210 40% 98%;
262
+ --muted: 217.2 32.6% 17.5%;
263
+ --muted-foreground: 215 20.2% 65.1%;
264
+ --accent: 217.2 32.6% 17.5%;
265
+ --accent-foreground: 210 40% 98%;
266
+ --destructive: 0 62.8% 30.6%;
267
+ --destructive-foreground: 210 40% 98%;
268
+ --border: 217.2 32.6% 17.5%;
269
+ --input: 217.2 32.6% 17.5%;
270
+ --ring: 212.7 26.8% 83.9%;
271
+ }
272
+
273
+ body {
274
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
275
+ background-color: hsl(var(--background));
276
+ color: hsl(var(--foreground));
277
+ }
278
+ }
279
+ `);
137
280
  const relativeComponentPath = path2.relative(tempDir, componentPath).replace(/\\/g, "/");
138
281
  await fs2.writeFile(entryJs, `
139
282
  import React, { StrictMode } from 'react';
140
283
  import { createRoot } from 'react-dom/client';
141
- import { AppProvider } from '@leanmcp/ui';
284
+ import { AppProvider, Toaster } from '@leanmcp/ui';
285
+ import '@leanmcp/ui/styles.css';
286
+ import './styles.css';
142
287
  import { ${componentName} } from '${relativeComponentPath.replace(/\.tsx?$/, "")}';
143
288
 
144
289
  const APP_INFO = {
@@ -150,6 +295,7 @@ function App() {
150
295
  return (
151
296
  <AppProvider appInfo={APP_INFO}>
152
297
  <${componentName} />
298
+ <Toaster />
153
299
  </AppProvider>
154
300
  );
155
301
  }
@@ -167,6 +313,16 @@ createRoot(document.getElementById('root')!).render(
167
313
  react(),
168
314
  viteSingleFile()
169
315
  ],
316
+ css: {
317
+ postcss: {
318
+ plugins: [
319
+ (await import("tailwindcss")).default({
320
+ config: tailwindConfig
321
+ }),
322
+ (await import("autoprefixer")).default
323
+ ]
324
+ }
325
+ },
170
326
  build: {
171
327
  outDir,
172
328
  emptyOutDir: false,
package/package.json CHANGED
@@ -1,73 +1,73 @@
1
- {
2
- "name": "@leanmcp/cli",
3
- "version": "0.2.12",
4
- "description": "Command-line interface for scaffolding LeanMCP projects",
5
- "bin": {
6
- "leanmcp": "bin/leanmcp.js"
7
- },
8
- "type": "module",
9
- "main": "dist/index.js",
10
- "types": "dist/index.d.ts",
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.js"
15
- }
16
- },
17
- "files": [
18
- "bin",
19
- "dist",
20
- "README.md",
21
- "LICENSE"
22
- ],
23
- "scripts": {
24
- "build": "tsup src/index.ts --format esm --dts",
25
- "dev": "tsup src/index.ts --format esm --dts --watch",
26
- "test": "echo \"No tests yet\" && exit 0",
27
- "clean": "rimraf dist"
28
- },
29
- "dependencies": {
30
- "@inquirer/prompts": "^7.0.1",
31
- "@vitejs/plugin-react": "^4.3.0",
32
- "archiver": "^7.0.1",
33
- "autoprefixer": "^10.4.16",
34
- "chalk": "^5.3.0",
35
- "chokidar": "^4.0.0",
36
- "commander": "^12.0.0",
37
- "fs-extra": "^11.2.0",
38
- "glob": "^11.0.0",
39
- "ora": "^8.1.0",
40
- "postcss": "^8.4.32",
41
- "tailwindcss": "^3.4.0",
42
- "vite": "^5.4.0",
43
- "vite-plugin-singlefile": "^2.3.0"
44
- },
45
- "devDependencies": {
46
- "@types/archiver": "^6.0.3",
47
- "@types/fs-extra": "^11.0.4",
48
- "@types/node": "^25.0.2",
49
- "rimraf": "^6.1.2"
50
- },
51
- "repository": {
52
- "type": "git",
53
- "url": "git+https://github.com/LeanMCP/leanmcp-sdk.git",
54
- "directory": "packages/cli"
55
- },
56
- "homepage": "https://github.com/LeanMCP/leanmcp-sdk#readme",
57
- "bugs": {
58
- "url": "https://github.com/LeanMCP/leanmcp-sdk/issues"
59
- },
60
- "keywords": [
61
- "mcp",
62
- "model-context-protocol",
63
- "cli",
64
- "scaffolding",
65
- "generator",
66
- "typescript"
67
- ],
68
- "author": "LeanMCP <admin@leanmcp.com>",
69
- "license": "MIT",
70
- "publishConfig": {
71
- "access": "public"
72
- }
1
+ {
2
+ "name": "@leanmcp/cli",
3
+ "version": "0.2.13",
4
+ "description": "Command-line interface for scaffolding LeanMCP projects",
5
+ "bin": {
6
+ "leanmcp": "bin/leanmcp.js"
7
+ },
8
+ "type": "module",
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsup src/index.ts --format esm --dts",
25
+ "dev": "tsup src/index.ts --format esm --dts --watch",
26
+ "test": "echo \"No tests yet\" && exit 0",
27
+ "clean": "rimraf dist"
28
+ },
29
+ "dependencies": {
30
+ "@inquirer/prompts": "^7.0.1",
31
+ "@vitejs/plugin-react": "^4.3.0",
32
+ "archiver": "^7.0.1",
33
+ "autoprefixer": "^10.4.16",
34
+ "chalk": "^5.3.0",
35
+ "chokidar": "^4.0.0",
36
+ "commander": "^12.0.0",
37
+ "fs-extra": "^11.2.0",
38
+ "glob": "^11.0.0",
39
+ "ora": "^8.1.0",
40
+ "postcss": "^8.4.32",
41
+ "tailwindcss": "^3.4.0",
42
+ "vite": "^5.4.0",
43
+ "vite-plugin-singlefile": "^2.3.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/archiver": "^6.0.3",
47
+ "@types/fs-extra": "^11.0.4",
48
+ "@types/node": "^25.0.2",
49
+ "rimraf": "^6.1.2"
50
+ },
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/LeanMCP/leanmcp-sdk.git",
54
+ "directory": "packages/cli"
55
+ },
56
+ "homepage": "https://github.com/LeanMCP/leanmcp-sdk#readme",
57
+ "bugs": {
58
+ "url": "https://github.com/LeanMCP/leanmcp-sdk/issues"
59
+ },
60
+ "keywords": [
61
+ "mcp",
62
+ "model-context-protocol",
63
+ "cli",
64
+ "scaffolding",
65
+ "generator",
66
+ "typescript"
67
+ ],
68
+ "author": "LeanMCP <admin@leanmcp.com>",
69
+ "license": "MIT",
70
+ "publishConfig": {
71
+ "access": "public"
72
+ }
73
73
  }