nitrostack 1.0.55 → 1.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/dist/cli/commands/init.d.ts.map +1 -1
  2. package/dist/cli/commands/init.js +14 -9
  3. package/dist/cli/commands/init.js.map +1 -1
  4. package/dist/widgets/hooks/index.d.ts +7 -0
  5. package/dist/widgets/hooks/index.d.ts.map +1 -0
  6. package/dist/widgets/hooks/index.js +7 -0
  7. package/dist/widgets/hooks/index.js.map +1 -0
  8. package/dist/widgets/hooks/use-display-mode.d.ts +11 -0
  9. package/dist/widgets/hooks/use-display-mode.d.ts.map +1 -0
  10. package/dist/widgets/hooks/use-display-mode.js +13 -0
  11. package/dist/widgets/hooks/use-display-mode.js.map +1 -0
  12. package/dist/widgets/hooks/use-max-height.d.ts +10 -0
  13. package/dist/widgets/hooks/use-max-height.d.ts.map +1 -0
  14. package/dist/widgets/hooks/use-max-height.js +13 -0
  15. package/dist/widgets/hooks/use-max-height.js.map +1 -0
  16. package/dist/widgets/hooks/use-openai-global.d.ts +12 -0
  17. package/dist/widgets/hooks/use-openai-global.d.ts.map +1 -0
  18. package/dist/widgets/hooks/use-openai-global.js +32 -0
  19. package/dist/widgets/hooks/use-openai-global.js.map +1 -0
  20. package/dist/widgets/hooks/use-theme.d.ts +10 -0
  21. package/dist/widgets/hooks/use-theme.d.ts.map +1 -0
  22. package/dist/widgets/hooks/use-theme.js +12 -0
  23. package/dist/widgets/hooks/use-theme.js.map +1 -0
  24. package/dist/widgets/hooks/use-widget-state.d.ts +18 -0
  25. package/dist/widgets/hooks/use-widget-state.d.ts.map +1 -0
  26. package/dist/widgets/hooks/use-widget-state.js +27 -0
  27. package/dist/widgets/hooks/use-widget-state.js.map +1 -0
  28. package/dist/widgets/hooks/useWidgetSDK.d.ts +47 -0
  29. package/dist/widgets/hooks/useWidgetSDK.d.ts.map +1 -0
  30. package/dist/widgets/hooks/useWidgetSDK.js +67 -0
  31. package/dist/widgets/hooks/useWidgetSDK.js.map +1 -0
  32. package/dist/widgets/index.d.ts +7 -1
  33. package/dist/widgets/index.d.ts.map +1 -1
  34. package/dist/widgets/index.js +11 -1
  35. package/dist/widgets/index.js.map +1 -1
  36. package/dist/widgets/runtime/WidgetLayout.d.ts +32 -0
  37. package/dist/widgets/runtime/WidgetLayout.d.ts.map +1 -0
  38. package/dist/widgets/runtime/WidgetLayout.js +143 -0
  39. package/dist/widgets/runtime/WidgetLayout.js.map +1 -0
  40. package/dist/widgets/runtime/widget-polyfill.d.ts +1 -0
  41. package/dist/widgets/runtime/widget-polyfill.d.ts.map +1 -0
  42. package/dist/widgets/runtime/widget-polyfill.js +28 -0
  43. package/dist/widgets/runtime/widget-polyfill.js.map +1 -0
  44. package/dist/widgets/sdk.d.ts +109 -0
  45. package/dist/widgets/sdk.d.ts.map +1 -0
  46. package/dist/widgets/sdk.js +221 -0
  47. package/dist/widgets/sdk.js.map +1 -0
  48. package/dist/widgets/types.d.ts +89 -0
  49. package/dist/widgets/types.d.ts.map +1 -0
  50. package/dist/widgets/types.js +8 -0
  51. package/dist/widgets/types.js.map +1 -0
  52. package/dist/widgets/utils/media-queries.d.ts +34 -0
  53. package/dist/widgets/utils/media-queries.d.ts.map +1 -0
  54. package/dist/widgets/utils/media-queries.js +42 -0
  55. package/dist/widgets/utils/media-queries.js.map +1 -0
  56. package/package.json +2 -2
  57. package/src/studio/app/chat/page.tsx +274 -137
  58. package/src/studio/app/globals.css +140 -64
  59. package/src/studio/branding.md +807 -0
  60. package/src/studio/components/WidgetRenderer.tsx +222 -16
  61. package/src/studio/lib/llm-service.ts +39 -39
  62. package/templates/typescript-oauth/{env.example → .env.example} +4 -10
  63. package/templates/typescript-oauth/README.md +226 -306
  64. package/templates/typescript-oauth/package-lock.json +4253 -0
  65. package/templates/typescript-oauth/package.json +10 -5
  66. package/templates/typescript-oauth/src/app.module.ts +39 -36
  67. package/templates/typescript-oauth/src/guards/oauth.guard.ts +0 -1
  68. package/templates/typescript-oauth/src/index.ts +22 -30
  69. package/templates/typescript-oauth/src/modules/flights/booking.tools.ts +323 -0
  70. package/templates/typescript-oauth/src/modules/flights/flights.module.ts +14 -0
  71. package/templates/typescript-oauth/src/modules/flights/flights.prompts.ts +231 -0
  72. package/templates/typescript-oauth/src/modules/flights/flights.resources.ts +215 -0
  73. package/templates/typescript-oauth/src/modules/flights/flights.tools.ts +457 -0
  74. package/templates/typescript-oauth/src/services/duffel.service.ts +285 -0
  75. package/templates/typescript-oauth/src/widgets/app/airport-search/page.tsx +270 -0
  76. package/templates/typescript-oauth/src/widgets/app/flight-details/page.tsx +261 -0
  77. package/templates/typescript-oauth/src/widgets/app/flight-search-results/page.tsx +378 -0
  78. package/templates/typescript-oauth/src/widgets/app/globals.css +167 -0
  79. package/templates/typescript-oauth/src/widgets/app/layout.tsx +6 -2
  80. package/templates/typescript-oauth/src/widgets/app/order-cancellation/page.tsx +207 -0
  81. package/templates/typescript-oauth/src/widgets/app/order-summary/page.tsx +245 -0
  82. package/templates/typescript-oauth/src/widgets/app/payment-confirmation/page.tsx +152 -0
  83. package/templates/typescript-oauth/src/widgets/app/seat-selection/page.tsx +486 -0
  84. package/templates/typescript-oauth/src/widgets/next-env.d.ts +5 -0
  85. package/templates/typescript-oauth/src/widgets/package-lock.json +155 -126
  86. package/templates/typescript-oauth/src/widgets/widget-manifest.json +374 -27
  87. package/templates/typescript-pizzaz/IMPLEMENTATION.md +98 -0
  88. package/templates/typescript-pizzaz/README.md +233 -0
  89. package/templates/typescript-pizzaz/package.json +31 -0
  90. package/templates/typescript-pizzaz/src/app.module.ts +28 -0
  91. package/templates/typescript-pizzaz/src/index.ts +30 -0
  92. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.data.ts +106 -0
  93. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.module.ts +11 -0
  94. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.service.ts +60 -0
  95. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.tools.ts +197 -0
  96. package/templates/typescript-pizzaz/src/widgets/app/layout.tsx +18 -0
  97. package/templates/typescript-pizzaz/src/widgets/app/pizza-list/page.tsx +272 -0
  98. package/templates/typescript-pizzaz/src/widgets/app/pizza-map/page.tsx +216 -0
  99. package/templates/typescript-pizzaz/src/widgets/app/pizza-shop/page.tsx +374 -0
  100. package/templates/typescript-pizzaz/src/widgets/components/CompactShopCard.tsx +144 -0
  101. package/templates/typescript-pizzaz/src/widgets/components/PizzaCard.tsx +191 -0
  102. package/templates/typescript-pizzaz/src/widgets/package.json +30 -0
  103. package/templates/typescript-pizzaz/src/widgets/widget-manifest.json +253 -0
  104. package/templates/typescript-pizzaz/tsconfig.json +30 -0
  105. package/templates/typescript-starter/src/modules/calculator/calculator.resources.ts +0 -1
  106. package/templates/typescript-starter/src/widgets/app/calculator-result/page.tsx +102 -56
  107. package/templates/typescript-starter/src/widgets/app/layout.tsx +6 -2
  108. package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +0 -702
  109. package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +0 -1260
  110. package/templates/typescript-auth/README.md +0 -402
  111. package/templates/typescript-auth/env.example +0 -25
  112. package/templates/typescript-auth/package.json +0 -36
  113. package/templates/typescript-auth/src/app.module.ts +0 -103
  114. package/templates/typescript-auth/src/db/database.ts +0 -160
  115. package/templates/typescript-auth/src/db/seed.ts +0 -374
  116. package/templates/typescript-auth/src/db/setup.ts +0 -87
  117. package/templates/typescript-auth/src/events/analytics.service.ts +0 -52
  118. package/templates/typescript-auth/src/events/notification.service.ts +0 -40
  119. package/templates/typescript-auth/src/filters/global-exception.filter.ts +0 -28
  120. package/templates/typescript-auth/src/guards/README.md +0 -75
  121. package/templates/typescript-auth/src/guards/jwt.guard.ts +0 -105
  122. package/templates/typescript-auth/src/health/database.health.ts +0 -41
  123. package/templates/typescript-auth/src/index.ts +0 -29
  124. package/templates/typescript-auth/src/interceptors/transform.interceptor.ts +0 -24
  125. package/templates/typescript-auth/src/middleware/logging.middleware.ts +0 -42
  126. package/templates/typescript-auth/src/modules/addresses/addresses.module.ts +0 -16
  127. package/templates/typescript-auth/src/modules/addresses/addresses.prompts.ts +0 -114
  128. package/templates/typescript-auth/src/modules/addresses/addresses.resources.ts +0 -40
  129. package/templates/typescript-auth/src/modules/addresses/addresses.tools.ts +0 -284
  130. package/templates/typescript-auth/src/modules/auth/auth.module.ts +0 -16
  131. package/templates/typescript-auth/src/modules/auth/auth.prompts.ts +0 -147
  132. package/templates/typescript-auth/src/modules/auth/auth.resources.ts +0 -84
  133. package/templates/typescript-auth/src/modules/auth/auth.tools.ts +0 -139
  134. package/templates/typescript-auth/src/modules/cart/cart.module.ts +0 -16
  135. package/templates/typescript-auth/src/modules/cart/cart.prompts.ts +0 -95
  136. package/templates/typescript-auth/src/modules/cart/cart.resources.ts +0 -44
  137. package/templates/typescript-auth/src/modules/cart/cart.tools.ts +0 -277
  138. package/templates/typescript-auth/src/modules/orders/orders.module.ts +0 -16
  139. package/templates/typescript-auth/src/modules/orders/orders.prompts.ts +0 -88
  140. package/templates/typescript-auth/src/modules/orders/orders.resources.ts +0 -48
  141. package/templates/typescript-auth/src/modules/orders/orders.tools.ts +0 -303
  142. package/templates/typescript-auth/src/modules/products/products.module.ts +0 -16
  143. package/templates/typescript-auth/src/modules/products/products.prompts.ts +0 -146
  144. package/templates/typescript-auth/src/modules/products/products.resources.ts +0 -98
  145. package/templates/typescript-auth/src/modules/products/products.tools.ts +0 -266
  146. package/templates/typescript-auth/src/pipes/validation.pipe.ts +0 -42
  147. package/templates/typescript-auth/src/services/database.service.ts +0 -90
  148. package/templates/typescript-auth/src/widgets/app/add-to-cart/page.tsx +0 -122
  149. package/templates/typescript-auth/src/widgets/app/address-added/page.tsx +0 -116
  150. package/templates/typescript-auth/src/widgets/app/address-deleted/page.tsx +0 -105
  151. package/templates/typescript-auth/src/widgets/app/address-list/page.tsx +0 -139
  152. package/templates/typescript-auth/src/widgets/app/address-updated/page.tsx +0 -153
  153. package/templates/typescript-auth/src/widgets/app/cart-cleared/page.tsx +0 -86
  154. package/templates/typescript-auth/src/widgets/app/cart-updated/page.tsx +0 -116
  155. package/templates/typescript-auth/src/widgets/app/categories/page.tsx +0 -134
  156. package/templates/typescript-auth/src/widgets/app/layout.tsx +0 -21
  157. package/templates/typescript-auth/src/widgets/app/login-result/page.tsx +0 -129
  158. package/templates/typescript-auth/src/widgets/app/order-confirmation/page.tsx +0 -231
  159. package/templates/typescript-auth/src/widgets/app/order-details/page.tsx +0 -225
  160. package/templates/typescript-auth/src/widgets/app/order-history/page.tsx +0 -218
  161. package/templates/typescript-auth/src/widgets/app/product-card/page.tsx +0 -121
  162. package/templates/typescript-auth/src/widgets/app/products-grid/page.tsx +0 -198
  163. package/templates/typescript-auth/src/widgets/app/shopping-cart/page.tsx +0 -187
  164. package/templates/typescript-auth/src/widgets/app/whoami/page.tsx +0 -165
  165. package/templates/typescript-auth/src/widgets/next.config.js +0 -38
  166. package/templates/typescript-auth/src/widgets/package.json +0 -18
  167. package/templates/typescript-auth/src/widgets/styles/ecommerce.ts +0 -169
  168. package/templates/typescript-auth/src/widgets/tsconfig.json +0 -28
  169. package/templates/typescript-auth/src/widgets/types/tool-data.ts +0 -141
  170. package/templates/typescript-auth/src/widgets/widget-manifest.json +0 -464
  171. package/templates/typescript-auth/tsconfig.json +0 -27
  172. package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +0 -701
  173. package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +0 -1260
  174. package/templates/typescript-auth-api-key/README.md +0 -485
  175. package/templates/typescript-auth-api-key/env.example +0 -17
  176. package/templates/typescript-auth-api-key/package.json +0 -21
  177. package/templates/typescript-auth-api-key/src/app.module.ts +0 -38
  178. package/templates/typescript-auth-api-key/src/guards/apikey.guard.ts +0 -47
  179. package/templates/typescript-auth-api-key/src/guards/multi-auth.guard.ts +0 -157
  180. package/templates/typescript-auth-api-key/src/index.ts +0 -47
  181. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.module.ts +0 -12
  182. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.prompts.ts +0 -73
  183. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.resources.ts +0 -60
  184. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.tools.ts +0 -71
  185. package/templates/typescript-auth-api-key/src/modules/demo/demo.module.ts +0 -18
  186. package/templates/typescript-auth-api-key/src/modules/demo/demo.tools.ts +0 -155
  187. package/templates/typescript-auth-api-key/src/modules/demo/multi-auth.tools.ts +0 -123
  188. package/templates/typescript-auth-api-key/src/widgets/app/calculator-operations/page.tsx +0 -133
  189. package/templates/typescript-auth-api-key/src/widgets/app/calculator-result/page.tsx +0 -134
  190. package/templates/typescript-auth-api-key/src/widgets/app/layout.tsx +0 -14
  191. package/templates/typescript-auth-api-key/src/widgets/package.json +0 -24
  192. package/templates/typescript-auth-api-key/src/widgets/widget-manifest.json +0 -48
  193. package/templates/typescript-auth-api-key/tsconfig.json +0 -23
  194. package/templates/typescript-oauth/OAUTH_SETUP.md +0 -592
  195. package/templates/typescript-oauth/src/modules/demo/demo.module.ts +0 -16
  196. package/templates/typescript-oauth/src/modules/demo/demo.tools.ts +0 -190
  197. package/templates/typescript-oauth/src/widgets/app/calculator-operations/page.tsx +0 -133
  198. package/templates/typescript-oauth/src/widgets/app/calculator-result/page.tsx +0 -134
  199. package/templates/typescript-oauth/src/widgets/out/404.html +0 -1
  200. package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_buildManifest.js +0 -1
  201. package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_ssgManifest.js +0 -1
  202. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/117-eb57c7ef86f964a4.js +0 -2
  203. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/_not-found/page-dcb83ba3e4d0aafd.js +0 -1
  204. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-operations/page-b8913a740073ea8a.js +0 -1
  205. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-result/page-ddaaab2fce95dea2.js +0 -1
  206. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/layout-cbd3ebdc4ecc5247.js +0 -1
  207. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/fd9d1056-749e5812300142af.js +0 -1
  208. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/framework-f66176bb897dc684.js +0 -1
  209. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-76df43fcef3db344.js +0 -1
  210. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-app-f9c40224d04023c5.js +0 -1
  211. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_app-72b849fbd24ac258.js +0 -1
  212. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_error-7ba65e1336b92748.js +0 -1
  213. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
  214. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/webpack-100b9e646d9c912e.js +0 -1
  215. package/templates/typescript-oauth/src/widgets/out/calculator-operations.html +0 -1
  216. package/templates/typescript-oauth/src/widgets/out/calculator-operations.txt +0 -7
  217. package/templates/typescript-oauth/src/widgets/out/calculator-result.html +0 -1
  218. package/templates/typescript-oauth/src/widgets/out/calculator-result.txt +0 -7
  219. package/templates/typescript-starter/src/widgets/app/calculator-operations/page.tsx +0 -133
  220. /package/templates/{typescript-auth-api-key → typescript-oauth}/src/health/system.health.ts +0 -0
  221. /package/templates/{typescript-auth-api-key → typescript-pizzaz}/src/widgets/next.config.js +0 -0
  222. /package/templates/{typescript-auth-api-key → typescript-pizzaz}/src/widgets/tsconfig.json +0 -0
