nitrostack 1.0.0

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 (290) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/CONTRIBUTING.md +182 -0
  3. package/LICENSE +201 -0
  4. package/LICENSE_URLS_UPDATE_COMPLETE.md +388 -0
  5. package/NOTICE +153 -0
  6. package/README.md +571 -0
  7. package/dist/auth/api-key.d.ts +118 -0
  8. package/dist/auth/api-key.d.ts.map +1 -0
  9. package/dist/auth/api-key.js +168 -0
  10. package/dist/auth/api-key.js.map +1 -0
  11. package/dist/auth/client.d.ts +151 -0
  12. package/dist/auth/client.d.ts.map +1 -0
  13. package/dist/auth/client.js +330 -0
  14. package/dist/auth/client.js.map +1 -0
  15. package/dist/auth/index.d.ts +30 -0
  16. package/dist/auth/index.d.ts.map +1 -0
  17. package/dist/auth/index.js +43 -0
  18. package/dist/auth/index.js.map +1 -0
  19. package/dist/auth/middleware.d.ts +95 -0
  20. package/dist/auth/middleware.d.ts.map +1 -0
  21. package/dist/auth/middleware.js +260 -0
  22. package/dist/auth/middleware.js.map +1 -0
  23. package/dist/auth/pkce.d.ts +53 -0
  24. package/dist/auth/pkce.d.ts.map +1 -0
  25. package/dist/auth/pkce.js +105 -0
  26. package/dist/auth/pkce.js.map +1 -0
  27. package/dist/auth/quick-setup.d.ts +94 -0
  28. package/dist/auth/quick-setup.d.ts.map +1 -0
  29. package/dist/auth/quick-setup.js +210 -0
  30. package/dist/auth/quick-setup.js.map +1 -0
  31. package/dist/auth/server-integration.d.ts +97 -0
  32. package/dist/auth/server-integration.d.ts.map +1 -0
  33. package/dist/auth/server-integration.js +182 -0
  34. package/dist/auth/server-integration.js.map +1 -0
  35. package/dist/auth/server-metadata.d.ts +51 -0
  36. package/dist/auth/server-metadata.d.ts.map +1 -0
  37. package/dist/auth/server-metadata.js +106 -0
  38. package/dist/auth/server-metadata.js.map +1 -0
  39. package/dist/auth/simple-jwt.d.ts +88 -0
  40. package/dist/auth/simple-jwt.d.ts.map +1 -0
  41. package/dist/auth/simple-jwt.js +152 -0
  42. package/dist/auth/simple-jwt.js.map +1 -0
  43. package/dist/auth/token-store.d.ts +104 -0
  44. package/dist/auth/token-store.d.ts.map +1 -0
  45. package/dist/auth/token-store.js +205 -0
  46. package/dist/auth/token-store.js.map +1 -0
  47. package/dist/auth/token-validation.d.ts +47 -0
  48. package/dist/auth/token-validation.d.ts.map +1 -0
  49. package/dist/auth/token-validation.js +237 -0
  50. package/dist/auth/token-validation.js.map +1 -0
  51. package/dist/auth/types.d.ts +215 -0
  52. package/dist/auth/types.d.ts.map +1 -0
  53. package/dist/auth/types.js +6 -0
  54. package/dist/auth/types.js.map +1 -0
  55. package/dist/cli/commands/build.d.ts +6 -0
  56. package/dist/cli/commands/build.d.ts.map +1 -0
  57. package/dist/cli/commands/build.js +104 -0
  58. package/dist/cli/commands/build.js.map +1 -0
  59. package/dist/cli/commands/dev.d.ts +7 -0
  60. package/dist/cli/commands/dev.d.ts.map +1 -0
  61. package/dist/cli/commands/dev.js +312 -0
  62. package/dist/cli/commands/dev.js.map +1 -0
  63. package/dist/cli/commands/generate-types.d.ts +8 -0
  64. package/dist/cli/commands/generate-types.d.ts.map +1 -0
  65. package/dist/cli/commands/generate-types.js +220 -0
  66. package/dist/cli/commands/generate-types.js.map +1 -0
  67. package/dist/cli/commands/generate.d.ts +5 -0
  68. package/dist/cli/commands/generate.d.ts.map +1 -0
  69. package/dist/cli/commands/generate.js +365 -0
  70. package/dist/cli/commands/generate.js.map +1 -0
  71. package/dist/cli/commands/init.d.ts +7 -0
  72. package/dist/cli/commands/init.d.ts.map +1 -0
  73. package/dist/cli/commands/init.js +365 -0
  74. package/dist/cli/commands/init.js.map +1 -0
  75. package/dist/cli/commands/start.d.ts +6 -0
  76. package/dist/cli/commands/start.d.ts.map +1 -0
  77. package/dist/cli/commands/start.js +61 -0
  78. package/dist/cli/commands/start.js.map +1 -0
  79. package/dist/cli/index.d.ts +3 -0
  80. package/dist/cli/index.d.ts.map +1 -0
  81. package/dist/cli/index.js +47 -0
  82. package/dist/cli/index.js.map +1 -0
  83. package/dist/cli/mcp-dev-wrapper.d.ts +3 -0
  84. package/dist/cli/mcp-dev-wrapper.d.ts.map +1 -0
  85. package/dist/cli/mcp-dev-wrapper.js +116 -0
  86. package/dist/cli/mcp-dev-wrapper.js.map +1 -0
  87. package/dist/core/apikey-module.d.ts +69 -0
  88. package/dist/core/apikey-module.d.ts.map +1 -0
  89. package/dist/core/apikey-module.js +114 -0
  90. package/dist/core/apikey-module.js.map +1 -0
  91. package/dist/core/app-decorator.d.ts +58 -0
  92. package/dist/core/app-decorator.d.ts.map +1 -0
  93. package/dist/core/app-decorator.js +261 -0
  94. package/dist/core/app-decorator.js.map +1 -0
  95. package/dist/core/builders.d.ts +38 -0
  96. package/dist/core/builders.d.ts.map +1 -0
  97. package/dist/core/builders.js +129 -0
  98. package/dist/core/builders.js.map +1 -0
  99. package/dist/core/component.d.ts +105 -0
  100. package/dist/core/component.d.ts.map +1 -0
  101. package/dist/core/component.js +182 -0
  102. package/dist/core/component.js.map +1 -0
  103. package/dist/core/config-module.d.ts +55 -0
  104. package/dist/core/config-module.d.ts.map +1 -0
  105. package/dist/core/config-module.js +94 -0
  106. package/dist/core/config-module.js.map +1 -0
  107. package/dist/core/decorators/cache.decorator.d.ts +61 -0
  108. package/dist/core/decorators/cache.decorator.d.ts.map +1 -0
  109. package/dist/core/decorators/cache.decorator.js +115 -0
  110. package/dist/core/decorators/cache.decorator.js.map +1 -0
  111. package/dist/core/decorators/health-check.decorator.d.ts +80 -0
  112. package/dist/core/decorators/health-check.decorator.d.ts.map +1 -0
  113. package/dist/core/decorators/health-check.decorator.js +153 -0
  114. package/dist/core/decorators/health-check.decorator.js.map +1 -0
  115. package/dist/core/decorators/rate-limit.decorator.d.ts +62 -0
  116. package/dist/core/decorators/rate-limit.decorator.d.ts.map +1 -0
  117. package/dist/core/decorators/rate-limit.decorator.js +129 -0
  118. package/dist/core/decorators/rate-limit.decorator.js.map +1 -0
  119. package/dist/core/decorators.d.ts +151 -0
  120. package/dist/core/decorators.d.ts.map +1 -0
  121. package/dist/core/decorators.js +142 -0
  122. package/dist/core/decorators.js.map +1 -0
  123. package/dist/core/di/container.d.ts +42 -0
  124. package/dist/core/di/container.d.ts.map +1 -0
  125. package/dist/core/di/container.js +76 -0
  126. package/dist/core/di/container.js.map +1 -0
  127. package/dist/core/di/injectable.decorator.d.ts +35 -0
  128. package/dist/core/di/injectable.decorator.d.ts.map +1 -0
  129. package/dist/core/di/injectable.decorator.js +57 -0
  130. package/dist/core/di/injectable.decorator.js.map +1 -0
  131. package/dist/core/errors.d.ts +54 -0
  132. package/dist/core/errors.d.ts.map +1 -0
  133. package/dist/core/errors.js +87 -0
  134. package/dist/core/errors.js.map +1 -0
  135. package/dist/core/events/event-emitter.d.ts +50 -0
  136. package/dist/core/events/event-emitter.d.ts.map +1 -0
  137. package/dist/core/events/event-emitter.js +94 -0
  138. package/dist/core/events/event-emitter.js.map +1 -0
  139. package/dist/core/events/event.decorator.d.ts +48 -0
  140. package/dist/core/events/event.decorator.d.ts.map +1 -0
  141. package/dist/core/events/event.decorator.js +68 -0
  142. package/dist/core/events/event.decorator.js.map +1 -0
  143. package/dist/core/filters/exception-filter.decorator.d.ts +40 -0
  144. package/dist/core/filters/exception-filter.decorator.d.ts.map +1 -0
  145. package/dist/core/filters/exception-filter.decorator.js +54 -0
  146. package/dist/core/filters/exception-filter.decorator.js.map +1 -0
  147. package/dist/core/filters/exception-filter.interface.d.ts +30 -0
  148. package/dist/core/filters/exception-filter.interface.d.ts.map +1 -0
  149. package/dist/core/filters/exception-filter.interface.js +2 -0
  150. package/dist/core/filters/exception-filter.interface.js.map +1 -0
  151. package/dist/core/guards/apikey.guard.d.ts +22 -0
  152. package/dist/core/guards/apikey.guard.d.ts.map +1 -0
  153. package/dist/core/guards/apikey.guard.js +11 -0
  154. package/dist/core/guards/apikey.guard.js.map +1 -0
  155. package/dist/core/guards/guard.interface.d.ts +18 -0
  156. package/dist/core/guards/guard.interface.d.ts.map +1 -0
  157. package/dist/core/guards/guard.interface.js +2 -0
  158. package/dist/core/guards/guard.interface.js.map +1 -0
  159. package/dist/core/guards/jwt.guard.d.ts +18 -0
  160. package/dist/core/guards/jwt.guard.d.ts.map +1 -0
  161. package/dist/core/guards/jwt.guard.js +2 -0
  162. package/dist/core/guards/jwt.guard.js.map +1 -0
  163. package/dist/core/guards/oauth.guard.d.ts +35 -0
  164. package/dist/core/guards/oauth.guard.d.ts.map +1 -0
  165. package/dist/core/guards/oauth.guard.js +2 -0
  166. package/dist/core/guards/oauth.guard.js.map +1 -0
  167. package/dist/core/guards/use-guards.decorator.d.ts +25 -0
  168. package/dist/core/guards/use-guards.decorator.d.ts.map +1 -0
  169. package/dist/core/guards/use-guards.decorator.js +32 -0
  170. package/dist/core/guards/use-guards.decorator.js.map +1 -0
  171. package/dist/core/health/health-checks.resource.d.ts +14 -0
  172. package/dist/core/health/health-checks.resource.d.ts.map +1 -0
  173. package/dist/core/health/health-checks.resource.js +29 -0
  174. package/dist/core/health/health-checks.resource.js.map +1 -0
  175. package/dist/core/index.d.ts +55 -0
  176. package/dist/core/index.d.ts.map +1 -0
  177. package/dist/core/index.js +57 -0
  178. package/dist/core/index.js.map +1 -0
  179. package/dist/core/interceptors/interceptor.decorator.d.ts +37 -0
  180. package/dist/core/interceptors/interceptor.decorator.d.ts.map +1 -0
  181. package/dist/core/interceptors/interceptor.decorator.js +51 -0
  182. package/dist/core/interceptors/interceptor.decorator.js.map +1 -0
  183. package/dist/core/interceptors/interceptor.interface.d.ts +31 -0
  184. package/dist/core/interceptors/interceptor.interface.d.ts.map +1 -0
  185. package/dist/core/interceptors/interceptor.interface.js +2 -0
  186. package/dist/core/interceptors/interceptor.interface.js.map +1 -0
  187. package/dist/core/jwt-module.d.ts +51 -0
  188. package/dist/core/jwt-module.d.ts.map +1 -0
  189. package/dist/core/jwt-module.js +52 -0
  190. package/dist/core/jwt-module.js.map +1 -0
  191. package/dist/core/logger.d.ts +18 -0
  192. package/dist/core/logger.d.ts.map +1 -0
  193. package/dist/core/logger.js +51 -0
  194. package/dist/core/logger.js.map +1 -0
  195. package/dist/core/middleware/middleware.decorator.d.ts +39 -0
  196. package/dist/core/middleware/middleware.decorator.d.ts.map +1 -0
  197. package/dist/core/middleware/middleware.decorator.js +53 -0
  198. package/dist/core/middleware/middleware.decorator.js.map +1 -0
  199. package/dist/core/middleware/middleware.interface.d.ts +29 -0
  200. package/dist/core/middleware/middleware.interface.d.ts.map +1 -0
  201. package/dist/core/middleware/middleware.interface.js +2 -0
  202. package/dist/core/middleware/middleware.interface.js.map +1 -0
  203. package/dist/core/module.d.ts +74 -0
  204. package/dist/core/module.d.ts.map +1 -0
  205. package/dist/core/module.js +82 -0
  206. package/dist/core/module.js.map +1 -0
  207. package/dist/core/oauth-module.d.ts +144 -0
  208. package/dist/core/oauth-module.d.ts.map +1 -0
  209. package/dist/core/oauth-module.js +190 -0
  210. package/dist/core/oauth-module.js.map +1 -0
  211. package/dist/core/pipes/pipe.decorator.d.ts +55 -0
  212. package/dist/core/pipes/pipe.decorator.d.ts.map +1 -0
  213. package/dist/core/pipes/pipe.decorator.js +85 -0
  214. package/dist/core/pipes/pipe.decorator.js.map +1 -0
  215. package/dist/core/pipes/pipe.interface.d.ts +36 -0
  216. package/dist/core/pipes/pipe.interface.d.ts.map +1 -0
  217. package/dist/core/pipes/pipe.interface.js +2 -0
  218. package/dist/core/pipes/pipe.interface.js.map +1 -0
  219. package/dist/core/prompt.d.ts +37 -0
  220. package/dist/core/prompt.d.ts.map +1 -0
  221. package/dist/core/prompt.js +76 -0
  222. package/dist/core/prompt.js.map +1 -0
  223. package/dist/core/resource.d.ts +42 -0
  224. package/dist/core/resource.d.ts.map +1 -0
  225. package/dist/core/resource.js +90 -0
  226. package/dist/core/resource.js.map +1 -0
  227. package/dist/core/server.d.ts +72 -0
  228. package/dist/core/server.d.ts.map +1 -0
  229. package/dist/core/server.js +406 -0
  230. package/dist/core/server.js.map +1 -0
  231. package/dist/core/tool.d.ts +78 -0
  232. package/dist/core/tool.d.ts.map +1 -0
  233. package/dist/core/tool.js +190 -0
  234. package/dist/core/tool.js.map +1 -0
  235. package/dist/core/transports/http-server.d.ts +102 -0
  236. package/dist/core/transports/http-server.d.ts.map +1 -0
  237. package/dist/core/transports/http-server.js +265 -0
  238. package/dist/core/transports/http-server.js.map +1 -0
  239. package/dist/core/types.d.ts +123 -0
  240. package/dist/core/types.d.ts.map +1 -0
  241. package/dist/core/types.js +2 -0
  242. package/dist/core/types.js.map +1 -0
  243. package/dist/core/widgets/widget-examples.resource.d.ts +17 -0
  244. package/dist/core/widgets/widget-examples.resource.d.ts.map +1 -0
  245. package/dist/core/widgets/widget-examples.resource.js +28 -0
  246. package/dist/core/widgets/widget-examples.resource.js.map +1 -0
  247. package/dist/core/widgets/widget-registry.d.ts +56 -0
  248. package/dist/core/widgets/widget-registry.d.ts.map +1 -0
  249. package/dist/core/widgets/widget-registry.js +75 -0
  250. package/dist/core/widgets/widget-registry.js.map +1 -0
  251. package/dist/testing/index.d.ts +82 -0
  252. package/dist/testing/index.d.ts.map +1 -0
  253. package/dist/testing/index.js +164 -0
  254. package/dist/testing/index.js.map +1 -0
  255. package/dist/ui-next/index.d.ts +31 -0
  256. package/dist/ui-next/index.d.ts.map +1 -0
  257. package/dist/ui-next/index.js +687 -0
  258. package/dist/ui-next/index.js.map +1 -0
  259. package/dist/widgets/index.d.ts +9 -0
  260. package/dist/widgets/index.d.ts.map +1 -0
  261. package/dist/widgets/index.js +9 -0
  262. package/dist/widgets/index.js.map +1 -0
  263. package/dist/widgets/metadata.d.ts +53 -0
  264. package/dist/widgets/metadata.d.ts.map +1 -0
  265. package/dist/widgets/metadata.js +29 -0
  266. package/dist/widgets/metadata.js.map +1 -0
  267. package/dist/widgets/withToolData.d.ts +19 -0
  268. package/dist/widgets/withToolData.d.ts.map +1 -0
  269. package/dist/widgets/withToolData.js +240 -0
  270. package/dist/widgets/withToolData.js.map +1 -0
  271. package/jest.config.js +21 -0
  272. package/package.json +108 -0
  273. package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +702 -0
  274. package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +1260 -0
  275. package/templates/typescript-auth/README.md +400 -0
  276. package/templates/typescript-auth/package.json +44 -0
  277. package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +701 -0
  278. package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +1260 -0
  279. package/templates/typescript-auth-api-key/README.md +483 -0
  280. package/templates/typescript-auth-api-key/package-lock.json +124 -0
  281. package/templates/typescript-auth-api-key/package.json +29 -0
  282. package/templates/typescript-oauth/AI_AGENT_CLI_REFERENCE.md +701 -0
  283. package/templates/typescript-oauth/AI_AGENT_SDK_REFERENCE.md +1260 -0
  284. package/templates/typescript-oauth/OAUTH_SETUP.md +406 -0
  285. package/templates/typescript-oauth/README.md +350 -0
  286. package/templates/typescript-oauth/package.json +30 -0
  287. package/templates/typescript-starter/AI_AGENT_CLI_REFERENCE.md +701 -0
  288. package/templates/typescript-starter/AI_AGENT_SDK_REFERENCE.md +1260 -0
  289. package/templates/typescript-starter/README.md +312 -0
  290. package/templates/typescript-starter/package.json +32 -0
