nitrostack 1.0.10 → 1.0.12
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
CHANGED
|
@@ -1,571 +1,172 @@
|
|
|
1
|
-
# NitroStack
|
|
1
|
+
# NitroStack ⚡
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build production‑ready MCP (Model Context Protocol) servers with TypeScript — fast.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/nitrostack)
|
|
6
6
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
7
|
[](https://nitrostack.vercel.app/)
|
|
8
8
|
[](https://nitrostack-docs.vercel.app/)
|
|
9
9
|
|
|
10
|
-
NitroStack
|
|
11
|
-
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- 🔐 **Guard System** - Declarative authentication with `@UseGuards`
|
|
49
|
-
- 🔄 **Middleware & Interceptors** - Transform requests/responses
|
|
50
|
-
- 🧪 **Pipes for Validation** - NestJS-style input processing
|
|
51
|
-
- 💉 **Dependency Injection** - Built-in DI container for testability
|
|
52
|
-
- ⚡ **Caching** - `@Cache()` decorator for tool responses
|
|
53
|
-
- 🚦 **Rate Limiting** - `@RateLimit()` for API protection
|
|
54
|
-
- 🎯 **Event System** - `@OnEvent()` for event-driven architecture
|
|
55
|
-
- 🔍 **Studio** - Next.js-based visual testing environment
|
|
56
|
-
- 🤖 **AI Integration** - Test with OpenAI GPT-4 or Gemini 2.0 Flash
|
|
57
|
-
- 📦 **Type Generation** - Auto-generate types from tool definitions
|
|
58
|
-
|
|
59
|
-
## 📦 Installation
|
|
60
|
-
|
|
61
|
-
Install NitroStack globally:
|
|
10
|
+
NitroStack is a batteries‑included toolkit for creating real, shippable MCP servers. It combines a clean, declarative programming model with a built‑in visual Studio, authentication modules, widget UI system, hot‑reload dev workflow, and production‑grade tooling — all focused on one goal: let you build great MCP servers with minimal ceremony.
|
|
11
|
+
|
|
12
|
+
## Why NitroStack
|
|
13
|
+
|
|
14
|
+
Developers typically struggle with:
|
|
15
|
+
- **Boilerplate and wiring**: scattered logic, ad‑hoc conventions, manual glue code
|
|
16
|
+
- **Auth and security**: JWT, OAuth 2.1 (PKCE), API keys, token validation, scopes, multi‑auth
|
|
17
|
+
- **Testing UX**: no clean way to visually exercise tools, resources, prompts
|
|
18
|
+
- **Performance & reliability**: caching, rate limiting, predictable runtime pipeline
|
|
19
|
+
- **DX & iteration**: hot reload, consistent CLIs, starter templates, type generation
|
|
20
|
+
|
|
21
|
+
NitroStack solves these pain points out of the box.
|
|
22
|
+
|
|
23
|
+
## What you get (inbuilt capabilities)
|
|
24
|
+
|
|
25
|
+
- **Declarative building blocks**
|
|
26
|
+
- `@Tool`, `@Widget`, `@Resource`, `@Prompt`, `@Module`
|
|
27
|
+
- `@UseGuards`, `@UseMiddleware`, `@UseInterceptors`, `@UsePipes`, `@UseFilters`
|
|
28
|
+
- **Authentication modules (drop‑in)**
|
|
29
|
+
- `JWTModule` (simple JWT)
|
|
30
|
+
- `OAuthModule` (OAuth 2.1 with PKCE, discovery, scopes, dual transport ready)
|
|
31
|
+
- `ApiKeyModule` (service‑to‑service keys)
|
|
32
|
+
- Multi‑auth patterns (either/both) supported via guards
|
|
33
|
+
- **Studio (built‑in visual test bench)**
|
|
34
|
+
- Run and debug tools, browse resources, test prompts, preview widgets
|
|
35
|
+
- AI chat integration and auto‑form generation from schemas
|
|
36
|
+
- **Widgets UI system**
|
|
37
|
+
- Attach Next.js pages to tools with `@Widget` for instant interactive demos
|
|
38
|
+
- **Runtime pipeline**
|
|
39
|
+
- Middleware, Interceptors, Pipes, Exception Filters for predictable request flow
|
|
40
|
+
- **Performance controls**
|
|
41
|
+
- `@Cache()` and `@RateLimit()` decorators
|
|
42
|
+
- **Type safety**
|
|
43
|
+
- CLI generates types from tool definitions for use across code and widgets
|
|
44
|
+
- **Dev experience**
|
|
45
|
+
- Hot reload, templates, code generators, dual transport support for OAuth metadata
|
|
46
|
+
|
|
47
|
+
## Install
|
|
62
48
|
|
|
63
49
|
```bash
|
|
64
|
-
npm
|
|
50
|
+
npm i -g nitrostack
|
|
65
51
|
```
|
|
66
52
|
|
|
67
|
-
Or use
|
|
53
|
+
Or use once without global install:
|
|
68
54
|
|
|
69
55
|
```bash
|
|
70
56
|
npx nitrostack init my-mcp-server
|
|
71
57
|
```
|
|
72
58
|
|
|
73
|
-
##
|
|
74
|
-
|
|
75
|
-
### 1. Create a New Server
|
|
59
|
+
## Quick Start (3 steps)
|
|
76
60
|
|
|
61
|
+
1) Initialize a project
|
|
77
62
|
```bash
|
|
78
|
-
nitrostack init my-
|
|
79
|
-
cd my-
|
|
63
|
+
nitrostack init my-server --template typescript-starter
|
|
64
|
+
cd my-server
|
|
80
65
|
npm install
|
|
81
66
|
```
|
|
82
67
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
// src/modules/products/products.tools.ts
|
|
87
|
-
import { ToolDecorator as Tool, z, ExecutionContext } from 'nitrostack';
|
|
88
|
-
|
|
89
|
-
export class ProductsTools {
|
|
90
|
-
@Tool({
|
|
91
|
-
name: 'browse_products',
|
|
92
|
-
description: 'Browse products by category',
|
|
93
|
-
inputSchema: z.object({
|
|
94
|
-
category: z.string().optional(),
|
|
95
|
-
limit: z.number().default(10)
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
@Widget('products-grid')
|
|
99
|
-
async browseProducts(input: any, ctx: ExecutionContext) {
|
|
100
|
-
const products = await this.db.query('SELECT * FROM products WHERE category = ?', [input.category]);
|
|
101
|
-
return { products, pagination: { total: products.length } };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 3. Create a Module
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
// src/modules/products/products.module.ts
|
|
110
|
-
import { Module } from 'nitrostack';
|
|
111
|
-
import { ProductsTools } from './products.tools.js';
|
|
112
|
-
import { ProductsResources } from './products.resources.js';
|
|
113
|
-
import { ProductsPrompts } from './products.prompts.js';
|
|
114
|
-
|
|
115
|
-
@Module({
|
|
116
|
-
name: 'products',
|
|
117
|
-
description: 'Product management module',
|
|
118
|
-
controllers: [ProductsTools, ProductsResources, ProductsPrompts]
|
|
119
|
-
})
|
|
120
|
-
export class ProductsModule {}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 4. Bootstrap Your Application
|
|
124
|
-
|
|
125
|
-
```typescript
|
|
126
|
-
// src/app.module.ts
|
|
127
|
-
import { McpApp, Module, ConfigModule, JWTModule } from 'nitrostack';
|
|
128
|
-
import { ProductsModule } from './modules/products/products.module.js';
|
|
129
|
-
|
|
130
|
-
@McpApp({
|
|
131
|
-
server: {
|
|
132
|
-
name: 'my-ecommerce-server',
|
|
133
|
-
version: '1.0.0'
|
|
134
|
-
},
|
|
135
|
-
logging: {
|
|
136
|
-
level: 'info'
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
@Module({
|
|
140
|
-
imports: [
|
|
141
|
-
ConfigModule.forRoot(),
|
|
142
|
-
JWTModule.forRoot({
|
|
143
|
-
secret: process.env.JWT_SECRET!
|
|
144
|
-
}),
|
|
145
|
-
ProductsModule
|
|
146
|
-
]
|
|
147
|
-
})
|
|
148
|
-
export class AppModule {}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
// src/index.ts
|
|
153
|
-
import { McpApplicationFactory } from 'nitrostack';
|
|
154
|
-
import { AppModule } from './app.module.js';
|
|
155
|
-
|
|
156
|
-
McpApplicationFactory.create(AppModule);
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### 5. Start Development
|
|
160
|
-
|
|
68
|
+
2) Start the dev environment
|
|
161
69
|
```bash
|
|
162
70
|
nitrostack dev
|
|
163
71
|
```
|
|
72
|
+
Studio opens at `http://localhost:3000` (widgets at `http://localhost:3001`).
|
|
164
73
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
### Decorators
|
|
170
|
-
|
|
171
|
-
NitroStack v3.0 uses decorators for clean, declarative code:
|
|
172
|
-
|
|
173
|
-
| Decorator | Purpose | Example |
|
|
174
|
-
|-----------|---------|---------|
|
|
175
|
-
| `@Tool` | Define MCP tools | `@Tool({ name: 'get_user' })` |
|
|
176
|
-
| `@Widget` | Attach UI component | `@Widget('user-card')` |
|
|
177
|
-
| `@Resource` | Define data resources | `@Resource({ uri: 'user://{id}' })` |
|
|
178
|
-
| `@Prompt` | Create prompt templates | `@Prompt({ name: 'review-code' })` |
|
|
179
|
-
| `@Module` | Organize code | `@Module({ name: 'users' })` |
|
|
180
|
-
| `@UseGuards` | Add authentication | `@UseGuards(JWTGuard)` |
|
|
181
|
-
| `@UseMiddleware` | Apply middleware | `@UseMiddleware(LoggingMiddleware)` |
|
|
182
|
-
| `@UseInterceptors` | Transform responses | `@UseInterceptors(TransformInterceptor)` |
|
|
183
|
-
| `@UsePipes` | Validate inputs | `@UsePipes(ValidationPipe)` |
|
|
184
|
-
| `@Cache` | Cache responses | `@Cache({ ttl: 300 })` |
|
|
185
|
-
| `@RateLimit` | Limit requests | `@RateLimit({ requests: 10 })` |
|
|
186
|
-
| `@Injectable` | Mark as service | `@Injectable()` |
|
|
187
|
-
| `@OnEvent` | Listen to events | `@OnEvent('user.created')` |
|
|
188
|
-
|
|
189
|
-
### Dependency Injection
|
|
190
|
-
|
|
191
|
-
Use constructor injection for cleaner, testable code:
|
|
192
|
-
|
|
193
|
-
```typescript
|
|
194
|
-
@Injectable()
|
|
195
|
-
export class UserService {
|
|
196
|
-
constructor(private db: DatabaseService) {}
|
|
197
|
-
|
|
198
|
-
async findUser(id: string) {
|
|
199
|
-
return this.db.query('SELECT * FROM users WHERE id = ?', [id]);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
74
|
+
3) Add your first tool
|
|
75
|
+
```ts
|
|
76
|
+
// src/modules/hello/hello.tools.ts
|
|
77
|
+
import { Tool, z, ExecutionContext, Module } from 'nitrostack';
|
|
202
78
|
|
|
203
|
-
export class
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### Guards
|
|
214
|
-
|
|
215
|
-
Declarative authentication:
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
export class JWTGuard implements Guard {
|
|
219
|
-
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
220
|
-
const token = context.auth?.token;
|
|
221
|
-
if (!token) return false;
|
|
222
|
-
|
|
223
|
-
const payload = verifyJWT(token);
|
|
224
|
-
context.auth = { subject: payload.sub };
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
@Tool({ name: 'create_order' })
|
|
230
|
-
@UseGuards(JWTGuard) // ← Auth required!
|
|
231
|
-
async createOrder(input: any, ctx: ExecutionContext) {
|
|
232
|
-
const userId = ctx.auth?.subject;
|
|
233
|
-
// ...
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Middleware
|
|
238
|
-
|
|
239
|
-
Cross-cutting concerns:
|
|
240
|
-
|
|
241
|
-
```typescript
|
|
242
|
-
@Middleware()
|
|
243
|
-
export class LoggingMiddleware implements MiddlewareInterface {
|
|
244
|
-
async use(context: ExecutionContext, next: () => Promise<any>) {
|
|
245
|
-
console.log(`[${context.toolName}] Started`);
|
|
246
|
-
const result = await next();
|
|
247
|
-
console.log(`[${context.toolName}] Completed`);
|
|
248
|
-
return result;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
### Interceptors
|
|
254
|
-
|
|
255
|
-
Transform requests/responses:
|
|
256
|
-
|
|
257
|
-
```typescript
|
|
258
|
-
@Interceptor()
|
|
259
|
-
export class TransformInterceptor implements InterceptorInterface {
|
|
260
|
-
async intercept(context: ExecutionContext, next: () => Promise<any>) {
|
|
261
|
-
const result = await next();
|
|
262
|
-
return {
|
|
263
|
-
success: true,
|
|
264
|
-
data: result,
|
|
265
|
-
timestamp: new Date().toISOString()
|
|
266
|
-
};
|
|
79
|
+
export class HelloTools {
|
|
80
|
+
@Tool({
|
|
81
|
+
name: 'say_hello',
|
|
82
|
+
description: 'Greets a user',
|
|
83
|
+
inputSchema: z.object({ name: z.string() })
|
|
84
|
+
})
|
|
85
|
+
async sayHello(input: { name: string }, ctx: ExecutionContext) {
|
|
86
|
+
return { message: `Hello, ${input.name}!` };
|
|
267
87
|
}
|
|
268
88
|
}
|
|
269
|
-
```
|
|
270
89
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
Create beautiful UIs for your tools:
|
|
274
|
-
|
|
275
|
-
```typescript
|
|
276
|
-
@Tool({
|
|
277
|
-
name: 'get_product',
|
|
278
|
-
description: 'Get product details',
|
|
279
|
-
inputSchema: z.object({
|
|
280
|
-
id: z.string()
|
|
281
|
-
}),
|
|
282
|
-
examples: {
|
|
283
|
-
response: {
|
|
284
|
-
id: 'prod-1',
|
|
285
|
-
name: 'Awesome Product',
|
|
286
|
-
price: 99.99
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
})
|
|
290
|
-
@Widget('product-card')
|
|
291
|
-
async getProduct(input: any) {
|
|
292
|
-
return await this.db.getProduct(input.id);
|
|
293
|
-
}
|
|
90
|
+
@Module({ name: 'hello', controllers: [HelloTools] })
|
|
91
|
+
export class HelloModule {}
|
|
294
92
|
```
|
|
93
|
+
Register the module in `app.module.ts`, save — and call the tool in Studio.
|
|
295
94
|
|
|
296
|
-
|
|
297
|
-
// src/widgets/app/product-card/page.tsx
|
|
298
|
-
'use client';
|
|
299
|
-
import { withToolData } from 'nitrostack/widgets';
|
|
300
|
-
|
|
301
|
-
function ProductCard({ data }) {
|
|
302
|
-
return (
|
|
303
|
-
<div className="product-card">
|
|
304
|
-
<h2>{data.name}</h2>
|
|
305
|
-
<p className="price">${data.price}</p>
|
|
306
|
-
</div>
|
|
307
|
-
);
|
|
308
|
-
}
|
|
95
|
+
## Authentication (inbuilt)
|
|
309
96
|
|
|
310
|
-
|
|
311
|
-
|
|
97
|
+
- **JWTModule**: Simple and fast token auth for user/session flows
|
|
98
|
+
- **OAuthModule**: Full OAuth 2.1 with PKCE, discovery endpoints, scopes, and dual‑transport support (STDIO for MCP + HTTP for OAuth metadata)
|
|
99
|
+
- **ApiKeyModule**: Issue and validate API keys for services and automations
|
|
100
|
+
- **Multi‑auth**: compose guards so a tool can require one or multiple schemes
|
|
312
101
|
|
|
313
|
-
##
|
|
102
|
+
## Studio (visual workflow)
|
|
314
103
|
|
|
315
|
-
|
|
104
|
+
- AI chat to drive tools
|
|
105
|
+
- Auto‑generated forms from schemas
|
|
106
|
+
- Resource browser & prompt explorer
|
|
107
|
+
- Widget previews connected to live tool outputs
|
|
316
108
|
|
|
317
|
-
|
|
318
|
-
nitrostack init <project-name> [--template typescript|typescript-auth]
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
### Development Mode
|
|
109
|
+
## CLI highlights
|
|
322
110
|
|
|
323
111
|
```bash
|
|
324
|
-
|
|
325
|
-
|
|
112
|
+
# Create a project from templates
|
|
113
|
+
nitrostack init <name> --template typescript-starter
|
|
114
|
+
nitrostack init <name> --template typescript-auth
|
|
115
|
+
nitrostack init <name> --template typescript-auth-api-key
|
|
116
|
+
nitrostack init <name> --template typescript-oauth
|
|
326
117
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
### Build for Production
|
|
330
|
-
|
|
331
|
-
```bash
|
|
332
|
-
nitrostack build
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### Generate Code
|
|
336
|
-
|
|
337
|
-
```bash
|
|
338
|
-
# Generate types from tools
|
|
339
|
-
nitrostack generate types [--output src/types/tools.ts]
|
|
340
|
-
|
|
341
|
-
# Generate module
|
|
342
|
-
nitrostack generate module payments
|
|
343
|
-
|
|
344
|
-
# Generate tool
|
|
345
|
-
nitrostack generate tool create-payment --module payments
|
|
346
|
-
|
|
347
|
-
# Generate guard
|
|
348
|
-
nitrostack generate guard admin
|
|
349
|
-
|
|
350
|
-
# Generate middleware
|
|
351
|
-
nitrostack generate middleware logging
|
|
352
|
-
|
|
353
|
-
# Generate interceptor
|
|
354
|
-
nitrostack generate interceptor transform
|
|
355
|
-
|
|
356
|
-
# Generate pipe
|
|
357
|
-
nitrostack generate pipe validation
|
|
358
|
-
|
|
359
|
-
# Generate filter
|
|
360
|
-
nitrostack generate filter exception
|
|
361
|
-
|
|
362
|
-
# Generate service
|
|
363
|
-
nitrostack generate service email
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
## 🔍 Studio
|
|
367
|
-
|
|
368
|
-
NitroStack Studio is a Next.js-based testing environment:
|
|
369
|
-
|
|
370
|
-
### Features
|
|
371
|
-
|
|
372
|
-
- 🤖 **AI Chat** - Test with GPT-4 or Gemini 2.0 Flash
|
|
373
|
-
- 🎨 **Widget Preview** - See UI components in action
|
|
374
|
-
- 🔧 **Tool Testing** - Execute tools with dynamic forms
|
|
375
|
-
- 📊 **Resource Browser** - View all resources
|
|
376
|
-
- 🎯 **Prompt Explorer** - Test prompts with arguments
|
|
377
|
-
- 🌓 **Dark/Light Theme** - Beautiful black & gold design
|
|
378
|
-
|
|
379
|
-
### Supported LLMs
|
|
380
|
-
|
|
381
|
-
- **OpenAI GPT-4** - Industry standard, excellent tool calling
|
|
382
|
-
- **Gemini 2.0 Flash** - Free experimental, 1M token context
|
|
383
|
-
|
|
384
|
-
### Usage
|
|
385
|
-
|
|
386
|
-
```bash
|
|
118
|
+
# Dev / Build
|
|
387
119
|
nitrostack dev
|
|
388
|
-
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
## 🔐 Authentication
|
|
392
|
-
|
|
393
|
-
NitroStack v3.0 supports multiple auth strategies:
|
|
394
|
-
|
|
395
|
-
### JWT (Recommended)
|
|
396
|
-
|
|
397
|
-
```typescript
|
|
398
|
-
@Module({
|
|
399
|
-
imports: [
|
|
400
|
-
JWTModule.forRoot({
|
|
401
|
-
secret: process.env.JWT_SECRET!,
|
|
402
|
-
expiresIn: '1h'
|
|
403
|
-
})
|
|
404
|
-
]
|
|
405
|
-
})
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
### OAuth 2.1
|
|
409
|
-
|
|
410
|
-
Full OAuth 2.1 compliance with PKCE for enterprise apps
|
|
411
|
-
|
|
412
|
-
### API Keys
|
|
413
|
-
|
|
414
|
-
Simple key-based authentication for service-to-service
|
|
415
|
-
|
|
416
|
-
### Guards
|
|
417
|
-
|
|
418
|
-
```typescript
|
|
419
|
-
@Tool({ name: 'admin_tool' })
|
|
420
|
-
@UseGuards(AdminGuard, JWTGuard)
|
|
421
|
-
async adminTool() {
|
|
422
|
-
// Only admins can access
|
|
423
|
-
}
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
## 📦 Type Safety
|
|
427
|
-
|
|
428
|
-
Auto-generate TypeScript types from your tools:
|
|
429
|
-
|
|
430
|
-
```bash
|
|
431
|
-
nitrostack generate types
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
Generated output:
|
|
435
|
-
|
|
436
|
-
```typescript
|
|
437
|
-
// src/types/generated-tools.ts
|
|
438
|
-
export type GetProductInput = {
|
|
439
|
-
id: string;
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
export type GetProductOutput = {
|
|
443
|
-
id: string;
|
|
444
|
-
name: string;
|
|
445
|
-
price: number;
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
export interface ToolInputs {
|
|
449
|
-
'get_product': GetProductInput;
|
|
450
|
-
// ...
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
export interface ToolOutputs {
|
|
454
|
-
'get_product': GetProductOutput;
|
|
455
|
-
// ...
|
|
456
|
-
}
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
Use in widgets:
|
|
460
|
-
|
|
461
|
-
```typescript
|
|
462
|
-
import { GetProductOutput } from '../../types/generated-tools';
|
|
120
|
+
nitrostack build
|
|
463
121
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
122
|
+
# Generators
|
|
123
|
+
nitrostack generate module <name>
|
|
124
|
+
nitrostack generate tool <name> --module <module>
|
|
125
|
+
nitrostack generate guard <name>
|
|
126
|
+
nitrostack generate middleware <name>
|
|
127
|
+
nitrostack generate interceptor <name>
|
|
128
|
+
nitrostack generate pipe <name>
|
|
129
|
+
nitrostack generate filter <name>
|
|
468
130
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
NitroStack includes testing utilities:
|
|
472
|
-
|
|
473
|
-
```typescript
|
|
474
|
-
import { TestingModule, createMockContext } from 'nitrostack/testing';
|
|
475
|
-
|
|
476
|
-
describe('ProductsTools', () => {
|
|
477
|
-
let module: TestingModule;
|
|
478
|
-
|
|
479
|
-
beforeAll(async () => {
|
|
480
|
-
module = await TestingModule.create({
|
|
481
|
-
controllers: [ProductsTools],
|
|
482
|
-
providers: [DatabaseService]
|
|
483
|
-
}).compile();
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
it('should get product', async () => {
|
|
487
|
-
const tool = module.get(ProductsTools);
|
|
488
|
-
const ctx = createMockContext();
|
|
489
|
-
const result = await tool.getProduct({ id: '1' }, ctx);
|
|
490
|
-
expect(result.name).toBeDefined();
|
|
491
|
-
});
|
|
492
|
-
});
|
|
131
|
+
# Types from tools
|
|
132
|
+
nitrostack generate types --output src/types/generated-tools.ts
|
|
493
133
|
```
|
|
494
134
|
|
|
495
|
-
##
|
|
496
|
-
|
|
497
|
-
**📖 Full documentation available at: [https://nitrostack-docs.vercel.app/](https://nitrostack-docs.vercel.app/)**
|
|
498
|
-
|
|
499
|
-
Quick Links:
|
|
500
|
-
- [Getting Started](https://nitrostack-docs.vercel.app/intro)
|
|
501
|
-
- [Installation](https://nitrostack-docs.vercel.app/installation)
|
|
502
|
-
- [Quick Start](https://nitrostack-docs.vercel.app/quick-start)
|
|
503
|
-
- [Tools Guide](https://nitrostack-docs.vercel.app/sdk/typescript/tools)
|
|
504
|
-
- [Widgets Guide](https://nitrostack-docs.vercel.app/sdk/typescript/ui/widgets)
|
|
505
|
-
- [Authentication (JWT, OAuth, API Keys)](https://nitrostack-docs.vercel.app/sdk/typescript/auth/overview)
|
|
506
|
-
- [CLI Reference](https://nitrostack-docs.vercel.app/cli/overview)
|
|
507
|
-
- [API Reference](https://nitrostack-docs.vercel.app/api/decorators)
|
|
508
|
-
- [Templates](https://nitrostack-docs.vercel.app/templates/starter)
|
|
509
|
-
- [Deployment](https://nitrostack-docs.vercel.app/deployment/checklist)
|
|
135
|
+
## Templates
|
|
510
136
|
|
|
137
|
+
- `typescript-starter` — clean starter with widgets and example tools
|
|
138
|
+
- `typescript-auth` — JWT auth flows and end‑to‑end examples
|
|
139
|
+
- `typescript-auth-api-key` — API key auth patterns and multi‑auth
|
|
140
|
+
- `typescript-oauth` — OAuth 2.1 (PKCE, discovery, scopes) with dual transport
|
|
511
141
|
|
|
142
|
+
Use any template with `nitrostack init` and start iterating immediately.
|
|
512
143
|
|
|
513
|
-
##
|
|
514
|
-
|
|
515
|
-
### Build
|
|
144
|
+
## Production
|
|
516
145
|
|
|
517
146
|
```bash
|
|
518
147
|
npm run build
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
### Run
|
|
522
|
-
|
|
523
|
-
```bash
|
|
524
148
|
NODE_ENV=production node dist/index.js
|
|
525
149
|
```
|
|
526
150
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
```dockerfile
|
|
530
|
-
FROM node:20-alpine
|
|
531
|
-
WORKDIR /app
|
|
532
|
-
COPY package*.json ./
|
|
533
|
-
RUN npm ci --production
|
|
534
|
-
COPY dist ./dist
|
|
535
|
-
CMD ["node", "dist/index.js"]
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
## 🤝 Contributing
|
|
151
|
+
Consider enabling caching, rate limits, structured logging, and health checks for production. See the docs for deployment recipes and checklists.
|
|
539
152
|
|
|
540
|
-
|
|
153
|
+
## Documentation
|
|
541
154
|
|
|
542
|
-
|
|
155
|
+
Full docs: `https://nitrostack-docs.vercel.app/`
|
|
156
|
+
- Getting started, SDK guides, decorators, CLI reference, templates, deployment
|
|
543
157
|
|
|
544
|
-
##
|
|
158
|
+
## License
|
|
545
159
|
|
|
546
|
-
|
|
160
|
+
Apache License 2.0 — see `LICENSE`. © 2025 Abhishek Pandit
|
|
547
161
|
|
|
548
|
-
|
|
162
|
+
## Links
|
|
549
163
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
-
|
|
553
|
-
-
|
|
554
|
-
-
|
|
555
|
-
- **npm Package**: [https://www.npmjs.com/package/nitrostack](https://www.npmjs.com/package/nitrostack)
|
|
556
|
-
- **Model Context Protocol**: [https://modelcontextprotocol.io](https://modelcontextprotocol.io)
|
|
557
|
-
|
|
558
|
-
## 🙏 Acknowledgments
|
|
559
|
-
|
|
560
|
-
Built with:
|
|
561
|
-
- [Model Context Protocol SDK](https://www.npmjs.com/package/@modelcontextprotocol/sdk)
|
|
562
|
-
- [Zod](https://zod.dev)
|
|
563
|
-
- [Next.js](https://nextjs.org)
|
|
564
|
-
- [React](https://react.dev)
|
|
565
|
-
- [TypeScript](https://www.typescriptlang.org)
|
|
164
|
+
- Website: `https://nitrostack.vercel.app/`
|
|
165
|
+
- Docs: `https://nitrostack-docs.vercel.app/`
|
|
166
|
+
- GitHub: `https://github.com/abhishekpanditofficial/nitrostack`
|
|
167
|
+
- npm: `https://www.npmjs.com/package/nitrostack`
|
|
168
|
+
- Model Context Protocol: `https://modelcontextprotocol.io`
|
|
566
169
|
|
|
567
170
|
---
|
|
568
171
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
*Star us on GitHub!* ⭐
|
|
172
|
+
Build boldly. Ship MCP servers people love. ⚡
|
package/package.json
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "
|
|
8
|
-
"build": "
|
|
9
|
-
"start": "
|
|
7
|
+
"dev": "nitrostack dev",
|
|
8
|
+
"build": "nitrostack build",
|
|
9
|
+
"start": "nitrostack start",
|
|
10
|
+
"widget": "npm --prefix src/widgets"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
13
|
"nitrostack": "^1",
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "
|
|
8
|
-
"build": "
|
|
9
|
-
"start": "
|
|
7
|
+
"dev": "nitrostack dev",
|
|
8
|
+
"build": "nitrostack build",
|
|
9
|
+
"start": "nitrostack start",
|
|
10
|
+
"widget": "npm --prefix src/widgets"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
13
|
"nitrostack": "^1",
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "
|
|
8
|
-
"build": "
|
|
9
|
-
"start": "
|
|
7
|
+
"dev": "nitrostack dev",
|
|
8
|
+
"build": "nitrostack build",
|
|
9
|
+
"start": "nitrostack start",
|
|
10
|
+
"widget": "npm --prefix src/widgets"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
13
|
"nitrostack": "^1",
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "
|
|
8
|
-
"build": "
|
|
9
|
-
"start": "
|
|
7
|
+
"dev": "nitrostack dev",
|
|
8
|
+
"build": "nitrostack build",
|
|
9
|
+
"start": "nitrostack start",
|
|
10
|
+
"widget": "npm --prefix src/widgets"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
13
|
"nitrostack": "^1",
|