@@ -1,394 +1,314 @@
1
- # OAuth 2.1 MCP Server Template
1
+ # NitroStack Starter Template
2
2
 
3
- Complete OAuth 2.1 authentication implementation for Model Context Protocol servers.
3
+ **The simple starter template** - Learn NitroStack v3.0 fundamentals with a clean calculator example.
4
4
 
5
- ## 🎯 What This Template Demonstrates
5
+ ## 🎯 What's Inside
6
6
 
7
- - **OAuth 2.1** authentication (MCP & OpenAI Apps SDK compliant)
8
- - ✅ **Token Audience Binding** (RFC 8707) - Critical security feature
9
- - **Protected Resource Metadata** (RFC 9728) - Auto-discovery
10
- - **PKCE Support** (RFC 7636) - Already handled by NitroStack Studio
11
- - **Scope-based Access Control** - Fine-grained permissions
12
- - **Multi-Provider Support** - Works with Auth0, Okta, Keycloak, etc.
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
- ### 1. Install Dependencies
19
+ ### Prerequisites
17
20
 
18
21
  ```bash
19
- npm install
22
+ # Install NitroStack CLI globally
23
+ npm install -g nitrostack
24
+
25
+ # Or use npx
26
+ npx nitrostack --version
20
27
  ```
21
28
 
