nitrostack 1.0.54 → 1.0.56
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/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +14 -9
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/widgets/hooks/index.d.ts +7 -0
- package/dist/widgets/hooks/index.d.ts.map +1 -0
- package/dist/widgets/hooks/index.js +7 -0
- package/dist/widgets/hooks/index.js.map +1 -0
- package/dist/widgets/hooks/use-display-mode.d.ts +11 -0
- package/dist/widgets/hooks/use-display-mode.d.ts.map +1 -0
- package/dist/widgets/hooks/use-display-mode.js +13 -0
- package/dist/widgets/hooks/use-display-mode.js.map +1 -0
- package/dist/widgets/hooks/use-max-height.d.ts +10 -0
- package/dist/widgets/hooks/use-max-height.d.ts.map +1 -0
- package/dist/widgets/hooks/use-max-height.js +13 -0
- package/dist/widgets/hooks/use-max-height.js.map +1 -0
- package/dist/widgets/hooks/use-openai-global.d.ts +12 -0
- package/dist/widgets/hooks/use-openai-global.d.ts.map +1 -0
- package/dist/widgets/hooks/use-openai-global.js +32 -0
- package/dist/widgets/hooks/use-openai-global.js.map +1 -0
- package/dist/widgets/hooks/use-theme.d.ts +10 -0
- package/dist/widgets/hooks/use-theme.d.ts.map +1 -0
- package/dist/widgets/hooks/use-theme.js +12 -0
- package/dist/widgets/hooks/use-theme.js.map +1 -0
- package/dist/widgets/hooks/use-widget-state.d.ts +18 -0
- package/dist/widgets/hooks/use-widget-state.d.ts.map +1 -0
- package/dist/widgets/hooks/use-widget-state.js +27 -0
- package/dist/widgets/hooks/use-widget-state.js.map +1 -0
- package/dist/widgets/hooks/useWidgetSDK.d.ts +47 -0
- package/dist/widgets/hooks/useWidgetSDK.d.ts.map +1 -0
- package/dist/widgets/hooks/useWidgetSDK.js +67 -0
- package/dist/widgets/hooks/useWidgetSDK.js.map +1 -0
- package/dist/widgets/index.d.ts +7 -1
- package/dist/widgets/index.d.ts.map +1 -1
- package/dist/widgets/index.js +11 -1
- package/dist/widgets/index.js.map +1 -1
- package/dist/widgets/runtime/WidgetLayout.d.ts +32 -0
- package/dist/widgets/runtime/WidgetLayout.d.ts.map +1 -0
- package/dist/widgets/runtime/WidgetLayout.js +143 -0
- package/dist/widgets/runtime/WidgetLayout.js.map +1 -0
- package/dist/widgets/runtime/widget-polyfill.d.ts +1 -0
- package/dist/widgets/runtime/widget-polyfill.d.ts.map +1 -0
- package/dist/widgets/runtime/widget-polyfill.js +28 -0
- package/dist/widgets/runtime/widget-polyfill.js.map +1 -0
- package/dist/widgets/sdk.d.ts +109 -0
- package/dist/widgets/sdk.d.ts.map +1 -0
- package/dist/widgets/sdk.js +221 -0
- package/dist/widgets/sdk.js.map +1 -0
- package/dist/widgets/types.d.ts +89 -0
- package/dist/widgets/types.d.ts.map +1 -0
- package/dist/widgets/types.js +8 -0
- package/dist/widgets/types.js.map +1 -0
- package/dist/widgets/utils/media-queries.d.ts +34 -0
- package/dist/widgets/utils/media-queries.d.ts.map +1 -0
- package/dist/widgets/utils/media-queries.js +42 -0
- package/dist/widgets/utils/media-queries.js.map +1 -0
- package/package.json +2 -2
- package/src/studio/app/chat/page.tsx +274 -137
- package/src/studio/app/globals.css +140 -64
- package/src/studio/branding.md +807 -0
- package/src/studio/components/WidgetRenderer.tsx +222 -16
- package/src/studio/lib/llm-service.ts +39 -39
- package/templates/typescript-oauth/.env.example +27 -0
- package/templates/typescript-oauth/README.md +226 -306
- package/templates/typescript-oauth/package-lock.json +4253 -0
- package/templates/typescript-oauth/package.json +10 -5
- package/templates/typescript-oauth/src/app.module.ts +39 -36
- package/templates/typescript-oauth/src/guards/oauth.guard.ts +0 -1
- package/templates/typescript-oauth/src/index.ts +22 -30
- package/templates/typescript-oauth/src/modules/flights/booking.tools.ts +323 -0
- package/templates/typescript-oauth/src/modules/flights/flights.module.ts +14 -0
- package/templates/typescript-oauth/src/modules/flights/flights.prompts.ts +231 -0
- package/templates/typescript-oauth/src/modules/flights/flights.resources.ts +215 -0
- package/templates/typescript-oauth/src/modules/flights/flights.tools.ts +457 -0
- package/templates/typescript-oauth/src/services/duffel.service.ts +285 -0
- package/templates/typescript-oauth/src/widgets/app/airport-search/page.tsx +270 -0
- package/templates/typescript-oauth/src/widgets/app/flight-details/page.tsx +261 -0
- package/templates/typescript-oauth/src/widgets/app/flight-search-results/page.tsx +378 -0
- package/templates/typescript-oauth/src/widgets/app/globals.css +167 -0
- package/templates/typescript-oauth/src/widgets/app/layout.tsx +6 -2
- package/templates/typescript-oauth/src/widgets/app/order-cancellation/page.tsx +207 -0
- package/templates/typescript-oauth/src/widgets/app/order-summary/page.tsx +245 -0
- package/templates/typescript-oauth/src/widgets/app/payment-confirmation/page.tsx +152 -0
- package/templates/typescript-oauth/src/widgets/app/seat-selection/page.tsx +486 -0
- package/templates/typescript-oauth/src/widgets/next-env.d.ts +5 -0
- package/templates/typescript-oauth/src/widgets/package-lock.json +155 -126
- package/templates/typescript-oauth/src/widgets/widget-manifest.json +374 -27
- package/templates/typescript-pizzaz/IMPLEMENTATION.md +98 -0
- package/templates/typescript-pizzaz/README.md +233 -0
- package/templates/typescript-pizzaz/package.json +31 -0
- package/templates/typescript-pizzaz/src/app.module.ts +28 -0
- package/templates/typescript-pizzaz/src/index.ts +30 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.data.ts +106 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.module.ts +11 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.service.ts +60 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.tools.ts +197 -0
- package/templates/typescript-pizzaz/src/widgets/app/layout.tsx +18 -0
- package/templates/typescript-pizzaz/src/widgets/app/pizza-list/page.tsx +272 -0
- package/templates/typescript-pizzaz/src/widgets/app/pizza-map/page.tsx +216 -0
- package/templates/typescript-pizzaz/src/widgets/app/pizza-shop/page.tsx +374 -0
- package/templates/typescript-pizzaz/src/widgets/components/CompactShopCard.tsx +144 -0
- package/templates/typescript-pizzaz/src/widgets/components/PizzaCard.tsx +191 -0
- package/templates/typescript-pizzaz/src/widgets/package.json +30 -0
- package/templates/typescript-pizzaz/src/widgets/widget-manifest.json +253 -0
- package/templates/typescript-pizzaz/tsconfig.json +30 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.resources.ts +0 -1
- package/templates/typescript-starter/src/widgets/app/calculator-result/page.tsx +102 -56
- package/templates/typescript-starter/src/widgets/app/layout.tsx +6 -2
- package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +0 -702
- package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +0 -1260
- package/templates/typescript-auth/README.md +0 -402
- package/templates/typescript-auth/package.json +0 -36
- package/templates/typescript-auth/src/app.module.ts +0 -103
- package/templates/typescript-auth/src/db/database.ts +0 -160
- package/templates/typescript-auth/src/db/seed.ts +0 -374
- package/templates/typescript-auth/src/db/setup.ts +0 -87
- package/templates/typescript-auth/src/events/analytics.service.ts +0 -52
- package/templates/typescript-auth/src/events/notification.service.ts +0 -40
- package/templates/typescript-auth/src/filters/global-exception.filter.ts +0 -28
- package/templates/typescript-auth/src/guards/README.md +0 -75
- package/templates/typescript-auth/src/guards/jwt.guard.ts +0 -105
- package/templates/typescript-auth/src/health/database.health.ts +0 -41
- package/templates/typescript-auth/src/index.ts +0 -29
- package/templates/typescript-auth/src/interceptors/transform.interceptor.ts +0 -24
- package/templates/typescript-auth/src/middleware/logging.middleware.ts +0 -42
- package/templates/typescript-auth/src/modules/addresses/addresses.module.ts +0 -16
- package/templates/typescript-auth/src/modules/addresses/addresses.prompts.ts +0 -114
- package/templates/typescript-auth/src/modules/addresses/addresses.resources.ts +0 -40
- package/templates/typescript-auth/src/modules/addresses/addresses.tools.ts +0 -284
- package/templates/typescript-auth/src/modules/auth/auth.module.ts +0 -16
- package/templates/typescript-auth/src/modules/auth/auth.prompts.ts +0 -147
- package/templates/typescript-auth/src/modules/auth/auth.resources.ts +0 -84
- package/templates/typescript-auth/src/modules/auth/auth.tools.ts +0 -139
- package/templates/typescript-auth/src/modules/cart/cart.module.ts +0 -16
- package/templates/typescript-auth/src/modules/cart/cart.prompts.ts +0 -95
- package/templates/typescript-auth/src/modules/cart/cart.resources.ts +0 -44
- package/templates/typescript-auth/src/modules/cart/cart.tools.ts +0 -277
- package/templates/typescript-auth/src/modules/orders/orders.module.ts +0 -16
- package/templates/typescript-auth/src/modules/orders/orders.prompts.ts +0 -88
- package/templates/typescript-auth/src/modules/orders/orders.resources.ts +0 -48
- package/templates/typescript-auth/src/modules/orders/orders.tools.ts +0 -303
- package/templates/typescript-auth/src/modules/products/products.module.ts +0 -16
- package/templates/typescript-auth/src/modules/products/products.prompts.ts +0 -146
- package/templates/typescript-auth/src/modules/products/products.resources.ts +0 -98
- package/templates/typescript-auth/src/modules/products/products.tools.ts +0 -266
- package/templates/typescript-auth/src/pipes/validation.pipe.ts +0 -42
- package/templates/typescript-auth/src/services/database.service.ts +0 -90
- package/templates/typescript-auth/src/widgets/app/add-to-cart/page.tsx +0 -122
- package/templates/typescript-auth/src/widgets/app/address-added/page.tsx +0 -116
- package/templates/typescript-auth/src/widgets/app/address-deleted/page.tsx +0 -105
- package/templates/typescript-auth/src/widgets/app/address-list/page.tsx +0 -139
- package/templates/typescript-auth/src/widgets/app/address-updated/page.tsx +0 -153
- package/templates/typescript-auth/src/widgets/app/cart-cleared/page.tsx +0 -86
- package/templates/typescript-auth/src/widgets/app/cart-updated/page.tsx +0 -116
- package/templates/typescript-auth/src/widgets/app/categories/page.tsx +0 -134
- package/templates/typescript-auth/src/widgets/app/layout.tsx +0 -21
- package/templates/typescript-auth/src/widgets/app/login-result/page.tsx +0 -129
- package/templates/typescript-auth/src/widgets/app/order-confirmation/page.tsx +0 -231
- package/templates/typescript-auth/src/widgets/app/order-details/page.tsx +0 -225
- package/templates/typescript-auth/src/widgets/app/order-history/page.tsx +0 -218
- package/templates/typescript-auth/src/widgets/app/product-card/page.tsx +0 -121
- package/templates/typescript-auth/src/widgets/app/products-grid/page.tsx +0 -198
- package/templates/typescript-auth/src/widgets/app/shopping-cart/page.tsx +0 -187
- package/templates/typescript-auth/src/widgets/app/whoami/page.tsx +0 -165
- package/templates/typescript-auth/src/widgets/next.config.js +0 -38
- package/templates/typescript-auth/src/widgets/package.json +0 -18
- package/templates/typescript-auth/src/widgets/styles/ecommerce.ts +0 -169
- package/templates/typescript-auth/src/widgets/tsconfig.json +0 -28
- package/templates/typescript-auth/src/widgets/types/tool-data.ts +0 -141
- package/templates/typescript-auth/src/widgets/widget-manifest.json +0 -464
- package/templates/typescript-auth/tsconfig.json +0 -27
- package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +0 -701
- package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +0 -1260
- package/templates/typescript-auth-api-key/README.md +0 -485
- package/templates/typescript-auth-api-key/package.json +0 -21
- package/templates/typescript-auth-api-key/src/app.module.ts +0 -38
- package/templates/typescript-auth-api-key/src/guards/apikey.guard.ts +0 -47
- package/templates/typescript-auth-api-key/src/guards/multi-auth.guard.ts +0 -157
- package/templates/typescript-auth-api-key/src/index.ts +0 -47
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.module.ts +0 -12
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.prompts.ts +0 -73
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.resources.ts +0 -60
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.tools.ts +0 -71
- package/templates/typescript-auth-api-key/src/modules/demo/demo.module.ts +0 -18
- package/templates/typescript-auth-api-key/src/modules/demo/demo.tools.ts +0 -155
- package/templates/typescript-auth-api-key/src/modules/demo/multi-auth.tools.ts +0 -123
- package/templates/typescript-auth-api-key/src/widgets/app/calculator-operations/page.tsx +0 -133
- package/templates/typescript-auth-api-key/src/widgets/app/calculator-result/page.tsx +0 -134
- package/templates/typescript-auth-api-key/src/widgets/app/layout.tsx +0 -14
- package/templates/typescript-auth-api-key/src/widgets/package.json +0 -24
- package/templates/typescript-auth-api-key/src/widgets/widget-manifest.json +0 -48
- package/templates/typescript-auth-api-key/tsconfig.json +0 -23
- package/templates/typescript-oauth/OAUTH_SETUP.md +0 -592
- package/templates/typescript-oauth/src/modules/demo/demo.module.ts +0 -16
- package/templates/typescript-oauth/src/modules/demo/demo.tools.ts +0 -190
- package/templates/typescript-oauth/src/widgets/app/calculator-operations/page.tsx +0 -133
- package/templates/typescript-oauth/src/widgets/app/calculator-result/page.tsx +0 -134
- package/templates/typescript-oauth/src/widgets/out/404.html +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_buildManifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_ssgManifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/117-eb57c7ef86f964a4.js +0 -2
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/_not-found/page-dcb83ba3e4d0aafd.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-operations/page-b8913a740073ea8a.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-result/page-ddaaab2fce95dea2.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/layout-cbd3ebdc4ecc5247.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/fd9d1056-749e5812300142af.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/framework-f66176bb897dc684.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-76df43fcef3db344.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-app-f9c40224d04023c5.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_app-72b849fbd24ac258.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_error-7ba65e1336b92748.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/webpack-100b9e646d9c912e.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/calculator-operations.html +0 -1
- package/templates/typescript-oauth/src/widgets/out/calculator-operations.txt +0 -7
- package/templates/typescript-oauth/src/widgets/out/calculator-result.html +0 -1
- package/templates/typescript-oauth/src/widgets/out/calculator-result.txt +0 -7
- package/templates/typescript-starter/src/widgets/app/calculator-operations/page.tsx +0 -133
- /package/templates/{typescript-auth-api-key → typescript-oauth}/src/health/system.health.ts +0 -0
- /package/templates/{typescript-auth-api-key → typescript-pizzaz}/src/widgets/next.config.js +0 -0
- /package/templates/{typescript-auth-api-key → typescript-pizzaz}/src/widgets/tsconfig.json +0 -0
|
@@ -1,394 +1,314 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NitroStack Starter Template
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**The simple starter template** - Learn NitroStack v3.0 fundamentals with a clean calculator example.
|
|
4
4
|
|
|
5
|
-
## 🎯 What
|
|
5
|
+
## 🎯 What's Inside
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
7
|
+
This template demonstrates core NitroStack v3.0 features:
|
|
8
|
+
|
|
9
|
+
- **One Module** - Calculator module with all features
|
|
10
|
+
- **One Tool** - `calculate` - Perform arithmetic operations
|
|
11
|
+
- **One Resource** - `calculator://operations` - List of operations
|
|
12
|
+
- **One Prompt** - `calculator_help` - Get usage help
|
|
13
|
+
- **Two Widgets** - Beautiful UI for results and operations list
|
|
14
|
+
- **No Authentication** - Focus on learning the basics
|
|
15
|
+
- **No Database** - Pure computation example
|
|
13
16
|
|
|
14
17
|
## 🚀 Quick Start
|
|
15
18
|
|
|
16
|
-
###
|
|
19
|
+
### Prerequisites
|
|
17
20
|
|
|
18
21
|
```bash
|
|
19
|
-
|
|
22
|
+
# Install NitroStack CLI globally
|
|
23
|
+
npm install -g nitrostack
|
|
24
|
+
|
|
25
|
+
# Or use npx
|
|
26
|
+
npx nitrostack --version
|
|
20
27
|
```
|
|
21
28
|
|
|
22
|
-
###
|
|
23
|
-
|
|
24
|
-
**⚠️ IMPORTANT:** Follow the steps in **exact order** to avoid common issues!
|
|
25
|
-
|
|
26
|
-
#### Create Auth0 API (Do This First!)
|
|
27
|
-
|
|
28
|
-
1. Auth0 Dashboard → **Applications** → **APIs** → **Create API**
|
|
29
|
-
2. **Settings:**
|
|
30
|
-
- **Name**: `MCP Server API`
|
|
31
|
-
- **Identifier**: `https://mcplocal` (your RESOURCE_URI - can be any unique URI)
|
|
32
|
-
- **Signing Algorithm**: **RS256**
|
|
33
|
-
- **JWT Profile**: **RFC 9068** (OAuth 2.0 Access Token JWT Profile)
|
|
34
|
-
3. **Permissions** tab → **Add Scopes:**
|
|
35
|
-
- `read` - Read access to resources
|
|
36
|
-
- `write` - Write/modify resources
|
|
37
|
-
- `admin` - Administrative operations
|
|
38
|
-
4. **Save**
|
|
39
|
-
|
|
40
|
-
#### Create Auth0 Application
|
|
41
|
-
|
|
42
|
-
1. Go to [Auth0 Dashboard](https://manage.auth0.com/)
|
|
43
|
-
2. **Applications** → **Create Application**
|
|
44
|
-
3. Choose **"Regular Web Application"** ← **CRITICAL!** (Not SPA or M2M)
|
|
45
|
-
4. **Application Settings:**
|
|
46
|
-
- **Name**: `MCP Server OAuth`
|
|
47
|
-
- **Allowed Callback URLs**: `http://localhost:3005/auth/callback,http://localhost:3000/auth/callback`
|
|
48
|
-
- **Allowed Logout URLs**: `http://localhost:3005,http://localhost:3000`
|
|
49
|
-
- **Allowed Web Origins**: `http://localhost:3005,http://localhost:3000`
|
|
50
|
-
- **Advanced Settings → Grant Types**:
|
|
51
|
-
- ✅ Authorization Code
|
|
52
|
-
- ✅ Refresh Token
|
|
53
|
-
- ❌ Implicit (disable)
|
|
54
|
-
- **Advanced Settings → ID Token Tab**:
|
|
55
|
-
- ❌ ID Token Encryption: **DISABLED** or **NONE**
|
|
56
|
-
5. **Save** and copy:
|
|
57
|
-
- **Domain** (e.g., `dev-xxx.us.auth0.com`)
|
|
58
|
-
- **Client ID**
|
|
59
|
-
- **Client Secret**
|
|
60
|
-
|
|
61
|
-
#### Link Application to API
|
|
62
|
-
|
|
63
|
-
1. Go to **Applications** → **APIs** → **MCP Server API**
|
|
64
|
-
2. Click **"Machine to Machine Applications"** tab
|
|
65
|
-
3. Find your `MCP Server OAuth` application
|
|
66
|
-
4. Toggle to **"Authorized"** (green)
|
|
67
|
-
5. Expand and select all scopes (`read`, `write`, `admin`)
|
|
68
|
-
6. Click **"Update"**
|
|
69
|
-
|
|
70
|
-
### 3. Configure Environment Variables
|
|
71
|
-
|
|
72
|
-
Edit `.env` with your Auth0 settings:
|
|
29
|
+
### Setup Your Project
|
|
73
30
|
|
|
74
31
|
```bash
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# Your Auth0 domain (with https://)
|
|
79
|
-
AUTH_SERVER_URL=https://YOUR-TENANT.auth0.com
|
|
80
|
-
|
|
81
|
-
# Token audience (MUST match RESOURCE_URI)
|
|
82
|
-
TOKEN_AUDIENCE=https://mcplocal
|
|
83
|
-
|
|
84
|
-
# Token issuer (Auth0 domain with trailing slash - don't forget the /)
|
|
85
|
-
TOKEN_ISSUER=https://YOUR-TENANT.auth0.com/
|
|
32
|
+
nitrostack init my-calculator --template typescript-starter
|
|
33
|
+
cd my-calculator
|
|
86
34
|
```
|
|
87
35
|
|
|
88
|
-
|
|
36
|
+
That's it! The CLI automatically:
|
|
37
|
+
- ✅ Installs all dependencies
|
|
38
|
+
- ✅ Installs widget dependencies
|
|
39
|
+
- ✅ Builds the widgets
|
|
40
|
+
- ✅ Sets up the project structure
|
|
89
41
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
### 4. Start the Server
|
|
42
|
+
### Run the Project
|
|
93
43
|
|
|
94
44
|
```bash
|
|
95
45
|
npm run dev
|
|
96
46
|
```
|
|
97
47
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
NITRO_LOG::{"level":"info","message":" Resource URI: https://mcplocal"}
|
|
103
|
-
NITRO_LOG::{"level":"info","message":" Auth Servers: https://YOUR-TENANT.auth0.com"}
|
|
104
|
-
🚀 Server started successfully (DUAL: STDIO + HTTP)
|
|
105
|
-
📡 MCP Protocol: STDIO (for Studio/Claude)
|
|
106
|
-
🌐 OAuth Metadata: HTTP (port 3005)
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
**Note:** The server runs in **DUAL mode**:
|
|
110
|
-
- **STDIO**: For MCP protocol communication
|
|
111
|
-
- **HTTP (port 3005)**: For OAuth discovery in dev mode
|
|
112
|
-
- **HTTP (port 3000)**: For OAuth discovery in prod mode
|
|
48
|
+
This starts:
|
|
49
|
+
- **MCP Server** (dual transport: STDIO + HTTP on port 3002) - Hot reloads on code changes
|
|
50
|
+
- **Studio** on http://localhost:3000 - Visual testing environment
|
|
51
|
+
- **Widget Dev Server** on http://localhost:3001 - Hot module replacement
|
|
113
52
|
|
|
114
|
-
|
|
53
|
+
> 💡 **Dual Transport**: Your server exposes tools via both STDIO (for direct connections) and HTTP (for remote access on port 3002). Switch between transports in Studio → Settings.
|
|
115
54
|
|
|
116
|
-
|
|
117
|
-
|
|
55
|
+
The `nitrostack dev` command handles everything automatically:
|
|
56
|
+
- ✅ Auto-detects widget directory
|
|
57
|
+
- ✅ Installs dependencies (if needed)
|
|
58
|
+
- ✅ Builds widgets (on first run)
|
|
59
|
+
- ✅ Starts all services concurrently
|
|
60
|
+
- ✅ Hot reload for TypeScript and widgets
|
|
118
61
|
|
|
119
|
-
|
|
120
|
-
1. Go to **Auth → OAuth 2.1** tab
|
|
121
|
-
2. Enter Server URL: `http://localhost:3005` (dev mode uses port 3005)
|
|
122
|
-
3. Click **"Discover Auth Config"**
|
|
123
|
-
4. ✅ Should show: **Discovery Successful**
|
|
124
|
-
5. You'll see the discovered metadata (resource URI, auth server, scopes)
|
|
125
|
-
6. ✅ Check browser console for: `🎯 Setting audience parameter: https://mcplocal`
|
|
62
|
+
## 📁 Project Structure
|
|
126
63
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
#### Step 4: Test Protected Tools
|
|
143
|
-
1. Go to **Tools** tab
|
|
144
|
-
2. Try any protected tool (e.g., `get_user_profile`, `list_resources`)
|
|
145
|
-
3. ✅ Your JWT token is automatically included in requests!
|
|
146
|
-
4. Tools will show your authenticated user info
|
|
147
|
-
|
|
148
|
-
**Congratulations! 🎉** Your OAuth 2.1 server is working!
|
|
149
|
-
|
|
150
|
-
## 📋 Available Tools
|
|
151
|
-
|
|
152
|
-
### Public Tools (No Auth)
|
|
64
|
+
```
|
|
65
|
+
src/
|
|
66
|
+
├── modules/
|
|
67
|
+
│ └── calculator/
|
|
68
|
+
│ ├── calculator.module.ts # @Module definition
|
|
69
|
+
│ ├── calculator.tools.ts # @Tool with examples
|
|
70
|
+
│ ├── calculator.resources.ts # @Resource
|
|
71
|
+
│ └── calculator.prompts.ts # @Prompt
|
|
72
|
+
├── widgets/ # Next.js UI widgets
|
|
73
|
+
│ └── app/
|
|
74
|
+
│ ├── calculator-result/ # Tool result widget
|
|
75
|
+
│ └── calculator-operations/ # Resource widget
|
|
76
|
+
├── app.module.ts # Root @McpApp module
|
|
77
|
+
└── index.ts # Application bootstrap
|
|
78
|
+
```
|
|
153
79
|
|
|
154
|
-
|
|
155
|
-
|------|-------------|
|
|
156
|
-
| `get_server_info` | Get server information |
|
|
80
|
+
## 🛠️ Available Features
|
|
157
81
|
|
|
158
|
-
###
|
|
82
|
+
### Health Check: `system`
|
|
159
83
|
|
|
160
|
-
|
|
161
|
-
|------|-----------------|-------------|
|
|
162
|
-
| `get_user_profile` | _(any valid token)_ | Get authenticated user info |
|
|
163
|
-
| `list_resources` | `read` | List available resources |
|
|
164
|
-
| `create_resource` | `write` | Create a new resource |
|
|
165
|
-
| `admin_statistics` | `read`, `admin` | Get admin statistics |
|
|
84
|
+
Monitors server health and resources:
|
|
166
85
|
|
|
167
|
-
|
|
86
|
+
- **Uptime**: Server running time
|
|
87
|
+
- **Memory Usage**: Heap memory consumption
|
|
88
|
+
- **Process Info**: PID and Node.js version
|
|
89
|
+
- **Status**: `up`, `degraded`, or `down`
|
|
168
90
|
|
|
169
|
-
|
|
170
|
-
typescript-oauth/
|
|
171
|
-
├── src/
|
|
172
|
-
│ ├── guards/
|
|
173
|
-
│ │ └── oauth.guard.ts # OAuth token validation
|
|
174
|
-
│ ├── modules/demo/
|
|
175
|
-
│ │ ├── demo.module.ts
|
|
176
|
-
│ │ └── demo.tools.ts # Example tools
|
|
177
|
-
│ ├── app.module.ts # OAuthModule configuration
|
|
178
|
-
│ └── index.ts # Entry point
|
|
179
|
-
├── .env.example # Environment template
|
|
180
|
-
├── OAUTH_SETUP.md # Provider setup guides
|
|
181
|
-
└── README.md
|
|
182
|
-
```
|
|
91
|
+
Check health status in Studio's Health Checks tab!
|
|
183
92
|
|
|
184
|
-
|
|
93
|
+
### Tool: `calculate`
|
|
185
94
|
|
|
186
|
-
|
|
95
|
+
Perform basic arithmetic operations:
|
|
187
96
|
|
|
188
97
|
```typescript
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
98
|
+
@Tool({
|
|
99
|
+
name: 'calculate',
|
|
100
|
+
description: 'Perform basic arithmetic calculations',
|
|
101
|
+
inputSchema: z.object({
|
|
102
|
+
operation: z.enum(['add', 'subtract', 'multiply', 'divide']),
|
|
103
|
+
a: z.number(),
|
|
104
|
+
b: z.number()
|
|
105
|
+
}),
|
|
106
|
+
examples: {
|
|
107
|
+
request: { operation: 'add', a: 5, b: 3 },
|
|
108
|
+
response: { result: 8, expression: '5 + 3 = 8' }
|
|
109
|
+
}
|
|
197
110
|
})
|
|
198
111
|
```
|
|
199
112
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
203
|
-
// Protect a tool with OAuth
|
|
204
|
-
@Tool({ name: 'protected_tool' })
|
|
205
|
-
@UseGuards(OAuthGuard)
|
|
206
|
-
async protectedTool() {
|
|
207
|
-
// Only accessible with valid OAuth token
|
|
208
|
-
}
|
|
113
|
+
**Usage:**
|
|
209
114
|
```
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
```typescript
|
|
214
|
-
// Require specific scopes
|
|
215
|
-
@Tool({ name: 'admin_tool' })
|
|
216
|
-
@UseGuards(OAuthGuard, createScopeGuard(['admin']))
|
|
217
|
-
async adminTool() {
|
|
218
|
-
// Requires 'admin' scope
|
|
219
|
-
}
|
|
115
|
+
User: "Calculate 5 + 3"
|
|
116
|
+
AI: [Calls calculate tool]
|
|
117
|
+
Result: Beautiful widget showing "5 + 3 = 8"
|
|
220
118
|
```
|
|
221
119
|
|
|
222
|
-
|
|
120
|
+
### Resource: `calculator://operations`
|
|
223
121
|
|
|
224
|
-
|
|
122
|
+
Lists all available operations with examples.
|
|
225
123
|
|
|
226
|
-
|
|
124
|
+
### Prompt: `calculator_help`
|
|
227
125
|
|
|
228
|
-
|
|
229
|
-
// Tokens MUST include your RESOURCE_URI in the audience claim
|
|
230
|
-
{
|
|
231
|
-
"aud": "https://mcp.yourapp.com", // ← Must match RESOURCE_URI
|
|
232
|
-
"sub": "user123",
|
|
233
|
-
"scope": "read write"
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### 2. No Token Passthrough
|
|
126
|
+
Get help on how to use the calculator.
|
|
238
127
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
```typescript
|
|
242
|
-
// ❌ WRONG - Don't do this
|
|
243
|
-
await upstreamAPI.call(headers: { Authorization: clientToken });
|
|
128
|
+
## 🎨 Widgets
|
|
244
129
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
130
|
+
### Calculator Result Widget
|
|
131
|
+
- Gradient background
|
|
132
|
+
- Operation icon
|
|
133
|
+
- Breakdown of numbers
|
|
134
|
+
- Beautiful animations
|
|
249
135
|
|
|
250
|
-
###
|
|
136
|
+
### Calculator Operations Widget
|
|
137
|
+
- Grid of all operations
|
|
138
|
+
- Color-coded by type
|
|
139
|
+
- Examples for each operation
|
|
251
140
|
|
|
252
|
-
|
|
141
|
+
## 💡 Learning Path
|
|
253
142
|
|
|
254
|
-
|
|
255
|
-
// Automatically validates scopes
|
|
256
|
-
@UseGuards(OAuthGuard, createScopeGuard(['read', 'write']))
|
|
257
|
-
```
|
|
143
|
+
This template is perfect for learning:
|
|
258
144
|
|
|
259
|
-
|
|
145
|
+
1. **Module Organization** - How to structure a feature module
|
|
146
|
+
2. **Tools** - How to create a tool with `@Tool` decorator
|
|
147
|
+
3. **Resources** - How to expose data with `@Resource`
|
|
148
|
+
4. **Prompts** - How to create conversation templates
|
|
149
|
+
5. **Widgets** - How to build UI components
|
|
150
|
+
6. **Examples** - How to include request/response examples
|
|
151
|
+
7. **Validation** - How to use Zod schemas
|
|
260
152
|
|
|
261
|
-
|
|
153
|
+
## 🔧 Commands
|
|
262
154
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
155
|
+
```bash
|
|
156
|
+
# Development
|
|
157
|
+
npm run dev # Start dev server with Studio (auto-builds everything)
|
|
158
|
+
npm run build # Build TypeScript and widgets for production
|
|
159
|
+
npm start # Run production server
|
|
160
|
+
|
|
161
|
+
# Widget Management
|
|
162
|
+
npm run widget <command> # Run npm command in widgets directory
|
|
163
|
+
npm run widget add <pkg> # Add a widget dependency (e.g., @mui/material)
|
|
164
|
+
```
|
|
266
165
|
|
|
267
|
-
|
|
166
|
+
**Note:** The NitroStack CLI automatically handles building, installing dependencies, and hot reload. You don't need separate commands for widgets anymore!
|
|
268
167
|
|
|
269
|
-
|
|
270
|
-
2. Login with your credentials
|
|
271
|
-
3. Grant requested scopes
|
|
272
|
-
4. Studio receives and stores the token
|
|
168
|
+
## 📝 Example Interactions
|
|
273
169
|
|
|
274
|
-
###
|
|
170
|
+
### Basic Calculation
|
|
171
|
+
```
|
|
172
|
+
User: "What's 12 times 8?"
|
|
173
|
+
AI: Calls calculate(operation="multiply", a=12, b=8)
|
|
174
|
+
Result: Widget showing "12 × 8 = 96"
|
|
175
|
+
```
|
|
275
176
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
177
|
+
### Get Help
|
|
178
|
+
```
|
|
179
|
+
User: "How do I use the calculator?"
|
|
180
|
+
AI: Uses calculator_help prompt
|
|
181
|
+
Result: Complete usage instructions
|
|
182
|
+
```
|
|
279
183
|
|
|
280
|
-
|
|
184
|
+
### List Operations
|
|
185
|
+
```
|
|
186
|
+
User: "What operations are available?"
|
|
187
|
+
AI: Fetches calculator://operations resource
|
|
188
|
+
Result: Widget showing all 4 operations with examples
|
|
189
|
+
```
|
|
281
190
|
|
|
282
|
-
|
|
191
|
+
## 🎓 Code Walkthrough
|
|
283
192
|
|
|
284
|
-
|
|
285
|
-
- ✅ **RFC 9728** - Protected Resource Metadata
|
|
286
|
-
- ✅ **RFC 8414** - Authorization Server Metadata
|
|
287
|
-
- ✅ **RFC 7591** - Dynamic Client Registration
|
|
288
|
-
- ✅ **RFC 8707** - Resource Indicators (Token Audience Binding)
|
|
289
|
-
- ✅ **RFC 7636** - PKCE
|
|
290
|
-
- ✅ **RFC 7662** - Token Introspection
|
|
193
|
+
### 1. Tool Definition
|
|
291
194
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
195
|
+
```typescript
|
|
196
|
+
@Tool({
|
|
197
|
+
name: 'calculate',
|
|
198
|
+
description: 'Perform basic arithmetic calculations',
|
|
199
|
+
inputSchema: z.object({...}),
|
|
200
|
+
examples: {...}
|
|
201
|
+
})
|
|
202
|
+
@Widget('calculator-result') // Link UI widget
|
|
203
|
+
async calculate(input: any, ctx: ExecutionContext) {
|
|
204
|
+
// Your logic here
|
|
205
|
+
return { result, expression };
|
|
206
|
+
}
|
|
207
|
+
```
|
|
295
208
|
|
|
296
|
-
|
|
209
|
+
**Key Points:**
|
|
210
|
+
- `@Tool` decorator defines the tool
|
|
211
|
+
- `inputSchema` validates input with Zod
|
|
212
|
+
- `examples` help AI understand usage
|
|
213
|
+
- `@Widget` links the UI component
|
|
214
|
+
- `ExecutionContext` provides logger, metadata
|
|
297
215
|
|
|
298
|
-
###
|
|
216
|
+
### 2. Resource Definition
|
|
299
217
|
|
|
300
|
-
|
|
301
|
-
|
|
218
|
+
```typescript
|
|
219
|
+
@Resource({
|
|
220
|
+
uri: 'calculator://operations',
|
|
221
|
+
name: 'Calculator Operations',
|
|
222
|
+
mimeType: 'application/json',
|
|
223
|
+
examples: {...}
|
|
224
|
+
})
|
|
225
|
+
@Widget('calculator-operations')
|
|
226
|
+
async getOperations(uri: string, ctx: ExecutionContext) {
|
|
227
|
+
return { contents: [{...}] };
|
|
228
|
+
}
|
|
229
|
+
```
|
|
302
230
|
|
|
303
|
-
###
|
|
231
|
+
### 3. Prompt Definition
|
|
304
232
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
233
|
+
```typescript
|
|
234
|
+
@Prompt({
|
|
235
|
+
name: 'calculator_help',
|
|
236
|
+
arguments: [...]
|
|
237
|
+
})
|
|
238
|
+
async getHelp(args: any, ctx: ExecutionContext) {
|
|
239
|
+
return { messages: [...] };
|
|
240
|
+
}
|
|
241
|
+
```
|
|
310
242
|
|
|
311
|
-
|
|
243
|
+
### 4. Module Definition
|
|
312
244
|
|
|
313
|
-
|
|
245
|
+
```typescript
|
|
246
|
+
@Module({
|
|
247
|
+
name: 'calculator',
|
|
248
|
+
controllers: [CalculatorTools, CalculatorResources, CalculatorPrompts]
|
|
249
|
+
})
|
|
250
|
+
export class CalculatorModule {}
|
|
251
|
+
```
|
|
314
252
|
|
|
315
|
-
|
|
316
|
-
- ✅ **Okta** - Enterprise-ready
|
|
317
|
-
- ✅ **Keycloak** - Self-hosted
|
|
318
|
-
- ✅ **Azure AD / Entra ID**
|
|
319
|
-
- ✅ **Google Identity Platform**
|
|
320
|
-
- ✅ **Custom OAuth servers**
|
|
253
|
+
### 5. Root Module
|
|
321
254
|
|
|
322
|
-
|
|
255
|
+
```typescript
|
|
256
|
+
@McpApp({
|
|
257
|
+
server: { name: 'calculator-server', version: '1.0.0' }
|
|
258
|
+
})
|
|
259
|
+
@Module({
|
|
260
|
+
imports: [ConfigModule.forRoot(), CalculatorModule]
|
|
261
|
+
})
|
|
262
|
+
export class AppModule {}
|
|
263
|
+
```
|
|
323
264
|
|
|
324
|
-
##
|
|
265
|
+
## 🚀 Extend This Template
|
|
325
266
|
|
|
326
|
-
###
|
|
267
|
+
### Add More Operations
|
|
327
268
|
|
|
328
|
-
|
|
329
|
-
```
|
|
330
|
-
[DEBUG] Token header: {"alg":"dir","enc":"A256GCM",...}
|
|
331
|
-
[ERROR] Received JWE (encrypted) token instead of JWT!
|
|
332
|
-
```
|
|
269
|
+
Edit `calculator.tools.ts` and add new operations to the enum and switch statement.
|
|
333
270
|
|
|
334
|
-
|
|
335
|
-
1. Go to Applications → Your Application → Settings → Advanced Settings
|
|
336
|
-
2. Click "ID Token" tab
|
|
337
|
-
3. Disable "ID Token Encryption" or set to "None"
|
|
338
|
-
4. Save and re-authorize in Studio
|
|
271
|
+
### Add History Feature
|
|
339
272
|
|
|
340
|
-
|
|
273
|
+
1. Create a service to store calculations
|
|
274
|
+
2. Add a `get_history` tool
|
|
275
|
+
3. Create a history widget
|
|
341
276
|
|
|
342
|
-
|
|
277
|
+
### Add More Modules
|
|
343
278
|
|
|
344
279
|
```bash
|
|
345
|
-
|
|
346
|
-
RESOURCE_URI=https://mcplocal
|
|
347
|
-
TOKEN_AUDIENCE=https://mcplocal
|
|
348
|
-
|
|
349
|
-
# Token will have:
|
|
350
|
-
{
|
|
351
|
-
"aud": "https://mcplocal" # ← Must match exactly
|
|
352
|
-
}
|
|
280
|
+
nitrostack generate module converter
|
|
353
281
|
```
|
|
354
282
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
**Fix:** Application type must be "Regular Web Application", not "Single Page Application". Delete and recreate the application with correct type.
|
|
283
|
+
## 📚 Next Steps
|
|
358
284
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
**Fix:** Copy `.env.example` to `.env` and configure all required variables.
|
|
362
|
-
|
|
363
|
-
```bash
|
|
364
|
-
cp .env.example .env
|
|
365
|
-
# Edit .env with your OAuth provider settings
|
|
366
|
-
```
|
|
285
|
+
Once you understand this template:
|
|
367
286
|
|
|
368
|
-
|
|
287
|
+
1. Try the [E-commerce Template](/templates/ecommerce) - Advanced features with auth
|
|
288
|
+
2. Read [Server Concepts](/sdk/typescript/server) - Deep dive into modules
|
|
289
|
+
3. Read [Tools Guide](/sdk/typescript/tools) - Advanced tool patterns
|
|
290
|
+
4. Read [Widgets Guide](/sdk/typescript/ui/widgets) - Build better UIs
|
|
369
291
|
|
|
370
|
-
|
|
292
|
+
## 💡 Tips
|
|
371
293
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
294
|
+
- **Keep it Simple** - This template shows the minimum needed
|
|
295
|
+
- **Study the Code** - Each file has clear examples
|
|
296
|
+
- **Test in Studio** - Use the chat to test your tools
|
|
297
|
+
- **Check Examples** - The `examples` field helps AI understand your tools
|
|
375
298
|
|
|
376
|
-
##
|
|
299
|
+
## 🎉 What to Build
|
|
377
300
|
|
|
378
|
-
|
|
379
|
-
- [OpenAI Apps SDK Auth](https://developers.openai.com/apps-sdk/build/auth)
|
|
380
|
-
- [OAuth 2.1 Draft](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13)
|
|
381
|
-
- [RFC 8707 - Resource Indicators](https://datatracker.ietf.org/doc/html/rfc8707)
|
|
382
|
-
- [OAUTH_SETUP.md](./OAUTH_SETUP.md) - Provider setup guides
|
|
301
|
+
Use this as a starting point for:
|
|
383
302
|
|
|
384
|
-
|
|
303
|
+
- **Unit Converters** - Temperature, currency, etc.
|
|
304
|
+
- **Text Tools** - String manipulation, formatting
|
|
305
|
+
- **Data Processors** - JSON, CSV, XML parsing
|
|
306
|
+
- **Simple APIs** - Weather, jokes, facts
|
|
307
|
+
- **Utilities** - Date/time, UUID generation
|
|
385
308
|
|
|
386
|
-
|
|
309
|
+
---
|
|
387
310
|
|
|
388
|
-
|
|
389
|
-
2. Integrate with your user database
|
|
390
|
-
3. Add custom token validation logic
|
|
391
|
-
4. Deploy with your chosen OAuth provider
|
|
311
|
+
**Happy Learning! 📖**
|
|
392
312
|
|
|
393
|
-
|
|
313
|
+
Start simple, learn the patterns, then build something amazing!
|
|
394
314
|
|