nitrostack 1.0.23 → 1.0.24
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/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +3 -1
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/mcp-dev-wrapper.js +2 -1
- package/dist/cli/mcp-dev-wrapper.js.map +1 -1
- package/dist/core/app-decorator.d.ts.map +1 -1
- package/dist/core/app-decorator.js +24 -2
- package/dist/core/app-decorator.js.map +1 -1
- package/dist/core/di/container.d.ts.map +1 -1
- package/dist/core/di/container.js +14 -1
- package/dist/core/di/container.js.map +1 -1
- package/dist/core/oauth-module.d.ts +15 -42
- package/dist/core/oauth-module.d.ts.map +1 -1
- package/dist/core/oauth-module.js +130 -5
- package/dist/core/oauth-module.js.map +1 -1
- package/dist/core/server.d.ts +7 -1
- package/dist/core/server.d.ts.map +1 -1
- package/dist/core/server.js +99 -23
- package/dist/core/server.js.map +1 -1
- package/dist/core/transports/discovery-http-server.d.ts +13 -0
- package/dist/core/transports/discovery-http-server.d.ts.map +1 -0
- package/dist/core/transports/discovery-http-server.js +54 -0
- package/dist/core/transports/discovery-http-server.js.map +1 -0
- package/dist/core/transports/http-server.d.ts +6 -0
- package/dist/core/transports/http-server.d.ts.map +1 -1
- package/dist/core/transports/http-server.js +8 -0
- package/dist/core/transports/http-server.js.map +1 -1
- package/dist/core/transports/streamable-http.d.ts +5 -0
- package/dist/core/transports/streamable-http.d.ts.map +1 -1
- package/dist/core/transports/streamable-http.js +7 -0
- package/dist/core/transports/streamable-http.js.map +1 -1
- package/package.json +1 -1
- package/src/studio/app/api/auth/fetch-metadata/route.ts +2 -2
- package/src/studio/app/auth/page.tsx +16 -3
- package/src/studio/next.config.js +4 -0
- package/templates/typescript-auth/package.json +2 -1
- package/templates/typescript-auth/src/index.ts +6 -25
- package/templates/typescript-auth-api-key/package.json +3 -1
- package/templates/typescript-auth-api-key/src/index.ts +6 -26
- package/templates/typescript-oauth/.env.example +35 -24
- package/templates/typescript-oauth/OAUTH_SETUP.md +306 -120
- package/templates/typescript-oauth/README.md +75 -31
- package/templates/typescript-oauth/package.json +3 -1
- package/templates/typescript-oauth/src/index.ts +6 -27
- package/templates/typescript-starter/package.json +2 -1
- package/templates/typescript-starter/src/index.ts +6 -25
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "nitrostack dev",
|
|
8
8
|
"build": "nitrostack build",
|
|
9
|
-
"start": "nitrostack start",
|
|
9
|
+
"start": "npm run build && nitrostack start",
|
|
10
|
+
"start:prod": "nitrostack start",
|
|
10
11
|
"widget": "npm --prefix src/widgets",
|
|
11
12
|
"setup-db": "node --loader ts-node/esm src/db/setup.ts"
|
|
12
13
|
},
|
|
@@ -9,39 +9,20 @@
|
|
|
9
9
|
* - Production (NODE_ENV=production): Dual transport (STDIO + HTTP SSE)
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { config } from 'dotenv';
|
|
12
13
|
import { McpApplicationFactory } from 'nitrostack';
|
|
13
14
|
import { AppModule } from './app.module.js';
|
|
14
15
|
|
|
16
|
+
// Load environment variables from .env file
|
|
17
|
+
config();
|
|
18
|
+
|
|
15
19
|
/**
|
|
16
20
|
* Bootstrap the application
|
|
17
21
|
*/
|
|
18
22
|
async function bootstrap() {
|
|
19
|
-
// Create the MCP server
|
|
23
|
+
// Create and start the MCP server
|
|
20
24
|
const server = await McpApplicationFactory.create(AppModule);
|
|
21
|
-
|
|
22
|
-
// Determine transport based on environment
|
|
23
|
-
const isDevelopment = process.env.NODE_ENV === 'development' || !process.env.NODE_ENV;
|
|
24
|
-
|
|
25
|
-
if (isDevelopment) {
|
|
26
|
-
// Development: STDIO only (for local testing with MCP Inspector, Claude Desktop)
|
|
27
|
-
await server.start('stdio');
|
|
28
|
-
console.error('🚀 Server running in DEVELOPMENT mode (STDIO only)');
|
|
29
|
-
} else {
|
|
30
|
-
// Production: Dual transport (STDIO + HTTP SSE)
|
|
31
|
-
const port = parseInt(process.env.PORT || '3002');
|
|
32
|
-
const host = process.env.HOST || '0.0.0.0';
|
|
33
|
-
|
|
34
|
-
await server.start('dual', {
|
|
35
|
-
port,
|
|
36
|
-
host,
|
|
37
|
-
endpoint: '/mcp',
|
|
38
|
-
enableCors: process.env.ENABLE_CORS !== 'false', // Enable by default, disable with ENABLE_CORS=false
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
console.error('🚀 Server running in PRODUCTION mode (DUAL)');
|
|
42
|
-
console.error(` 📡 STDIO: Ready for direct connections`);
|
|
43
|
-
console.error(` 🌐 HTTP SSE: http://${host}:${port}/mcp`);
|
|
44
|
-
}
|
|
25
|
+
await server.start();
|
|
45
26
|
}
|
|
46
27
|
|
|
47
28
|
// Start the application
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "nitrostack dev",
|
|
8
8
|
"build": "nitrostack build",
|
|
9
|
-
"start": "nitrostack start",
|
|
9
|
+
"start": "npm run build && nitrostack start",
|
|
10
|
+
"start:prod": "nitrostack start",
|
|
10
11
|
"widget": "npm --prefix src/widgets"
|
|
11
12
|
},
|
|
12
13
|
"dependencies": {
|
|
14
|
+
"dotenv": "^16.4.5",
|
|
13
15
|
"nitrostack": "^1",
|
|
14
16
|
"zod": "^3.23.8"
|
|
15
17
|
},
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { config } from 'dotenv';
|
|
2
3
|
import { McpApplicationFactory } from 'nitrostack';
|
|
3
4
|
import { AppModule } from './app.module.js';
|
|
4
5
|
|
|
6
|
+
// Load environment variables from .env file
|
|
7
|
+
config();
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* API Key Authentication MCP Server
|
|
7
11
|
*
|
|
@@ -34,32 +38,8 @@ async function bootstrap() {
|
|
|
34
38
|
console.error(' - Protected tools require valid API key');
|
|
35
39
|
console.error(' - Public tools accessible without authentication\n');
|
|
36
40
|
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (isDevelopment) {
|
|
41
|
-
// Development: STDIO only (for local testing)
|
|
42
|
-
await app.start('stdio');
|
|
43
|
-
console.error('🚀 Server running in DEVELOPMENT mode (STDIO only)');
|
|
44
|
-
console.error(' Use MCP Inspector or Claude Desktop for testing\n');
|
|
45
|
-
} else {
|
|
46
|
-
// Production: Dual transport (STDIO + HTTP SSE)
|
|
47
|
-
const port = parseInt(process.env.PORT || '3002');
|
|
48
|
-
const host = process.env.HOST || '0.0.0.0';
|
|
49
|
-
|
|
50
|
-
await app.start('dual', {
|
|
51
|
-
port,
|
|
52
|
-
host,
|
|
53
|
-
endpoint: '/mcp',
|
|
54
|
-
enableCors: process.env.ENABLE_CORS !== 'false', // Enable by default, disable with ENABLE_CORS=false
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
console.error('🚀 Server running in PRODUCTION mode (DUAL)');
|
|
58
|
-
console.error(` 📡 STDIO: Ready for direct connections`);
|
|
59
|
-
console.error(` 🌐 HTTP SSE: http://${host}:${port}/mcp`);
|
|
60
|
-
console.error(' Open NitroStack Studio to test the server');
|
|
61
|
-
console.error(' Set your API key in Studio → Auth → API Key section\n');
|
|
62
|
-
}
|
|
41
|
+
// Start the server
|
|
42
|
+
await app.start();
|
|
63
43
|
|
|
64
44
|
} catch (error) {
|
|
65
45
|
console.error('❌ Failed to start server:', error);
|
|
@@ -1,59 +1,70 @@
|
|
|
1
1
|
# OAuth 2.1 MCP Server Configuration
|
|
2
2
|
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# TRANSPORT MODE (AUTO-CONFIGURED)
|
|
5
|
+
# =============================================================================
|
|
6
|
+
# When OAuth is configured, the server automatically runs in DUAL mode:
|
|
7
|
+
# - STDIO: For MCP protocol communication with Studio/Claude
|
|
8
|
+
# - HTTP: For OAuth metadata endpoints (/.well-known/oauth-protected-resource)
|
|
9
|
+
# Both transports run simultaneously on different channels.
|
|
10
|
+
|
|
3
11
|
# =============================================================================
|
|
4
12
|
# REQUIRED: Server Configuration
|
|
5
13
|
# =============================================================================
|
|
6
14
|
|
|
7
|
-
# Your MCP server's
|
|
8
|
-
# This MUST match the
|
|
9
|
-
#
|
|
10
|
-
|
|
15
|
+
# Your MCP server's resource URI (used for token audience binding - RFC 8707)
|
|
16
|
+
# ⚠️ CRITICAL: This MUST match EXACTLY the "API Identifier" in your OAuth provider
|
|
17
|
+
#
|
|
18
|
+
# For Auth0: Copy the "Identifier" from APIs → Your API → Settings
|
|
19
|
+
# For development: Can be any unique URI like https://mcplocal or http://localhost:3005
|
|
20
|
+
# For production: Use your actual domain like https://api.yourapp.com
|
|
21
|
+
#
|
|
22
|
+
# ⚠️ This value is used for:
|
|
23
|
+
# 1. Token audience validation (security critical!)
|
|
24
|
+
# 2. OAuth discovery metadata
|
|
25
|
+
# 3. The "audience" parameter sent to your OAuth provider
|
|
26
|
+
RESOURCE_URI=https://mcplocal
|
|
11
27
|
|
|
12
28
|
# Your OAuth 2.1 authorization server URL
|
|
13
29
|
# This is the base URL of your OAuth provider (Auth0, Okta, Keycloak, etc.)
|
|
14
30
|
# Example for Auth0: https://your-tenant.auth0.com
|
|
15
31
|
# Example for Okta: https://your-domain.okta.com
|
|
16
|
-
AUTH_SERVER_URL=https://
|
|
32
|
+
AUTH_SERVER_URL=https://your-tenant.auth0.com
|
|
17
33
|
|
|
18
34
|
# =============================================================================
|
|
19
35
|
# OPTIONAL: Token Configuration
|
|
20
36
|
# =============================================================================
|
|
21
37
|
|
|
22
38
|
# Expected token audience (defaults to RESOURCE_URI if not set)
|
|
23
|
-
# This MUST match the
|
|
24
|
-
TOKEN_AUDIENCE=https://
|
|
39
|
+
# ⚠️ This MUST match EXACTLY the RESOURCE_URI above
|
|
40
|
+
TOKEN_AUDIENCE=https://mcplocal
|
|
25
41
|
|
|
26
42
|
# Expected token issuer (recommended for security)
|
|
27
43
|
# This MUST match the issuer claim in access tokens
|
|
28
|
-
#
|
|
44
|
+
# ⚠️ For Auth0: Add trailing slash! https://your-tenant.auth0.com/
|
|
29
45
|
# Example for Okta: https://your-domain.okta.com/oauth2/default
|
|
30
|
-
TOKEN_ISSUER=https://
|
|
46
|
+
TOKEN_ISSUER=https://your-tenant.auth0.com/
|
|
31
47
|
|
|
32
|
-
# =============================================================================
|
|
33
|
-
# OPTIONAL: Token Introspection (for opaque tokens)
|
|
34
|
-
# =============================================================================
|
|
35
48
|
|
|
36
|
-
# If your OAuth provider issues opaque tokens (not JWTs), configure these:
|
|
37
49
|
|
|
38
|
-
# Token introspection endpoint (RFC 7662)
|
|
39
|
-
# Example for Auth0: https://your-tenant.auth0.com/oauth/token/introspection
|
|
40
|
-
# Example for Okta: https://your-domain.okta.com/oauth2/default/v1/introspect
|
|
41
|
-
# INTROSPECTION_ENDPOINT=https://auth.example.com/oauth/introspect
|
|
42
50
|
|
|
43
|
-
# Client credentials for introspection
|
|
44
|
-
# These are separate from your MCP client credentials
|
|
45
|
-
# INTROSPECTION_CLIENT_ID=your-introspection-client-id
|
|
46
|
-
# INTROSPECTION_CLIENT_SECRET=your-introspection-client-secret
|
|
47
51
|
|
|
48
52
|
# =============================================================================
|
|
49
53
|
# Provider-Specific Examples
|
|
50
54
|
# =============================================================================
|
|
51
55
|
|
|
52
|
-
# --- Auth0 Example ---
|
|
53
|
-
#
|
|
56
|
+
# --- Auth0 Example (RECOMMENDED FOR TESTING) ---
|
|
57
|
+
# Step 1: Create API in Auth0 with Identifier = https://mcplocal
|
|
58
|
+
# Step 2: Create "Regular Web Application" in Auth0
|
|
59
|
+
# Step 3: Authorize the Application to access the API
|
|
60
|
+
# Step 4: Use these settings:
|
|
61
|
+
#
|
|
62
|
+
# RESOURCE_URI=https://mcplocal
|
|
54
63
|
# AUTH_SERVER_URL=https://your-tenant.auth0.com
|
|
55
|
-
# TOKEN_AUDIENCE=https://
|
|
64
|
+
# TOKEN_AUDIENCE=https://mcplocal
|
|
56
65
|
# TOKEN_ISSUER=https://your-tenant.auth0.com/
|
|
66
|
+
#
|
|
67
|
+
# ⚠️ CRITICAL: RESOURCE_URI must match Auth0 API Identifier EXACTLY!
|
|
57
68
|
|
|
58
69
|
# --- Okta Example ---
|
|
59
70
|
# RESOURCE_URI=https://mcp.yourapp.com
|