22
- ### 2. Setup Auth0 (Recommended for Quick Testing)
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
- # Your MCP server's resource URI (MUST match Auth0 API Identifier EXACTLY)
76
- RESOURCE_URI=https://mcplocal
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
- **⚠️ Replace `YOUR-TENANT` with your actual Auth0 domain!**
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
- **See `OAUTH_SETUP.md` for other providers** (Okta, Keycloak, Azure AD).
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
- You should see:
99
- ```
100
- 🚀 OAuth discovery server running at http://localhost:3005
101
- NITRO_LOG::{"level":"info","message":"🔐 OAuth 2.1 enabled"}
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
- ### 5. Complete OAuth Flow in Studio
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
- #### Open NitroStack Studio
117
- Navigate to `http://localhost:3000`
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
- #### Step 1: Discover OAuth Server
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
- #### Step 2: Enter Client Credentials
128
- 1. Scroll to **"2a. Use Existing Client"** section
129
- 2. **Client ID**: Paste your Auth0 Client ID
130
- 3. **Client Secret**: Paste your Auth0 Client Secret
131
- 4. Click **"Save Client Credentials"**
132
- 5. Should show: **Client credentials saved!**
133
-
134
- #### Step 3: Start OAuth Flow
135
- 1. Click **"Start Authorization Flow"**
136
- 2. ✅ You'll be redirected to Auth0 login page
137
- 3. **Login** with your Auth0 account
138
- 4. **Authorize** the application (grant requested scopes)
139
- 5. You'll be redirected back to Studio with a JWT token!
140
- 6. Token is automatically saved and ready to use
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
- | Tool | Description |
155
- |------|-------------|
156
- | `get_server_info` | Get server information |
80
+ ## 🛠️ Available Features
157
81
 