@@ -0,0 +1,406 @@
1
+ # Complete OAuth 2.1 Setup Guide for NitroStack
2
+
3
+ This guide shows you **exactly** how to set up OAuth 2.1 authentication from scratch, test it in NitroStack Studio, and deploy it to production.
4
+
5
+ ## 🎯 What You'll Learn
6
+
7
+ - ✅ How to configure Auth0 (or other OAuth providers)
8
+ - ✅ How to set up your MCP server environment
9
+ - ✅ How to test the complete OAuth flow in Studio
10
+ - ✅ How to troubleshoot common issues
11
+
12
+ ---
13
+
14
+ ## 🚀 Quick Start with Auth0 (5 Minutes)
15
+
16
+ ### Why Auth0?
17
+ - ✅ **Free tier** (7,000 active users, no credit card)
18
+ - ✅ **Fastest setup** (5 minutes)
19
+ - ✅ **Best for testing** and learning
20
+ - ✅ **Production-ready** when you need it
21
+
22
+ ---
23
+
24
+ ## Step 1: Create Auth0 Account
25
+
26
+ 1. Go to **[auth0.com/signup](https://auth0.com/signup)**
27
+ 2. Sign up for free (choose "Personal" plan)
28
+ 3. Complete email verification
29
+
30
+ ---
31
+
32
+ ## Step 2: Create Auth0 Application
33
+
34
+ This represents NitroStack Studio as an OAuth client.
35
+
36
+ 1. Open **Auth0 Dashboard** → **Applications** → **Applications**
37
+ 2. Click **"Create Application"**
38
+ 3. **Settings:**
39
+ ```
40
+ Name: NitroStack Studio
41
+ Application Type: Regular Web Application
42
+ ```
43
+ 4. Click **"Create"**
44
+
45
+ 5. Go to **Settings** tab and configure:
46
+ ```
47
+ Allowed Callback URLs:
48
+ http://localhost:3000/auth/callback
49
+
50
+ Allowed Logout URLs:
51
+ http://localhost:3000
52
+
53
+ Allowed Web Origins:
54
+ http://localhost:3000
55
+
56
+ Grant Types:
57
+ ☑ Authorization Code
58
+ ☑ Refresh Token
59
+ ```
60
+
61
+ 6. **Save Changes**
62
+
63
+ 7. **Copy these values** (you'll need them later):
64
+ - **Domain** (e.g., `dev-abc123.us.auth0.com`)
65
+ - **Client ID** (e.g., `aBc123XyZ...`)
66
+ - **Client Secret** (click "Reveal Auth0 Management API" to see it)
67
+
68
+ ---
69
+
70
+ ## Step 3: Create Auth0 API
71
+
72
+ This represents your MCP server as a protected resource.
73
+
74
+ 1. Go to **Applications** → **APIs**
75
+ 2. Click **"Create API"**
76
+ 3. **Settings:**
77
+ ```
78
+ Name: NitroStack MCP Server
79
+ Identifier: http://localhost:3002
80
+ Signing Algorithm: RS256
81
+ ```
82
+ **Important:** The Identifier MUST match your server's `RESOURCE_URI`
83
+
84
+ 4. Click **"Create"**
85
+
86
+ 5. Go to **Permissions** tab
87
+ 6. Add these scopes:
88
+ ```
89
+ Scope Description
90
+ ----- -----------
91
+ read Read access to resources
92
+ write Write/modify resources
93
+ admin Administrative operations
94
+ ```
95
+
96
+ 7. Click **"Add"** for each scope
97
+
98
+ ---
99
+
100
+ ## Step 4: Configure Your MCP Server
101
+
102
+ ### Edit `.env` File
103
+
104
+ Replace the values with your Auth0 settings from Steps 2 & 3:
105
+
106
+ ```bash
107
+ # =============================================================================
108
+ # REQUIRED: Server Configuration
109
+ # =============================================================================
110
+
111
+ # Your MCP server's public URL (matches API Identifier from Step 3)
112
+ RESOURCE_URI=http://localhost:3002
113
+
114
+ # Your Auth0 domain (from Step 2)
115
+ AUTH_SERVER_URL=https://dev-abc123.us.auth0.com
116
+
117
+ # =============================================================================
118
+ # OPTIONAL: Token Configuration
119
+ # =============================================================================
120
+
121
+ # Expected token audience (must match API Identifier)
122
+ TOKEN_AUDIENCE=http://localhost:3002
123
+
124
+ # Expected token issuer (Auth0 domain with trailing slash)
125
+ TOKEN_ISSUER=https://dev-abc123.us.auth0.com/
126
+ ```
127
+
128
+ **⚠️ Important:** Replace `dev-abc123` with YOUR actual Auth0 domain!
129
+
130
+ ---
131
+
132
+ ## Step 5: Start Your MCP Server
133
+
134
+ ```bash
135
+ npm install
136
+ npm run dev
137
+ ```
138
+
139
+ **Expected Output:**
140
+ ```
141
+ 🌐 HTTP MCP Server listening on http://0.0.0.0:3002/mcp
142
+ 🔐 OAuth 2.1 enabled
143
+ Resource URI: http://localhost:3002
144
+ Auth Servers: https://dev-abc123.us.auth0.com
145
+ Metadata: http://0.0.0.0:3002/.well-known/oauth-protected-resource
146
+ 🚀 Server started successfully (DUAL: STDIO + HTTP)
147
+ 📡 MCP Protocol: STDIO (for Studio/Claude)
148
+ 🌐 OAuth Metadata: HTTP (port 3002)
149
+ ```
150
+
151
+ **✅ Success!** Your server is running in DUAL mode:
152
+ - **STDIO**: For MCP protocol communication (tools, chat)
153
+ - **HTTP**: For OAuth metadata and discovery
154
+
155
+ ---
156
+
157
+ ## Step 6: Test OAuth Flow in NitroStack Studio
158
+
159
+ ### Open Studio
160
+
161
+ Navigate to **http://localhost:3000** in your browser
162
+
163
+ ### 6.1 Discover OAuth Server
164
+
165
+ 1. Go to **Auth** → **OAuth 2.1** tab
166
+ 2. In the **"Discover Server Auth"** section:
167
+ ```
168
+ Server URL: http://localhost:3002
169
+ ```
170
+ 3. Click **"Discover Auth Config"**
171
+
172
+ **Expected Result:**
173
+ ```
174
+ ✅ Discovery Successful
175
+
176
+ Resource: http://localhost:3002
177
+ Authorization Servers: https://dev-abc123.us.auth0.com
178
+ Scopes: read, write, admin
179
+ ```
180
+
181
+ ### 6.2 Enter Client Credentials
182
+
183
+ 1. Scroll to **"2a. Use Existing Client"** section
184
+ 2. Enter your credentials from Step 2:
185
+ ```
186
+ Client ID: [Your Auth0 Client ID]
187
+ Client Secret: [Your Auth0 Client Secret]
188
+ ```
189
+ 3. Click **"Save Client Credentials"**
190
+
191
+ **Expected Result:**
192
+ ```
193
+ ✅ Client credentials saved!
194
+ ```
195
+
196
+ ### 6.3 Start OAuth Flow
197
+
198
+ 1. Scroll to **"3. Start OAuth Flow"** section
199
+ 2. Click **"Start Authorization Flow"**
200
+
201
+ **What Happens:**
202
+ 1. ✅ You're redirected to Auth0 login page
203
+ 2. ✅ Login with your Auth0 account
204
+ 3. ✅ You're asked to authorize the application
205
+ 4. ✅ After authorization, you're redirected back to Studio
206
+ 5. ✅ Studio exchanges the code for a JWT token
207
+ 6. ✅ Token is automatically saved!
208
+
209
+ **Expected Result:**
210
+ ```
211
+ ✅ Authorization successful! Redirecting...
212
+ ```
213
+
214
+ ### 6.4 Test Protected Tools
215
+
216
+ 1. Go to **Tools** tab
217
+ 2. You should see all your MCP tools loaded
218
+ 3. Try a protected tool (e.g., `get_user_profile`, `list_resources`)
219
+ 4. Click **"Execute"**
220
+
221
+ **Expected Result:**
222
+ ```json
223
+ {
224
+ "success": true,
225
+ "user": {
226
+ "sub": "auth0|xxx",
227
+ "scopes": ["read", "write", "admin"]
228
+ }
229
+ }
230
+ ```
231
+
232
+ **🎉 Congratulations!** Your OAuth 2.1 server is fully working!
233
+
234
+ ---
235
+
236
+ ## 🔍 How It Works
237
+
238
+ ### Dual Transport Architecture
239
+
240
+ NitroStack runs **two transports simultaneously**:
241
+
242
+ ```
243
+ ┌─────────────────────────────────────┐
244
+ │ Your OAuth 2.1 MCP Server │
245
+ ├─────────────────────────────────────┤
246
+ │ │
247
+ │ 📡 STDIO Transport │
248
+ │ ├─ MCP Protocol (tools, chat) │
249
+ │ ├─ Connected to Studio/Claude │
250
+ │ └─ stdin/stdout communication │
251
+ │ │
252
+ │ 🌐 HTTP Server (Port 3002) │
253
+ │ ├─ OAuth Metadata Endpoints │
254
+ │ ├─ /.well-known/oauth-protected- │
255
+ │ │ resource │
256
+ │ └─ Discovery & Token Validation │
257
+ │ │
258
+ └─────────────────────────────────────┘
259
+ ```
260
+
261
+ ### OAuth Flow Sequence
262
+
263
+ ```
264
+ 1. Studio → Discover → Your MCP Server (HTTP)
265
+
266
+ Returns OAuth metadata
267
+
268
+ 2. Studio → Authorize → Auth0 Login Page
269
+
270
+ User logs in
271
+
272
+ 3. Auth0 → Redirect → Studio Callback (/auth/callback)
273
+
274
+ 4. Studio → Exchange → Auth0 Token Endpoint
275
+
276
+ Receives JWT token
277
+
278
+ 5. Studio → Execute Tool → Your MCP Server (STDIO)
279
+ (with JWT) ↓
280
+ Tool validates token & executes
281
+ ```
282
+
283
+ ---
284
+
285
+ ## 🚨 Troubleshooting
286
+
287
+ ### "Discovery failed: Cannot read properties of undefined"
288
+
289
+ **Cause:** Server URL is incorrect or server isn't running
290
+
291
+ **Fix:**
292
+ 1. Verify server is running: `lsof -i :3002`
293
+ 2. Check URL is exactly: `http://localhost:3002`
294
+ 3. Test metadata endpoint: `curl http://localhost:3002/.well-known/oauth-protected-resource`
295
+
296
+ ### "Token audience mismatch"
297
+
298
+ **Cause:** `RESOURCE_URI` doesn't match Auth0 API Identifier
299
+
300
+ **Fix:**
301
+ 1. In Auth0: Applications → APIs → Your API → Identifier
302
+ 2. In `.env`: `RESOURCE_URI` must match exactly
303
+ 3. In `.env`: `TOKEN_AUDIENCE` must match exactly
304
+
305
+ ### "Invalid token issuer"
306
+
307
+ **Cause:** `TOKEN_ISSUER` doesn't match token's `iss` claim
308
+
309
+ **Fix:**
310
+ 1. Check Auth0 domain in dashboard
311
+ 2. Add `https://` prefix
312
+ 3. Add trailing `/`
313
+ 4. Example: `https://dev-abc123.us.auth0.com/`
314
+
315
+ ### "Insufficient scope"
316
+
317
+ **Cause:** Token doesn't have required scopes for the tool
318
+
319
+ **Fix:**
320
+ 1. In Auth0: Applications → APIs → Your API → Permissions
321
+ 2. Add the required scopes
322
+ 3. Re-authorize in Studio (logout and login again)
323
+ 4. New token will have updated scopes
324
+
325
+ ### "Port 3002 already in use"
326
+
327
+ **Cause:** Previous server instance still running
328
+
329
+ **Fix:**
330
+ ```bash
331
+ # Kill process on port 3002
332
+ lsof -ti :3002 | xargs kill -9
333
+
334
+ # Restart server
335
+ npm run dev
336
+ ```
337
+
338
+ ---
339
+
340
+ ## 🌐 Other OAuth Providers
341
+
342
+ ### Okta
343
+
344
+ ```bash
345
+ RESOURCE_URI=https://mcp.yourapp.com
346
+ AUTH_SERVER_URL=https://your-domain.okta.com/oauth2/default
347
+ TOKEN_AUDIENCE=api://mcp.yourapp.com
348
+ TOKEN_ISSUER=https://your-domain.okta.com/oauth2/default
349
+ ```
350
+
351
+ ### Keycloak
352
+
353
+ ```bash
354
+ RESOURCE_URI=https://mcp.yourapp.com
355
+ AUTH_SERVER_URL=https://keycloak.yourapp.com/realms/your-realm
356
+ TOKEN_AUDIENCE=mcp-server
357
+ TOKEN_ISSUER=https://keycloak.yourapp.com/realms/your-realm
358
+ ```
359
+
360
+ ### Azure AD / Entra ID
361
+
362
+ ```bash
363
+ RESOURCE_URI=https://mcp.yourapp.com
364
+ AUTH_SERVER_URL=https://login.microsoftonline.com/YOUR-TENANT-ID/v2.0
365
+ TOKEN_AUDIENCE=api://YOUR-APP-ID
366
+ TOKEN_ISSUER=https://login.microsoftonline.com/YOUR-TENANT-ID/v2.0
367
+ ```
368
+
369
+ ---
370
+
371
+ ## 📚 Learn More
372
+
373
+ - [MCP OAuth Specification](https://modelcontextprotocol.io/specification/draft/basic/authorization)
374
+ - [OAuth 2.1 Draft](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13)
375
+ - [RFC 8707 - Resource Indicators](https://datatracker.ietf.org/doc/html/rfc8707)
376
+ - [RFC 9728 - Protected Resource Metadata](https://datatracker.ietf.org/doc/html/rfc9728)
377
+
378
+ ---
379
+
380
+ ## ✅ Checklist
381
+
382
+ Before asking for help, verify:
383
+
384
+ - [ ] Auth0 Application created with correct callback URLs
385
+ - [ ] Auth0 API created with correct identifier
386
+ - [ ] Scopes added to Auth0 API
387
+ - [ ] `.env` file configured with correct values
388
+ - [ ] Server starts successfully (check logs)
389
+ - [ ] HTTP metadata endpoint accessible: `curl http://localhost:3002/.well-known/oauth-protected-resource`
390
+ - [ ] Discovery works in Studio
391
+ - [ ] Client credentials saved in Studio
392
+ - [ ] OAuth flow completes successfully
393
+ - [ ] JWT token stored in Studio (check Auth tab)
394
+
395
+ **If all checkboxes are ✅ and it still doesn't work,** check the troubleshooting section above!
396
+
397
+ ---
398
+
399
+ **Need Help?** Open an issue on [GitHub](https://github.com/yourrepo/nitrostack/issues) with:
400
+ 1. Your Auth0 configuration (hide secrets!)
401
+ 2. Server logs
402
+ 3. Browser console errors
403
+ 4. Steps you've tried
404
+
405
+ Happy coding! 🚀
406
+