@nitrostack/cli 1.0.12 ā 1.0.13
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/commands/cursor.d.ts +11 -0
- package/dist/commands/cursor.d.ts.map +1 -0
- package/dist/commands/cursor.js +238 -0
- package/dist/commands/upgrade.d.ts +12 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +144 -106
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/package.json +3 -3
- package/templates/typescript-oauth/.env.example +71 -14
- package/templates/typescript-oauth/src/app.module.ts +7 -0
- package/templates/typescript-oauth/src/guards/oauth.guard.ts +19 -0
- package/templates/typescript-oauth/src/index.ts +9 -11
- package/templates/typescript-oauth/src/modules/flights/flights.prompts.ts +19 -1
- package/templates/typescript-oauth/src/services/duffel.service.ts +4 -2
- package/templates/typescript-pizzaz/.env.example +10 -0
- package/templates/typescript-starter/.env.example +10 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface CursorOptions {
|
|
2
|
+
global?: boolean;
|
|
3
|
+
local?: boolean;
|
|
4
|
+
type?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
port?: string;
|
|
7
|
+
force?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function cursorCommand(options: CursorOptions): Promise<void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/commands/cursor.ts"],"names":[],"mappings":"AAqBA,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAuBD,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAoOzE"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import { createHeader, createSuccessBox, createErrorBox, NitroSpinner, log, spacer, nextSteps, showFooter, NITRO_BANNER_FULL } from '../ui/branding.js';
|
|
7
|
+
import { trackEvent, shutdownAnalytics } from '../analytics/posthog.js';
|
|
8
|
+
/** Normalize CLI --type values, including the deprecated `sse` alias. */
|
|
9
|
+
function normalizeConnectionType(raw) {
|
|
10
|
+
if (!raw)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (raw === 'sse')
|
|
13
|
+
return 'legacy-sse';
|
|
14
|
+
if (raw === 'command' || raw === 'legacy-sse' || raw === 'streamable-http') {
|
|
15
|
+
return raw;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
function defaultHttpUrl(type, port) {
|
|
20
|
+
if (type === 'streamable-http') {
|
|
21
|
+
return `http://localhost:${port}/mcp`;
|
|
22
|
+
}
|
|
23
|
+
return `http://localhost:${port}/sse`;
|
|
24
|
+
}
|
|
25
|
+
function isHttpConnectionType(type) {
|
|
26
|
+
return type === 'legacy-sse' || type === 'streamable-http';
|
|
27
|
+
}
|
|
28
|
+
export async function cursorCommand(options) {
|
|
29
|
+
console.log(NITRO_BANNER_FULL);
|
|
30
|
+
console.log(createHeader('Cursor Integration', 'Configure MCP server in Cursor'));
|
|
31
|
+
const startTime = Date.now();
|
|
32
|
+
trackEvent('cli_command_invoked', {
|
|
33
|
+
command: 'cursor',
|
|
34
|
+
options: Object.keys(options).filter(k => options[k] !== undefined),
|
|
35
|
+
});
|
|
36
|
+
const projectRoot = process.cwd();
|
|
37
|
+
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
38
|
+
// Validate project
|
|
39
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
40
|
+
console.log(createErrorBox('Not a Valid Project', 'package.json not found in the current directory.'));
|
|
41
|
+
trackEvent('cli_cursor_failed', {
|
|
42
|
+
error: 'Not a valid project: package.json missing',
|
|
43
|
+
});
|
|
44
|
+
await shutdownAnalytics();
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
let packageJson;
|
|
48
|
+
try {
|
|
49
|
+
packageJson = await fs.readJson(packageJsonPath);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.log(createErrorBox('Invalid package.json', 'Could not parse project package.json.'));
|
|
53
|
+
trackEvent('cli_cursor_failed', {
|
|
54
|
+
error: 'Invalid package.json parsing error',
|
|
55
|
+
});
|
|
56
|
+
await shutdownAnalytics();
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
const rawName = packageJson.name || path.basename(projectRoot);
|
|
60
|
+
const serverName = rawName.includes('/') ? rawName.split('/').pop() : rawName;
|
|
61
|
+
let target;
|
|
62
|
+
if (options.global) {
|
|
63
|
+
target = 'global';
|
|
64
|
+
}
|
|
65
|
+
else if (options.local) {
|
|
66
|
+
target = 'local';
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const answers = await inquirer.prompt([
|
|
70
|
+
{
|
|
71
|
+
type: 'list',
|
|
72
|
+
name: 'target',
|
|
73
|
+
message: chalk.white('Where would you like to install the Cursor MCP configuration?'),
|
|
74
|
+
choices: [
|
|
75
|
+
{ name: `Project-level ${chalk.dim('(.cursor/mcp.json)')}`, value: 'local' },
|
|
76
|
+
{ name: `Global ${chalk.dim('(~/.cursor/mcp.json)')}`, value: 'global' },
|
|
77
|
+
],
|
|
78
|
+
default: 'local',
|
|
79
|
+
}
|
|
80
|
+
]);
|
|
81
|
+
target = answers.target;
|
|
82
|
+
}
|
|
83
|
+
let type = normalizeConnectionType(options.type);
|
|
84
|
+
if (options.type && !type) {
|
|
85
|
+
console.log(createErrorBox('Invalid connection type', `Unknown --type "${options.type}". Use: command, legacy-sse, or streamable-http.`));
|
|
86
|
+
await shutdownAnalytics();
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
if (!type) {
|
|
90
|
+
const answers = await inquirer.prompt([
|
|
91
|
+
{
|
|
92
|
+
type: 'list',
|
|
93
|
+
name: 'type',
|
|
94
|
+
message: chalk.white('Choose the connection type for Cursor:'),
|
|
95
|
+
choices: [
|
|
96
|
+
{ name: `Command (Stdio) ${chalk.dim('ā Starts subprocess (recommended for local dev)')}`, value: 'command' },
|
|
97
|
+
{ name: `Legacy SSE (/sse) ${chalk.dim('ā Cursor and older HTTP clients (recommended for Cursor)')}`, value: 'legacy-sse' },
|
|
98
|
+
{ name: `Streamable HTTP (/mcp) ${chalk.dim('ā MCP Inspector and modern Streamable HTTP clients')}`, value: 'streamable-http' },
|
|
99
|
+
],
|
|
100
|
+
default: 'command',
|
|
101
|
+
}
|
|
102
|
+
]);
|
|
103
|
+
type = answers.type;
|
|
104
|
+
}
|
|
105
|
+
if (!type) {
|
|
106
|
+
console.log(createErrorBox('Invalid connection type', 'No connection type selected.'));
|
|
107
|
+
await shutdownAnalytics();
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
const port = options.port || '3000';
|
|
111
|
+
let httpUrl = options.url;
|
|
112
|
+
if (isHttpConnectionType(type) && !httpUrl) {
|
|
113
|
+
const defaultUrl = defaultHttpUrl(type, port);
|
|
114
|
+
const urlHint = type === 'legacy-sse'
|
|
115
|
+
? chalk.dim('Default /sse; /mcp also works for Cursor (legacy SSE fallback on GET).')
|
|
116
|
+
: chalk.dim('For MCP Inspector and clients that use POST initialize + mcp-session-id.');
|
|
117
|
+
const answers = await inquirer.prompt([
|
|
118
|
+
{
|
|
119
|
+
type: 'input',
|
|
120
|
+
name: 'url',
|
|
121
|
+
message: chalk.white('HTTP connection URL:'),
|
|
122
|
+
default: defaultUrl,
|
|
123
|
+
}
|
|
124
|
+
]);
|
|
125
|
+
httpUrl = answers.url;
|
|
126
|
+
if (urlHint) {
|
|
127
|
+
console.log(urlHint);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
let configFilePath;
|
|
131
|
+
if (target === 'global') {
|
|
132
|
+
configFilePath = path.join(os.homedir(), '.cursor', 'mcp.json');
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
configFilePath = path.join(projectRoot, '.cursor', 'mcp.json');
|
|
136
|
+
}
|
|
137
|
+
let entry;
|
|
138
|
+
if (type === 'command') {
|
|
139
|
+
const absIndexPath = path.join(projectRoot, 'dist', 'index.js');
|
|
140
|
+
entry = {
|
|
141
|
+
command: 'node',
|
|
142
|
+
args: [absIndexPath],
|
|
143
|
+
env: {}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
entry = {
|
|
148
|
+
url: httpUrl
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const spinner = new NitroSpinner(`Configuring Cursor MCP server...`).start();
|
|
152
|
+
try {
|
|
153
|
+
await fs.ensureDir(path.dirname(configFilePath));
|
|
154
|
+
let mcpConfig = { mcpServers: {} };
|
|
155
|
+
if (await fs.pathExists(configFilePath)) {
|
|
156
|
+
try {
|
|
157
|
+
mcpConfig = await fs.readJson(configFilePath);
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
// Corrupted or empty file, initialize it
|
|
161
|
+
mcpConfig = { mcpServers: {} };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (!mcpConfig.mcpServers) {
|
|
165
|
+
mcpConfig.mcpServers = {};
|
|
166
|
+
}
|
|
167
|
+
// Check if it already exists
|
|
168
|
+
if (mcpConfig.mcpServers[serverName] && !options.force) {
|
|
169
|
+
spinner.stop();
|
|
170
|
+
const { overwrite } = await inquirer.prompt([
|
|
171
|
+
{
|
|
172
|
+
type: 'confirm',
|
|
173
|
+
name: 'overwrite',
|
|
174
|
+
message: chalk.yellow(`MCP Server "${serverName}" is already registered in Cursor config. Overwrite?`),
|
|
175
|
+
default: true,
|
|
176
|
+
}
|
|
177
|
+
]);
|
|
178
|
+
if (!overwrite) {
|
|
179
|
+
log('Cancelled integration', 'warning');
|
|
180
|
+
trackEvent('cli_cursor_cancelled', {
|
|
181
|
+
server_name: serverName,
|
|
182
|
+
target,
|
|
183
|
+
type,
|
|
184
|
+
});
|
|
185
|
+
await shutdownAnalytics();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
spinner.start();
|
|
189
|
+
}
|
|
190
|
+
mcpConfig.mcpServers[serverName] = entry;
|
|
191
|
+
await fs.writeJson(configFilePath, mcpConfig, { spaces: 2 });
|
|
192
|
+
spinner.succeed(`Registered "${serverName}" in Cursor config`);
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
spinner.fail('Failed to update Cursor configuration');
|
|
196
|
+
console.log(createErrorBox('Integration Failed', err instanceof Error ? err.message : String(err)));
|
|
197
|
+
trackEvent('cli_cursor_failed', {
|
|
198
|
+
error: err instanceof Error ? err.message : String(err),
|
|
199
|
+
target,
|
|
200
|
+
type,
|
|
201
|
+
});
|
|
202
|
+
await shutdownAnalytics();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
// Summary
|
|
206
|
+
spacer();
|
|
207
|
+
console.log(createSuccessBox('Cursor Integration Successful', [
|
|
208
|
+
`Configured target: ${chalk.cyan(configFilePath)}`,
|
|
209
|
+
`Server registered: ${chalk.cyan(serverName)}`,
|
|
210
|
+
`Connection type: ${chalk.cyan(type)}`,
|
|
211
|
+
type === 'command'
|
|
212
|
+
? `Command path: ${chalk.dim(path.join(projectRoot, 'dist', 'index.js'))}`
|
|
213
|
+
: `HTTP URL: ${chalk.cyan(httpUrl)}`
|
|
214
|
+
]));
|
|
215
|
+
if (type === 'command') {
|
|
216
|
+
// Check if dist/index.js exists
|
|
217
|
+
const distIndexPath = path.join(projectRoot, 'dist', 'index.js');
|
|
218
|
+
if (!fs.existsSync(distIndexPath)) {
|
|
219
|
+
log('Warning: dist/index.js not found. Remember to run "npm run build" first!', 'warning');
|
|
220
|
+
spacer();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (type === 'legacy-sse') {
|
|
224
|
+
log('Tip: ensure the server is running in dual or http mode before connecting from Cursor.', 'info');
|
|
225
|
+
}
|
|
226
|
+
nextSteps([
|
|
227
|
+
'Restart/Reload your Cursor window to load the new MCP server',
|
|
228
|
+
'Check active MCP servers in Cursor under Settings > Tools > MCP',
|
|
229
|
+
]);
|
|
230
|
+
showFooter();
|
|
231
|
+
trackEvent('cli_cursor_completed', {
|
|
232
|
+
target,
|
|
233
|
+
type,
|
|
234
|
+
server_name: serverName,
|
|
235
|
+
duration_ms: Date.now() - startTime,
|
|
236
|
+
});
|
|
237
|
+
await shutdownAnalytics();
|
|
238
|
+
}
|
|
@@ -2,6 +2,18 @@ interface UpgradeOptions {
|
|
|
2
2
|
latest?: boolean;
|
|
3
3
|
dryRun?: boolean;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* Fetch a package's latest published version from NPM using standard https module.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fetchLatestNpmVersion(packageName: string): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Compare two version strings
|
|
11
|
+
*/
|
|
12
|
+
export declare function compareVersions(v1: string, v2: string): number;
|
|
13
|
+
/**
|
|
14
|
+
* Determine if a dependency refers to a local file or workspace link.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isLocalDependency(version: string): boolean;
|
|
5
17
|
/**
|
|
6
18
|
* Main upgrade command handler
|
|
7
19
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AA2BA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAUD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgD1E;AA2BD;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAa9D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAM1D;AAqED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAsI3E"}
|
package/dist/commands/upgrade.js
CHANGED
|
@@ -2,22 +2,57 @@ import chalk from 'chalk';
|
|
|
2
2
|
import { execSync } from 'child_process';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
|
+
import https from 'https';
|
|
5
6
|
import { createHeader, createBox, createSuccessBox, createErrorBox, NitroSpinner, log, spacer, nextSteps, NITRO_BANNER_FULL, showFooter } from '../ui/branding.js';
|
|
6
7
|
import { trackEvent, shutdownAnalytics } from '../analytics/posthog.js';
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Fetch a package's latest published version from NPM using standard https module.
|
|
9
10
|
*/
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
export function fetchLatestNpmVersion(packageName) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const url = `https://registry.npmjs.org/${packageName}/latest`;
|
|
14
|
+
const req = https.get(url, {
|
|
15
|
+
headers: {
|
|
16
|
+
'Accept': 'application/json',
|
|
17
|
+
'User-Agent': 'nitrostack-cli-upgrade'
|
|
18
|
+
},
|
|
19
|
+
timeout: 5000
|
|
20
|
+
}, (res) => {
|
|
21
|
+
if (res.statusCode !== 200) {
|
|
22
|
+
reject(new Error(`Registry responded with HTTP ${res.statusCode}`));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let data = '';
|
|
26
|
+
res.on('data', (chunk) => {
|
|
27
|
+
data += chunk;
|
|
28
|
+
});
|
|
29
|
+
// Handle stream errors
|
|
30
|
+
res.on('error', (err) => {
|
|
31
|
+
reject(new Error(`Response stream error: ${err.message}`));
|
|
32
|
+
});
|
|
33
|
+
res.on('end', () => {
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(data);
|
|
36
|
+
if (parsed.version) {
|
|
37
|
+
resolve(parsed.version);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
reject(new Error('Invalid response structure from NPM registry'));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
reject(new Error(`Failed to parse response: ${e.message}`));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
req.on('error', (err) => {
|
|
49
|
+
reject(err);
|
|
50
|
+
});
|
|
51
|
+
req.on('timeout', () => {
|
|
52
|
+
req.destroy();
|
|
53
|
+
reject(new Error('Request timed out'));
|
|
54
|
+
});
|
|
55
|
+
});
|
|
21
56
|
}
|
|
22
57
|
/**
|
|
23
58
|
* Get the current installed version of @nitrostack/core from package.json
|
|
@@ -32,15 +67,19 @@ function getCoreVersion(packageJsonPath) {
|
|
|
32
67
|
null;
|
|
33
68
|
}
|
|
34
69
|
/**
|
|
35
|
-
* Parse version string to extract the actual version
|
|
70
|
+
* Parse version string to extract the actual numeric version.
|
|
71
|
+
*
|
|
72
|
+
* Strips any leading range operator (^ ~ >= <= > <) and drops the pre-release
|
|
73
|
+
* suffix (e.g. `-beta.1`) so the dot-separated segments always parse to numbers
|
|
74
|
+
* instead of producing `NaN` in `compareVersions`.
|
|
36
75
|
*/
|
|
37
76
|
function parseVersion(versionString) {
|
|
38
|
-
return versionString.replace(/^[\^~>=<]+/, '');
|
|
77
|
+
return versionString.replace(/^[\^~>=<]+/, '').split('-')[0];
|
|
39
78
|
}
|
|
40
79
|
/**
|
|
41
80
|
* Compare two version strings
|
|
42
81
|
*/
|
|
43
|
-
function compareVersions(v1, v2) {
|
|
82
|
+
export function compareVersions(v1, v2) {
|
|
44
83
|
const parts1 = parseVersion(v1).split('.').map(Number);
|
|
45
84
|
const parts2 = parseVersion(v2).split('.').map(Number);
|
|
46
85
|
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
|
@@ -54,37 +93,58 @@ function compareVersions(v1, v2) {
|
|
|
54
93
|
return 0;
|
|
55
94
|
}
|
|
56
95
|
/**
|
|
57
|
-
*
|
|
96
|
+
* Determine if a dependency refers to a local file or workspace link.
|
|
58
97
|
*/
|
|
59
|
-
function
|
|
98
|
+
export function isLocalDependency(version) {
|
|
99
|
+
return version.startsWith('file:') ||
|
|
100
|
+
version.startsWith('link:') ||
|
|
101
|
+
version.startsWith('workspace:') ||
|
|
102
|
+
version.startsWith('.') ||
|
|
103
|
+
version.startsWith('/');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Update all @nitrostack/* versions in package.json using dynamic npm registry fetch
|
|
107
|
+
*/
|
|
108
|
+
async function updatePackageJson(packageJsonPath, dryRun) {
|
|
60
109
|
if (!fs.existsSync(packageJsonPath)) {
|
|
61
110
|
return [];
|
|
62
111
|
}
|
|
63
112
|
const packageJson = fs.readJSONSync(packageJsonPath);
|
|
64
113
|
const results = [];
|
|
65
114
|
let hasChanges = false;
|
|
66
|
-
const updateDeps = (deps) => {
|
|
115
|
+
const updateDeps = async (deps) => {
|
|
67
116
|
if (!deps)
|
|
68
117
|
return;
|
|
69
|
-
|
|
118
|
+
const promises = Object.keys(deps).map(async (pkg) => {
|
|
70
119
|
if (pkg.startsWith('@nitrostack/')) {
|
|
71
120
|
const currentVersion = deps[pkg];
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
121
|
+
// Skip local dependencies entirely
|
|
122
|
+
if (isLocalDependency(currentVersion)) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
const latestVersion = await fetchLatestNpmVersion(pkg);
|
|
127
|
+
if (compareVersions(currentVersion, latestVersion) < 0) {
|
|
128
|
+
results.push({
|
|
129
|
+
location: path.basename(path.dirname(packageJsonPath)),
|
|
130
|
+
packageName: pkg,
|
|
131
|
+
previousVersion: currentVersion,
|
|
132
|
+
newVersion: `^${latestVersion}`,
|
|
133
|
+
upgraded: true,
|
|
134
|
+
});
|
|
135
|
+
deps[pkg] = `^${latestVersion}`;
|
|
136
|
+
hasChanges = true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
console.warn(`\nā ļø Skipped upgrade check for ${pkg}: ${error.message}`);
|
|
82
141
|
}
|
|
83
142
|
}
|
|
84
|
-
}
|
|
143
|
+
});
|
|
144
|
+
await Promise.all(promises);
|
|
85
145
|
};
|
|
86
|
-
updateDeps(packageJson.dependencies);
|
|
87
|
-
updateDeps(packageJson.devDependencies);
|
|
146
|
+
await updateDeps(packageJson.dependencies);
|
|
147
|
+
await updateDeps(packageJson.devDependencies);
|
|
88
148
|
if (hasChanges && !dryRun) {
|
|
89
149
|
fs.writeJSONSync(packageJsonPath, packageJson, { spaces: 2 });
|
|
90
150
|
}
|
|
@@ -123,51 +183,22 @@ export async function upgradeCommand(options) {
|
|
|
123
183
|
console.log(createErrorBox('Not a NitroStack Project', '@nitrostack/core is not a dependency'));
|
|
124
184
|
process.exit(1);
|
|
125
185
|
}
|
|
126
|
-
// Fetch latest version
|
|
127
|
-
const spinner = new NitroSpinner('Checking for updates...').start();
|
|
128
|
-
let latestVersion;
|
|
129
|
-
try {
|
|
130
|
-
latestVersion = getLatestVersion('@nitrostack/core');
|
|
131
|
-
spinner.succeed(`Latest version: ${chalk.cyan(latestVersion)}`);
|
|
132
|
-
}
|
|
133
|
-
catch (error) {
|
|
134
|
-
spinner.fail('Failed to fetch latest version');
|
|
135
|
-
process.exit(1);
|
|
136
|
-
}
|
|
137
|
-
// Check if already on latest
|
|
138
|
-
const currentParsedVersion = parseVersion(coreVersion);
|
|
139
|
-
if (compareVersions(currentParsedVersion, latestVersion) >= 0) {
|
|
140
|
-
spacer();
|
|
141
|
-
console.log(createSuccessBox('Already Up to Date', [
|
|
142
|
-
`Current version: ${currentParsedVersion}`,
|
|
143
|
-
`Latest version: ${latestVersion}`,
|
|
144
|
-
]));
|
|
145
|
-
trackEvent('cli_upgrade_completed', {
|
|
146
|
-
packages_upgraded: 0,
|
|
147
|
-
from_version: currentParsedVersion,
|
|
148
|
-
to_version: latestVersion,
|
|
149
|
-
dry_run: !!options.dryRun,
|
|
150
|
-
already_current: true,
|
|
151
|
-
});
|
|
152
|
-
await shutdownAnalytics();
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const allResults = [];
|
|
156
186
|
const dryRun = options.dryRun ?? false;
|
|
157
187
|
if (dryRun) {
|
|
158
188
|
spacer();
|
|
159
189
|
log('Dry run mode - no changes will be made', 'warning');
|
|
160
190
|
}
|
|
161
191
|
spacer();
|
|
162
|
-
log('
|
|
192
|
+
log('Checking for package updates...', 'info');
|
|
163
193
|
spacer();
|
|
194
|
+
const allResults = [];
|
|
164
195
|
// Upgrade root
|
|
165
|
-
const rootSpinner = new NitroSpinner('
|
|
196
|
+
const rootSpinner = new NitroSpinner('Checking root package.json...').start();
|
|
166
197
|
try {
|
|
167
|
-
const results = updatePackageJson(rootPackageJsonPath,
|
|
198
|
+
const results = await updatePackageJson(rootPackageJsonPath, dryRun);
|
|
168
199
|
if (results.length > 0) {
|
|
169
200
|
allResults.push(...results);
|
|
170
|
-
rootSpinner.succeed(`Root:
|
|
201
|
+
rootSpinner.succeed(`Root: Found ${results.length} package update(s)`);
|
|
171
202
|
if (!dryRun) {
|
|
172
203
|
const installSpinner = new NitroSpinner('Installing dependencies...').start();
|
|
173
204
|
runNpmInstall(projectRoot);
|
|
@@ -175,7 +206,7 @@ export async function upgradeCommand(options) {
|
|
|
175
206
|
}
|
|
176
207
|
}
|
|
177
208
|
else {
|
|
178
|
-
rootSpinner.info('Root: All @nitrostack packages are up to date');
|
|
209
|
+
rootSpinner.info('Root: All @nitrostack packages are up to date (or local references)');
|
|
179
210
|
}
|
|
180
211
|
}
|
|
181
212
|
catch (error) {
|
|
@@ -184,12 +215,12 @@ export async function upgradeCommand(options) {
|
|
|
184
215
|
}
|
|
185
216
|
// Upgrade widgets if they exist
|
|
186
217
|
if (fs.existsSync(widgetsPackageJsonPath)) {
|
|
187
|
-
const widgetsSpinner = new NitroSpinner('
|
|
218
|
+
const widgetsSpinner = new NitroSpinner('Checking widgets package.json...').start();
|
|
188
219
|
try {
|
|
189
|
-
const results = updatePackageJson(widgetsPackageJsonPath,
|
|
220
|
+
const results = await updatePackageJson(widgetsPackageJsonPath, dryRun);
|
|
190
221
|
if (results.length > 0) {
|
|
191
222
|
allResults.push(...results);
|
|
192
|
-
widgetsSpinner.succeed(`Widgets:
|
|
223
|
+
widgetsSpinner.succeed(`Widgets: Found ${results.length} package update(s)`);
|
|
193
224
|
if (!dryRun) {
|
|
194
225
|
const installSpinner = new NitroSpinner('Installing widget dependencies...').start();
|
|
195
226
|
runNpmInstall(widgetsPath);
|
|
@@ -197,54 +228,61 @@ export async function upgradeCommand(options) {
|
|
|
197
228
|
}
|
|
198
229
|
}
|
|
199
230
|
else {
|
|
200
|
-
widgetsSpinner.info('Widgets: All @nitrostack packages are up to date');
|
|
231
|
+
widgetsSpinner.info('Widgets: All @nitrostack packages are up to date (or local references)');
|
|
201
232
|
}
|
|
202
233
|
}
|
|
203
234
|
catch (error) {
|
|
204
235
|
widgetsSpinner.fail('Failed to upgrade widgets');
|
|
236
|
+
console.error(error);
|
|
205
237
|
}
|
|
206
238
|
}
|
|
207
239
|
// Summary
|
|
208
240
|
spacer();
|
|
209
241
|
if (allResults.length === 0) {
|
|
210
|
-
log('
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
// Unique packages upgraded
|
|
214
|
-
const uniquePackages = Array.from(new Set(allResults.map(r => r.packageName)));
|
|
215
|
-
const summaryItems = uniquePackages.map(pkg => {
|
|
216
|
-
const result = allResults.find(r => r.packageName === pkg);
|
|
217
|
-
return `${pkg}: ${parseVersion(result.previousVersion)} ā ${parseVersion(result.newVersion)}`;
|
|
218
|
-
});
|
|
219
|
-
if (dryRun) {
|
|
220
|
-
spacer();
|
|
221
|
-
console.log(createBox([
|
|
222
|
-
chalk.yellow.bold('Dry run complete'),
|
|
223
|
-
'',
|
|
224
|
-
chalk.dim('No changes were made to your project.'),
|
|
225
|
-
chalk.dim('Run without --dry-run to apply the upgrade.'),
|
|
226
|
-
], 'warning'));
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
console.log(createSuccessBox('Upgrade Complete', [
|
|
230
|
-
...summaryItems,
|
|
231
|
-
'',
|
|
232
|
-
chalk.dim(`Total updates across all packages: ${allResults.length}`)
|
|
233
|
-
]));
|
|
234
|
-
nextSteps([
|
|
235
|
-
'Review the changes in package.json',
|
|
236
|
-
'Restart your development server',
|
|
237
|
-
'Check docs.nitrostack.ai for migration guides',
|
|
238
|
-
]);
|
|
239
|
-
}
|
|
240
|
-
showFooter();
|
|
242
|
+
console.log(createSuccessBox('Already Up to Date', [
|
|
243
|
+
'All @nitrostack packages are already running their latest versions.',
|
|
244
|
+
]));
|
|
241
245
|
trackEvent('cli_upgrade_completed', {
|
|
242
|
-
packages_upgraded:
|
|
243
|
-
from_version: currentParsedVersion,
|
|
244
|
-
to_version: latestVersion,
|
|
246
|
+
packages_upgraded: 0,
|
|
245
247
|
dry_run: dryRun,
|
|
246
|
-
already_current:
|
|
248
|
+
already_current: true,
|
|
247
249
|
});
|
|
248
250
|
await shutdownAnalytics();
|
|
251
|
+
return;
|
|
249
252
|
}
|
|
253
|
+
// Unique packages upgraded
|
|
254
|
+
const uniquePackages = Array.from(new Set(allResults.map(r => r.packageName)));
|
|
255
|
+
const summaryItems = uniquePackages.map(pkg => {
|
|
256
|
+
const result = allResults.find(r => r.packageName === pkg);
|
|
257
|
+
return `${pkg}: ${parseVersion(result.previousVersion)} ā ${parseVersion(result.newVersion)}`;
|
|
258
|
+
});
|
|
259
|
+
if (dryRun) {
|
|
260
|
+
spacer();
|
|
261
|
+
console.log(createBox([
|
|
262
|
+
chalk.yellow.bold('Dry Run - Proposed Upgrades:'),
|
|
263
|
+
...summaryItems.map(item => ` ⢠${item}`),
|
|
264
|
+
'',
|
|
265
|
+
chalk.dim('No changes were made to your project.'),
|
|
266
|
+
chalk.dim('Run without --dry-run to apply the upgrade.'),
|
|
267
|
+
], 'warning'));
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
console.log(createSuccessBox('Upgrade Complete', [
|
|
271
|
+
...summaryItems,
|
|
272
|
+
'',
|
|
273
|
+
chalk.dim(`Total updates across all packages: ${allResults.length}`)
|
|
274
|
+
]));
|
|
275
|
+
nextSteps([
|
|
276
|
+
'Review the changes in package.json',
|
|
277
|
+
'Restart your development server',
|
|
278
|
+
'Check docs.nitrostack.ai for migration guides',
|
|
279
|
+
]);
|
|
280
|
+
}
|
|
281
|
+
showFooter();
|
|
282
|
+
trackEvent('cli_upgrade_completed', {
|
|
283
|
+
packages_upgraded: allResults.length,
|
|
284
|
+
dry_run: dryRun,
|
|
285
|
+
already_current: false,
|
|
286
|
+
});
|
|
287
|
+
await shutdownAnalytics();
|
|
250
288
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export { startCommand } from './commands/start.js';
|
|
|
8
8
|
export { generate } from './commands/generate.js';
|
|
9
9
|
export { upgradeCommand } from './commands/upgrade.js';
|
|
10
10
|
export { installCommand } from './commands/install.js';
|
|
11
|
+
export { cursorCommand } from './commands/cursor.js';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,aAAa,YA4E5B;AAGD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { startCommand } from './commands/start.js';
|
|
|
8
8
|
import { generate } from './commands/generate.js';
|
|
9
9
|
import { upgradeCommand } from './commands/upgrade.js';
|
|
10
10
|
import { installCommand } from './commands/install.js';
|
|
11
|
+
import { cursorCommand } from './commands/cursor.js';
|
|
11
12
|
const require = createRequire(import.meta.url);
|
|
12
13
|
const packageJson = require('../package.json');
|
|
13
14
|
export function createProgram() {
|
|
@@ -64,6 +65,17 @@ export function createProgram() {
|
|
|
64
65
|
.option('--skip-widgets', 'Skip installing widget dependencies')
|
|
65
66
|
.option('--production', 'Install production dependencies only')
|
|
66
67
|
.action(installCommand);
|
|
68
|
+
program
|
|
69
|
+
.command('cursor')
|
|
70
|
+
.alias('c')
|
|
71
|
+
.description('Integrate this MCP server with Cursor')
|
|
72
|
+
.option('-g, --global', 'Install globally to ~/.cursor/mcp.json')
|
|
73
|
+
.option('-l, --local', 'Install locally to .cursor/mcp.json')
|
|
74
|
+
.option('-t, --type <type>', 'Connection type: "command", "legacy-sse", or "streamable-http" (alias: "sse" ā legacy-sse)')
|
|
75
|
+
.option('-u, --url <url>', 'HTTP connection URL (for legacy-sse or streamable-http)')
|
|
76
|
+
.option('-p, --port <port>', 'Port for default HTTP URL (for legacy-sse or streamable-http)')
|
|
77
|
+
.option('--force', 'Force overwrite of existing configuration')
|
|
78
|
+
.action(cursorCommand);
|
|
67
79
|
return program;
|
|
68
80
|
}
|
|
69
81
|
// Re-export commands for programmatic use
|
|
@@ -74,6 +86,7 @@ export { startCommand } from './commands/start.js';
|
|
|
74
86
|
export { generate } from './commands/generate.js';
|
|
75
87
|
export { upgradeCommand } from './commands/upgrade.js';
|
|
76
88
|
export { installCommand } from './commands/install.js';
|
|
89
|
+
export { cursorCommand } from './commands/cursor.js';
|
|
77
90
|
// Run the CLI when this module is the entry point
|
|
78
91
|
import { fileURLToPath } from 'url';
|
|
79
92
|
import { realpathSync } from 'fs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitrostack/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "CLI for NitroStack - Create and manage MCP server projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
14
15
|
"import": "./dist/index.js",
|
|
15
|
-
"require": "./dist/index.js"
|
|
16
|
-
"types": "./dist/index.d.ts"
|
|
16
|
+
"require": "./dist/index.js"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
@@ -2,30 +2,87 @@
|
|
|
2
2
|
NITRO_LOG_LEVEL=info
|
|
3
3
|
NITROSTACK_APP_MODE=openai
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Server Transport Configuration (Optional)
|
|
6
6
|
# =============================================================================
|
|
7
|
-
#
|
|
7
|
+
# MCP_TRANSPORT_TYPE: Toggles transport mode. Values: stdio | http | dual.
|
|
8
|
+
# Defaults to 'stdio' in development and 'dual' in production/NODE_ENV=production.
|
|
8
9
|
# =============================================================================
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
10
|
+
# MCP_TRANSPORT_TYPE=dual
|
|
11
|
+
# PORT=3000
|
|
12
|
+
# HOST=localhost
|
|
13
|
+
# ENABLE_CORS=true
|
|
14
|
+
|
|
15
|
+
# Streamable HTTP Session Limits (Optional)
|
|
13
16
|
# =============================================================================
|
|
14
|
-
#
|
|
17
|
+
# Bounds memory against unauthenticated initialize floods. Defaults: 1000 sessions,
|
|
18
|
+
# 30-minute idle timeout. Only applies when running in http or dual transport mode.
|
|
15
19
|
# =============================================================================
|
|
20
|
+
# MCP_MAX_SESSIONS=1000
|
|
21
|
+
# MCP_SESSION_TIMEOUT_MS=1800000
|
|
22
|
+
|
|
23
|
+
# OAuth 2.1 MCP Server Configuration
|
|
24
|
+
# =============================================================================
|
|
25
|
+
# Enforcement Gate (Optional)
|
|
16
26
|
# =============================================================================
|
|
17
|
-
#
|
|
27
|
+
# OAUTH_REQUIRED controls whether authentication is enforced.
|
|
28
|
+
# - Unset / false (default): auth is NOT enforced. The server runs out-of-the-box
|
|
29
|
+
# and protected endpoints are reachable without a token. Best for local dev.
|
|
30
|
+
# - true: auth is enforced (fail-closed). If neither JWKS_URI nor
|
|
31
|
+
# INTROSPECTION_ENDPOINT is configured, the server STILL starts and logs a
|
|
32
|
+
# clear warning, but rejects all protected requests until a verifier is set.
|
|
33
|
+
# Set this to true (and configure a verifier below) before deploying.
|
|
34
|
+
# =============================================================================
|
|
35
|
+
# OAUTH_REQUIRED=true
|
|
36
|
+
|
|
37
|
+
# =============================================================================
|
|
38
|
+
# REQUIRED: Server Configuration
|
|
18
39
|
# =============================================================================
|
|
19
|
-
# After creating your API and Application in Auth0, fill in these values:
|
|
20
40
|
# Your Auth0 API Identifier (from APIs ā MCP Server ā Identifier)
|
|
21
41
|
# This MUST match exactly what you set when creating the API
|
|
22
|
-
# This MUST match exactly what you set when creating the API
|
|
23
42
|
RESOURCE_URI=https://mcplocal
|
|
24
|
-
|
|
43
|
+
|
|
44
|
+
# Your Auth0 tenant domain (authorization server URL)
|
|
25
45
|
AUTH_SERVER_URL=https://dev-5dt0utuk315713tjm.us.auth0.com
|
|
26
|
-
|
|
46
|
+
|
|
47
|
+
# Cryptographic JWKS Signature Verification (Recommended)
|
|
48
|
+
# =============================================================================
|
|
49
|
+
# If configured, the SDK cryptographically verifies token signatures using JWKS keys.
|
|
50
|
+
# Token validation is SECURE BY DEFAULT (fail-closed): if neither JWKS_URI nor an
|
|
51
|
+
# introspection endpoint (below) is configured, ALL tokens are rejected. Configure
|
|
52
|
+
# one of them for a working server.
|
|
53
|
+
# NOTE: Unsigned/signature-less token decoding is disabled by default and is only
|
|
54
|
+
# available via the in-code `allowInsecureTokenDecode: true` option in
|
|
55
|
+
# OAuthModule.forRoot(...) ā intended for local development only, never production.
|
|
56
|
+
# =============================================================================
|
|
57
|
+
# JWKS_URI=https://dev-5dt0utuk315713tjm.us.auth0.com/.well-known/jwks.json
|
|
58
|
+
|
|
59
|
+
# Expected token validation audience (should match RESOURCE_URI)
|
|
27
60
|
TOKEN_AUDIENCE=https://mcplocal
|
|
28
|
-
|
|
61
|
+
|
|
62
|
+
# Expected token validation issuer (your authorization server tenant domain)
|
|
29
63
|
TOKEN_ISSUER=https://dev-5dt0utuk315713tjm.us.auth0.com
|
|
30
64
|
|
|
31
|
-
|
|
65
|
+
# Token Introspection Configuration (Alternative to JWKS signature verification)
|
|
66
|
+
# =============================================================================
|
|
67
|
+
# INTROSPECTION_ENDPOINT=https://dev-5dt0utuk315713tjm.us.auth0.com/oauth/introspect
|
|
68
|
+
# INTROSPECTION_CLIENT_ID=your-introspection-client-id
|
|
69
|
+
# INTROSPECTION_CLIENT_SECRET=your-introspection-client-secret
|
|
70
|
+
|
|
71
|
+
# OAuth Discovery Settings (Optional)
|
|
72
|
+
# =============================================================================
|
|
73
|
+
# OAUTH_DISCOVERY_PORT=3005
|
|
74
|
+
# OAUTH_DISCOVERY_AUTO_RETRY=true
|
|
75
|
+
# MCP_SERVER_PORT=3000
|
|
76
|
+
|
|
77
|
+
# Dynamic Client Registration (Optional / disabled by default)
|
|
78
|
+
# =============================================================================
|
|
79
|
+
# Set to 'true' to expose the /oauth/v2/register endpoint. It only serves the
|
|
80
|
+
# statically configured client below; without OAUTH_CLIENT_ID it stays disabled.
|
|
81
|
+
# =============================================================================
|
|
82
|
+
# OAUTH_ENABLE_CLIENT_REGISTRATION=true
|
|
83
|
+
# OAUTH_CLIENT_ID=your-client-id
|
|
84
|
+
# OAUTH_CLIENT_SECRET=your-client-secret
|
|
85
|
+
|
|
86
|
+
# Duffel API Integration (Required for Flight Search & Booking)
|
|
87
|
+
# =============================================================================
|
|
88
|
+
DUFFEL_API_KEY=your-duffel-api-key
|
|
@@ -36,6 +36,13 @@ import { SystemHealthCheck } from './health/system.health.js';
|
|
|
36
36
|
|
|
37
37
|
// Enable OAuth 2.1 authentication
|
|
38
38
|
OAuthModule.forRoot({
|
|
39
|
+
// Whether OAuth is enforced. Defaults to false (dev-friendly): the server
|
|
40
|
+
// runs out-of-the-box and protected endpoints are reachable without a token.
|
|
41
|
+
// Set OAUTH_REQUIRED=true to enforce auth (fail-closed). When enforced but no
|
|
42
|
+
// verifier (JWKS_URI / INTROSPECTION_ENDPOINT) is configured, the server still
|
|
43
|
+
// starts and warns, but rejects protected requests until one is configured.
|
|
44
|
+
required: process.env.OAUTH_REQUIRED === 'true',
|
|
45
|
+
|
|
39
46
|
// Resource URI - YOUR MCP server's public URL
|
|
40
47
|
// This is used for token audience binding (RFC 8707)
|
|
41
48
|
// CRITICAL: Tokens must be issued specifically for this URI
|
|
@@ -41,6 +41,25 @@ export class OAuthGuard implements Guard {
|
|
|
41
41
|
} else if (metaToken) {
|
|
42
42
|
token = metaToken as string;
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
// Enforcement gate: when OAuth is not required (OAUTH_REQUIRED not "true"),
|
|
46
|
+
// do not reject. Best-effort: if a valid token happens to be present, attach
|
|
47
|
+
// its identity; otherwise allow the request through unauthenticated.
|
|
48
|
+
if (!OAuthModule.isAuthRequired()) {
|
|
49
|
+
if (token) {
|
|
50
|
+
const result = await OAuthModule.validateToken(token);
|
|
51
|
+
if (result.valid) {
|
|
52
|
+
const payload = result.payload as OAuthTokenPayload;
|
|
53
|
+
context.auth = {
|
|
54
|
+
subject: payload.sub,
|
|
55
|
+
scopes: this.extractScopes(payload),
|
|
56
|
+
clientId: payload.client_id,
|
|
57
|
+
tokenPayload: payload,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
44
63
|
|
|
45
64
|
if (!token) {
|
|
46
65
|
throw new Error(
|
|
@@ -28,26 +28,24 @@ async function bootstrap() {
|
|
|
28
28
|
try {
|
|
29
29
|
console.error('š Starting Calculator MCP Server with OAuth 2.1...\\n');
|
|
30
30
|
|
|
31
|
-
// Validate required environment variables for OAuth
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
missing.forEach(v => console.error(` - ${v}`));
|
|
38
|
-
console.error('\\nš” Copy .env.example to .env and configure your OAuth provider');
|
|
39
|
-
console.error(' Or check the test-oauth/.env for reference\\n');
|
|
40
|
-
process.exit(1);
|
|
31
|
+
// Validate required environment variables for OAuth, set defaults if missing
|
|
32
|
+
if (!process.env.RESOURCE_URI || !process.env.AUTH_SERVER_URL) {
|
|
33
|
+
console.error('ā ļø Warning: Missing RESOURCE_URI or AUTH_SERVER_URL environment variables.');
|
|
34
|
+
console.error(' Defaulting to local test endpoints. Copy .env.example to .env to configure.\n');
|
|
35
|
+
process.env.RESOURCE_URI = process.env.RESOURCE_URI || 'http://localhost:3000';
|
|
36
|
+
process.env.AUTH_SERVER_URL = process.env.AUTH_SERVER_URL || 'http://localhost:8080/auth';
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
// Create the MCP application
|
|
44
40
|
const server = await McpApplicationFactory.create(AppModule);
|
|
45
41
|
|
|
42
|
+
const authEnforced = process.env.OAUTH_REQUIRED === 'true';
|
|
46
43
|
console.error('ā
OAuth 2.1 Module configured');
|
|
47
44
|
console.error(` Resource URI: ${process.env.RESOURCE_URI}`);
|
|
48
45
|
console.error(` Auth Server: ${process.env.AUTH_SERVER_URL}`);
|
|
49
46
|
console.error(` Scopes: read, write, admin`);
|
|
50
|
-
console.error(` Audience: ${process.env.TOKEN_AUDIENCE || process.env.RESOURCE_URI}
|
|
47
|
+
console.error(` Audience: ${process.env.TOKEN_AUDIENCE || process.env.RESOURCE_URI}`);
|
|
48
|
+
console.error(` Enforcement: ${authEnforced ? 'ON (OAUTH_REQUIRED=true)' : 'OFF (dev mode ā set OAUTH_REQUIRED=true to enforce)'}\\n`);
|
|
51
49
|
|
|
52
50
|
// Start the server
|
|
53
51
|
await server.start();
|
|
@@ -79,8 +79,26 @@ Respond to EXACTLY what the user asked - nothing more.`;
|
|
|
79
79
|
]
|
|
80
80
|
})
|
|
81
81
|
async flightComparison(input: any, ctx: ExecutionContext) {
|
|
82
|
+
let ids: string[] = [];
|
|
83
|
+
if (Array.isArray(input.offerIds)) {
|
|
84
|
+
ids = input.offerIds;
|
|
85
|
+
} else if (typeof input.offerIds === 'string') {
|
|
86
|
+
const trimmed = input.offerIds.trim();
|
|
87
|
+
if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
|
|
88
|
+
try {
|
|
89
|
+
const parsed = JSON.parse(trimmed);
|
|
90
|
+
ids = Array.isArray(parsed) ? parsed : [parsed];
|
|
91
|
+
} catch {
|
|
92
|
+
ids = trimmed.split(',').map((s: string) => s.trim());
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
ids = trimmed.split(',').map((s: string) => s.trim());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
ids = ids.filter(Boolean);
|
|
99
|
+
|
|
82
100
|
const offers = await Promise.all(
|
|
83
|
-
|
|
101
|
+
ids.map((id: string) => this.duffelService.getOffer(id))
|
|
84
102
|
);
|
|
85
103
|
|
|
86
104
|
const comparisonData = offers.map((offer: any) => {
|
|
@@ -12,9 +12,11 @@ export class DuffelService {
|
|
|
12
12
|
private duffel: Duffel;
|
|
13
13
|
|
|
14
14
|
constructor() {
|
|
15
|
-
|
|
15
|
+
let apiKey = process.env.DUFFEL_API_KEY;
|
|
16
16
|
if (!apiKey) {
|
|
17
|
-
|
|
17
|
+
console.error('ā ļø Warning: DUFFEL_API_KEY environment variable is missing.');
|
|
18
|
+
console.error(' Running with a dummy key for testing/dry-run mode.\n');
|
|
19
|
+
apiKey = 'duffel_test_dummy_key';
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
this.duffel = new Duffel({
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
NITRO_LOG_LEVEL=info
|
|
3
3
|
NITROSTACK_APP_MODE=openai
|
|
4
4
|
|
|
5
|
+
# Server Transport Configuration (Optional)
|
|
6
|
+
# =============================================================================
|
|
7
|
+
# MCP_TRANSPORT_TYPE: Toggles transport mode. Values: stdio | http | dual.
|
|
8
|
+
# Defaults to 'stdio' in development and 'dual' in production/NODE_ENV=production.
|
|
9
|
+
# =============================================================================
|
|
10
|
+
# MCP_TRANSPORT_TYPE=stdio
|
|
11
|
+
# PORT=3000
|
|
12
|
+
# HOST=localhost
|
|
13
|
+
# ENABLE_CORS=true
|
|
14
|
+
|
|
5
15
|
# Mapbox Configuration (Optional)
|
|
6
16
|
# =============================================================================
|
|
7
17
|
# The map widget uses Mapbox GL for interactive maps.
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
# NitroStack Configuration
|
|
2
2
|
NITRO_LOG_LEVEL=info
|
|
3
3
|
NITROSTACK_APP_MODE=openai
|
|
4
|
+
|
|
5
|
+
# Server Transport Configuration (Optional)
|
|
6
|
+
# =============================================================================
|
|
7
|
+
# MCP_TRANSPORT_TYPE: Toggles transport mode. Values: stdio | http | dual.
|
|
8
|
+
# Defaults to 'stdio' in development and 'dual' in production/NODE_ENV=production.
|
|
9
|
+
# =============================================================================
|
|
10
|
+
# MCP_TRANSPORT_TYPE=stdio
|
|
11
|
+
# PORT=3000
|
|
12
|
+
# HOST=localhost
|
|
13
|
+
# ENABLE_CORS=true
|