158
- ### Protected Tools (OAuth Required)
82
+ ### Health Check: `system`
159
83
 
160
- | Tool | Required Scopes | Description |
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
- ## 🏗️ Project Structure
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
- ## 🔐 OAuth 2.1 Implementation
93
+ ### Tool: `calculate`
185
94
 
186
- ### OAuthModule Configuration
95
+ Perform basic arithmetic operations:
187
96
 
188
97
  ```typescript
189
- // src/app.module.ts
190
- OAuthModule.forRoot({
191
- resourceUri: process.env.RESOURCE_URI!,
192
- authorizationServers: [process.env.AUTH_SERVER_URL!],
193
- scopesSupported: ['read', 'write', 'admin'],
194
- tokenIntrospectionEndpoint: process.env.INTROSPECTION_ENDPOINT,
195
- audience: process.env.TOKEN_AUDIENCE,
196
- issuer: process.env.TOKEN_ISSUER,
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
- ### OAuth Guard
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
- ### Scope-Based Access
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
- ## 🔑 Key Security Features
120
+ ### Resource: `calculator://operations`
223
121
 
224
- ### 1. Token Audience Binding (RFC 8707)
122
+ Lists all available operations with examples.
225
123
 
226
- **Critical for security!** Tokens are validated to ensure they were issued **specifically for your MCP server**.
124
+ ### Prompt: `calculator_help`
227
125
 
