@nitrostack/cli 1.0.6 → 1.0.7
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 +201 -0
- package/README.md +39 -96
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +4 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +24 -52
- package/dist/commands/generate-types.d.ts +0 -1
- package/dist/commands/generate-types.d.ts.map +1 -1
- package/dist/commands/generate-types.js +18 -39
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +12 -4
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +6 -5
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +3 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +4 -4
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +92 -77
- package/dist/ui/branding.d.ts +21 -4
- package/dist/ui/branding.d.ts.map +1 -1
- package/dist/ui/branding.js +121 -52
- package/package.json +5 -6
- package/templates/typescript-oauth/.env.example +27 -0
- package/templates/typescript-oauth/README.md +36 -231
- package/templates/typescript-pizzaz/.env.example +8 -0
- package/templates/typescript-pizzaz/README.md +42 -217
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.module.ts +2 -1
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.tasks.ts +294 -0
- package/templates/typescript-starter/.env.example +7 -0
- package/templates/typescript-starter/README.md +51 -284
|
@@ -1,320 +1,87 @@
|
|
|
1
|
-
# NitroStack Starter Template
|
|
1
|
+
# ⚡ NitroStack Starter Template
|
|
2
2
|
|
|
3
|
-
**The
|
|
3
|
+
**The definitive starter template** — Learn the fundamentals of the NitroStack MCP framework with a clean, well-documented calculator example.
|
|
4
4
|
|
|
5
5
|
## 🎯 What's Inside
|
|
6
6
|
|
|
7
|
-
This template
|
|
7
|
+
This template is designed to showcase core NitroStack features with zero friction:
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **No Database** - Pure computation example
|
|
9
|
+
- **Modular Architecture** — Clean separation of concerns with a dedicated Calculator module.
|
|
10
|
+
- **Interactive Tools** — A `calculate` tool for performing arithmetic operations.
|
|
11
|
+
- **Dynamic Resources** — A `calculator://operations` resource for discovering capabilities.
|
|
12
|
+
- **Prompt Library** — Context-aware prompts for guiding users.
|
|
13
|
+
- **Pre-built UI Widgets** — Beautiful, high-performance UI components for results and listings.
|
|
14
|
+
- **Production-Ready** — Uses TypeScript, Zod for validation, and best-in-class logging.
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### Prerequisites
|
|
16
|
+
---
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
# Install NitroStack CLI globally
|
|
23
|
-
npm install -g nitrostack
|
|
18
|
+
## 🚀 Quick Start
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
npx nitrostack --version
|
|
27
|
-
```
|
|
20
|
+
### 1. Initialize Your Project
|
|
28
21
|
|
|
29
|
-
|
|
22
|
+
If you haven't already, scaffold your project using the NitroStack CLI:
|
|
30
23
|
|
|
31
24
|
```bash
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
cd my-calculator
|
|
35
|
-
|
|
36
|
-
# Install all dependencies (root + widgets)
|
|
37
|
-
nitrostack install
|
|
25
|
+
npx nitrostack init my-server --template typescript-starter
|
|
26
|
+
cd my-server
|
|
38
27
|
```
|
|
39
28
|
|
|
40
|
-
|
|
41
|
-
- ✅ Installs all root dependencies
|
|
42
|
-
- ✅ Installs widget dependencies
|
|
43
|
-
- ✅ Sets up the project structure
|
|
29
|
+
### 2. Install Dependencies
|
|
44
30
|
|
|
45
|
-
|
|
31
|
+
Install all project dependencies (including the visual widget SDK) in one step:
|
|
46
32
|
|
|
47
33
|
```bash
|
|
48
|
-
npm run
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
This starts:
|
|
52
|
-
- **MCP Server** (dual transport: STDIO + HTTP) - Hot reloads on code changes
|
|
53
|
-
- **Studio** on http://localhost:3000 - Visual testing environment
|
|
54
|
-
- **Widget Dev Server** on http://localhost:3001 - Hot module replacement
|
|
55
|
-
|
|
56
|
-
> 💡 **Dual Transport**: Your server exposes tools via both STDIO (for direct connections) and HTTP (for remote access). Switch between transports in Studio → Settings.
|
|
57
|
-
|
|
58
|
-
The `nitrostack dev` command handles everything automatically:
|
|
59
|
-
- ✅ Auto-detects widget directory
|
|
60
|
-
- ✅ Installs dependencies (if needed)
|
|
61
|
-
- ✅ Builds widgets (on first run)
|
|
62
|
-
- ✅ Starts all services concurrently
|
|
63
|
-
- ✅ Hot reload for TypeScript and widgets
|
|
64
|
-
|
|
65
|
-
## 📁 Project Structure
|
|
66
|
-
|
|
34
|
+
npm run install:all
|
|
67
35
|
```
|
|
68
|
-
src/
|
|
69
|
-
├── modules/
|
|
70
|
-
│ └── calculator/
|
|
71
|
-
│ ├── calculator.module.ts # @Module definition
|
|
72
|
-
│ ├── calculator.tools.ts # @Tool with examples
|
|
73
|
-
│ ├── calculator.resources.ts # @Resource
|
|
74
|
-
│ └── calculator.prompts.ts # @Prompt
|
|
75
|
-
├── widgets/ # Next.js UI widgets
|
|
76
|
-
│ └── app/
|
|
77
|
-
│ ├── calculator-result/ # Tool result widget
|
|
78
|
-
│ └── calculator-operations/ # Resource widget
|
|
79
|
-
├── app.module.ts # Root @McpApp module
|
|
80
|
-
└── index.ts # Application bootstrap
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## 🛠️ Available Features
|
|
84
|
-
|
|
85
|
-
### Health Check: `system`
|
|
86
36
|
|
|
87
|
-
|
|
37
|
+
### 3. Get NitroStudio
|
|
88
38
|
|
|
89
|
-
|
|
90
|
-
- **Memory Usage**: Heap memory consumption
|
|
91
|
-
- **Process Info**: PID and Node.js version
|
|
92
|
-
- **Status**: `up`, `degraded`, or `down`
|
|
39
|
+
NitroStudio is the recommended visual client for running, testing, and managing your NitroStack projects.
|
|
93
40
|
|
|
94
|
-
|
|
41
|
+
1. **Download NitroStudio**: [nitrostack.ai/studio](https://nitrostack.ai/studio)
|
|
42
|
+
2. **Open Project**: Launch NitroStudio and open this project folder.
|
|
43
|
+
3. **Run**: NitroStudio handles the rest!
|
|
95
44
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Perform basic arithmetic operations:
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
@Tool({
|
|
102
|
-
name: 'calculate',
|
|
103
|
-
description: 'Perform basic arithmetic calculations',
|
|
104
|
-
inputSchema: z.object({
|
|
105
|
-
operation: z.enum(['add', 'subtract', 'multiply', 'divide']),
|
|
106
|
-
a: z.number(),
|
|
107
|
-
b: z.number()
|
|
108
|
-
}),
|
|
109
|
-
examples: {
|
|
110
|
-
request: { operation: 'add', a: 5, b: 3 },
|
|
111
|
-
response: { result: 8, expression: '5 + 3 = 8' }
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
**Usage:**
|
|
117
|
-
```
|
|
118
|
-
User: "Calculate 5 + 3"
|
|
119
|
-
AI: [Calls calculate tool]
|
|
120
|
-
Result: Beautiful widget showing "5 + 3 = 8"
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Resource: `calculator://operations`
|
|
124
|
-
|
|
125
|
-
Lists all available operations with examples.
|
|
126
|
-
|
|
127
|
-
### Prompt: `calculator_help`
|
|
128
|
-
|
|
129
|
-
Get help on how to use the calculator.
|
|
130
|
-
|
|
131
|
-
## 🎨 Widgets
|
|
132
|
-
|
|
133
|
-
### Calculator Result Widget
|
|
134
|
-
- Gradient background
|
|
135
|
-
- Operation icon
|
|
136
|
-
- Breakdown of numbers
|
|
137
|
-
- Beautiful animations
|
|
138
|
-
|
|
139
|
-
### Calculator Operations Widget
|
|
140
|
-
- Grid of all operations
|
|
141
|
-
- Color-coded by type
|
|
142
|
-
- Examples for each operation
|
|
143
|
-
|
|
144
|
-
## 💡 Learning Path
|
|
145
|
-
|
|
146
|
-
This template is perfect for learning:
|
|
45
|
+
---
|
|
147
46
|
|
|
148
|
-
|
|
149
|
-
2. **Tools** - How to create a tool with `@Tool` decorator
|
|
150
|
-
3. **Resources** - How to expose data with `@Resource`
|
|
151
|
-
4. **Prompts** - How to create conversation templates
|
|
152
|
-
5. **Widgets** - How to build UI components
|
|
153
|
-
6. **Examples** - How to include request/response examples
|
|
154
|
-
7. **Validation** - How to use Zod schemas
|
|
47
|
+
## 🛠️ Development
|
|
155
48
|
|
|
156
|
-
|
|
49
|
+
If you prefer using the command line:
|
|
157
50
|
|
|
158
51
|
```bash
|
|
159
|
-
#
|
|
160
|
-
npm
|
|
161
|
-
nitrostack install # Same as above
|
|
162
|
-
|
|
163
|
-
# Development
|
|
164
|
-
npm run dev # Start dev server with Studio
|
|
165
|
-
npm run build # Build TypeScript and widgets for production
|
|
166
|
-
npm start # Run production server
|
|
167
|
-
|
|
168
|
-
# Upgrade
|
|
169
|
-
npm run upgrade # Upgrade nitrostack to latest version
|
|
170
|
-
|
|
171
|
-
# Widget Management
|
|
172
|
-
npm run widget <command> # Run npm command in widgets directory
|
|
173
|
-
npm run widget add <pkg> # Add a widget dependency (e.g., @mui/material)
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## 📝 Example Interactions
|
|
177
|
-
|
|
178
|
-
### Basic Calculation
|
|
179
|
-
```
|
|
180
|
-
User: "What's 12 times 8?"
|
|
181
|
-
AI: Calls calculate(operation="multiply", a=12, b=8)
|
|
182
|
-
Result: Widget showing "12 × 8 = 96"
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Get Help
|
|
186
|
-
```
|
|
187
|
-
User: "How do I use the calculator?"
|
|
188
|
-
AI: Uses calculator_help prompt
|
|
189
|
-
Result: Complete usage instructions
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### List Operations
|
|
193
|
-
```
|
|
194
|
-
User: "What operations are available?"
|
|
195
|
-
AI: Fetches calculator://operations resource
|
|
196
|
-
Result: Widget showing all 4 operations with examples
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## 🎓 Code Walkthrough
|
|
200
|
-
|
|
201
|
-
### 1. Tool Definition
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
@Tool({
|
|
205
|
-
name: 'calculate',
|
|
206
|
-
description: 'Perform basic arithmetic calculations',
|
|
207
|
-
inputSchema: z.object({...}),
|
|
208
|
-
examples: {...}
|
|
209
|
-
})
|
|
210
|
-
@Widget('calculator-result') // Link UI widget
|
|
211
|
-
async calculate(input: any, ctx: ExecutionContext) {
|
|
212
|
-
// Your logic here
|
|
213
|
-
return { result, expression };
|
|
214
|
-
}
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
**Key Points:**
|
|
218
|
-
- `@Tool` decorator defines the tool
|
|
219
|
-
- `inputSchema` validates input with Zod
|
|
220
|
-
- `examples` help AI understand usage
|
|
221
|
-
- `@Widget` links the UI component
|
|
222
|
-
- `ExecutionContext` provides logger, metadata
|
|
223
|
-
|
|
224
|
-
### 2. Resource Definition
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
@Resource({
|
|
228
|
-
uri: 'calculator://operations',
|
|
229
|
-
name: 'Calculator Operations',
|
|
230
|
-
mimeType: 'application/json',
|
|
231
|
-
examples: {...}
|
|
232
|
-
})
|
|
233
|
-
@Widget('calculator-operations')
|
|
234
|
-
async getOperations(uri: string, ctx: ExecutionContext) {
|
|
235
|
-
return { contents: [{...}] };
|
|
236
|
-
}
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### 3. Prompt Definition
|
|
240
|
-
|
|
241
|
-
```typescript
|
|
242
|
-
@Prompt({
|
|
243
|
-
name: 'calculator_help',
|
|
244
|
-
arguments: [...]
|
|
245
|
-
})
|
|
246
|
-
async getHelp(args: any, ctx: ExecutionContext) {
|
|
247
|
-
return { messages: [...] };
|
|
248
|
-
}
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
### 4. Module Definition
|
|
252
|
-
|
|
253
|
-
```typescript
|
|
254
|
-
@Module({
|
|
255
|
-
name: 'calculator',
|
|
256
|
-
controllers: [CalculatorTools, CalculatorResources, CalculatorPrompts]
|
|
257
|
-
})
|
|
258
|
-
export class CalculatorModule {}
|
|
259
|
-
```
|
|
52
|
+
# Start development server (Server + Widgets + Studio)
|
|
53
|
+
npm run dev
|
|
260
54
|
|
|
261
|
-
|
|
55
|
+
# Build for production
|
|
56
|
+
npm run build
|
|
262
57
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
server: { name: 'calculator-server', version: '1.0.0' }
|
|
266
|
-
})
|
|
267
|
-
@Module({
|
|
268
|
-
imports: [ConfigModule.forRoot(), CalculatorModule]
|
|
269
|
-
})
|
|
270
|
-
export class AppModule {}
|
|
58
|
+
# Start production server
|
|
59
|
+
npm start
|
|
271
60
|
```
|
|
272
61
|
|
|
273
|
-
##
|
|
274
|
-
|
|
275
|
-
### Add More Operations
|
|
276
|
-
|
|
277
|
-
Edit `calculator.tools.ts` and add new operations to the enum and switch statement.
|
|
278
|
-
|
|
279
|
-
### Add History Feature
|
|
280
|
-
|
|
281
|
-
1. Create a service to store calculations
|
|
282
|
-
2. Add a `get_history` tool
|
|
283
|
-
3. Create a history widget
|
|
284
|
-
|
|
285
|
-
### Add More Modules
|
|
62
|
+
## 📁 Project Structure
|
|
286
63
|
|
|
287
|
-
```
|
|
288
|
-
|
|
64
|
+
```text
|
|
65
|
+
src/
|
|
66
|
+
├── modules/
|
|
67
|
+
│ └── calculator/
|
|
68
|
+
│ ├── calculator.module.ts # @Module definition
|
|
69
|
+
│ ├── calculator.tools.ts # @Tool implementations
|
|
70
|
+
│ ├── calculator.resources.ts # @Resource definitions
|
|
71
|
+
│ └── calculator.prompts.ts # @Prompt templates
|
|
72
|
+
├── widgets/ # Visual SDK UI components
|
|
73
|
+
├── app.module.ts # Root application module
|
|
74
|
+
└── index.ts # Server entry point
|
|
289
75
|
```
|
|
290
76
|
|
|
291
|
-
##
|
|
292
|
-
|
|
293
|
-
Once you understand this template:
|
|
294
|
-
|
|
295
|
-
1. Try the **Pizza Shop Template** - Interactive maps and widgets
|
|
296
|
-
2. Try the **Flight Booking Template** - API integration with Duffel
|
|
297
|
-
3. Read the [NitroStack Documentation](https://nitrostack.ai/docs)
|
|
77
|
+
## 🎨 Next Generation MCP
|
|
298
78
|
|
|
299
|
-
|
|
79
|
+
NitroStack is more than just a server; it's a full-stack MCP ecosystem.
|
|
300
80
|
|
|
301
|
-
- **
|
|
302
|
-
- **
|
|
303
|
-
- **
|
|
304
|
-
- **Check Examples** - The `examples` field helps AI understand your tools
|
|
305
|
-
|
|
306
|
-
## 🎉 What to Build
|
|
307
|
-
|
|
308
|
-
Use this as a starting point for:
|
|
309
|
-
|
|
310
|
-
- **Unit Converters** - Temperature, currency, etc.
|
|
311
|
-
- **Text Tools** - String manipulation, formatting
|
|
312
|
-
- **Data Processors** - JSON, CSV, XML parsing
|
|
313
|
-
- **Simple APIs** - Weather, jokes, facts
|
|
314
|
-
- **Utilities** - Date/time, UUID generation
|
|
81
|
+
- **Website**: [nitrostack.ai](https://nitrostack.ai)
|
|
82
|
+
- **Documentation**: [docs.nitrostack.ai](https://docs.nitrostack.ai)
|
|
83
|
+
- **Discord**: [Join our community](https://nitrostack.ai/discord)
|
|
315
84
|
|
|
316
85
|
---
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
Start simple, learn the patterns, then build something amazing!
|
|
86
|
+
**Happy Coding! 🎉**
|
|
87
|
+
Build something amazing with NitroStack.
|