228
- ```typescript
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
- **Never forward OAuth tokens to other services!** Each service must have its own token.
240
-
241
- ```typescript
242
- // ❌ WRONG - Don't do this
243
- await upstreamAPI.call(headers: { Authorization: clientToken });
128
+ ## 🎨 Widgets
244
129
 
245
- // CORRECT - Use separate token
246
- const upstreamToken = await getTokenForUpstream();
247
- await upstreamAPI.call(headers: { Authorization: upstreamToken });
248
- ```
130
+ ### Calculator Result Widget
131
+ - Gradient background
132
+ - Operation icon
133
+ - Breakdown of numbers
134
+ - Beautiful animations
249
135
 
250
- ### 3. Scope Validation
136
+ ### Calculator Operations Widget
137
+ - Grid of all operations
138
+ - Color-coded by type
139
+ - Examples for each operation
251
140
 
252
- Fine-grained access control based on OAuth scopes:
141
+ ## 💡 Learning Path
253
142
 
254
- ```typescript
255
- // Automatically validates scopes
256
- @UseGuards(OAuthGuard, createScopeGuard(['read', 'write']))
257
- ```
143
+ This template is perfect for learning:
258
144
 
259
- ## 🧪 Testing with Studio
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
- ### Step 1: Start OAuth Flow
153
+ ## 🔧 Commands
262
154
 
263
- 1. **Auth Tab** → **OAuth 2.1**
264
- 2. Enter your MCP server URL
265
- 3. Click **"Discover & Register"**
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
- ### Step 2: Complete Authorization
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
- 1. Studio redirects to your OAuth provider
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
- ### Step 3: Test Tools
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
- 1. **Tools Tab** → Select a protected tool
277
- 2. Execute - Token is automatically included!
278
- 3. Try tools with different scope requirements
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
- ## 📚 Standards Compliance
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
- This template implements:
191
+ ## 🎓 Code Walkthrough
283
192
 
284
- - **OAuth 2.1** ([draft-ietf-oauth-v2-1-13](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13))
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
- Compatible with:
293
- - ✅ [MCP Specification](https://modelcontextprotocol.io/specification/draft/basic/authorization)
294
- - ✅ [OpenAI Apps SDK](https://developers.openai.com/apps-sdk/build/auth)
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
- ## 🔧 Configuration Options
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
- ### Required
216
+ ### 2. Resource Definition
299
217
 
300
- - `RESOURCE_URI` - Your MCP server's public URL
301
- - `AUTH_SERVER_URL` - Your OAuth provider's base URL
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
- ### Optional
231
+ ### 3. Prompt Definition
304
232
 
305
- - `TOKEN_AUDIENCE` - Expected audience (defaults to RESOURCE_URI)
306
- - `TOKEN_ISSUER` - Expected issuer (recommended for security)
307
- - `INTROSPECTION_ENDPOINT` - For opaque token validation
308
- - `INTROSPECTION_CLIENT_ID` - Introspection client credentials
309
- - `INTROSPECTION_CLIENT_SECRET` - Introspection client secret
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
- ## 🌐 Supported OAuth Providers
243
+ ### 4. Module Definition
312
244
 
313
- This template works with any RFC-compliant OAuth 2.1 provider:
245
+ ```typescript
246
+ @Module({
247
+ name: 'calculator',
248
+ controllers: [CalculatorTools, CalculatorResources, CalculatorPrompts]
249
+ })
250
+ export class CalculatorModule {}
251
+ ```
314
252
 
315
- - **Auth0** - Easiest for testing
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
- **See `OAUTH_SETUP.md` for provider-specific configuration guides.**
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
- ## 🚨 Common Issues
265
+ ## 🚀 Extend This Template
325
266
 
326
- ### "Received JWE (encrypted) token instead of JWT!"
267
+ ### Add More Operations
327
268
 
328
- **Symptoms:** Server logs show:
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
- **Fix:**
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
- ### "OAuth token validation failed: Token audience mismatch"
273
+ 1. Create a service to store calculations
274
+ 2. Add a `get_history` tool
275
+ 3. Create a history widget
341
276
 
342
- **Fix:** Ensure `RESOURCE_URI` and `TOKEN_AUDIENCE` in `.env` match the Auth0 API Identifier **EXACTLY**.
277
+ ### Add More Modules
343
278
 
344
279
  ```bash
345
- # .env
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
- ### "Application doesn't show in API's Machine to Machine tab"
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
- ### "Missing required environment variables"
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
- ### "Insufficient scope"
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
- **Fix:** Request the required scopes when authorizing in Studio:
292
+ ## 💡 Tips
371
293
 
372
- 1. Auth Tab OAuth 2.1
373
- 2. Check required scopes for the tool
374
- 3. Re-authorize with correct scopes
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
- ## 📖 Learn More
299
+ ## 🎉 What to Build
377
300
 
378
- - [MCP OAuth Specification](https://modelcontextprotocol.io/specification/draft/basic/authorization)
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
- ## 🎉 Ready to Build!
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
- This template provides a production-ready OAuth 2.1 implementation. Customize it for your needs:
309
+ ---
387
310
 
388
- 1. Add your own tools with appropriate scopes
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
- **Happy coding! 🚀**
313
+ Start simple, learn the patterns, then build something amazing!
394
314