mlgym-deploy 2.3.2 → 2.3.5
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/index.js +94 -40
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -17,18 +17,20 @@ import crypto from 'crypto';
|
|
|
17
17
|
const execAsync = promisify(exec);
|
|
18
18
|
|
|
19
19
|
// Current version of this MCP server
|
|
20
|
-
const CURRENT_VERSION = '2.3.
|
|
20
|
+
const CURRENT_VERSION = '2.3.5';
|
|
21
21
|
const PACKAGE_NAME = 'mlgym-deploy';
|
|
22
22
|
|
|
23
23
|
// Version check state
|
|
24
24
|
let versionCheckResult = null;
|
|
25
25
|
let lastVersionCheck = 0;
|
|
26
26
|
const VERSION_CHECK_INTERVAL = 3600000; // Check once per hour
|
|
27
|
+
let updateAcknowledged = false; // Track if user has acknowledged the update
|
|
27
28
|
|
|
28
29
|
// Helper to wrap tool response with update message if needed
|
|
29
30
|
function wrapResponseWithUpdateMessage(response) {
|
|
30
31
|
if (versionCheckResult && versionCheckResult.updateAvailable) {
|
|
31
|
-
const updateMessage =
|
|
32
|
+
const updateMessage = `
|
|
33
|
+
╔════════════════════════════════════════════════════════════════════╗
|
|
32
34
|
║ 🔄 UPDATE AVAILABLE 🔄 ║
|
|
33
35
|
║ ║
|
|
34
36
|
║ A newer version of MLGym MCP Server is available! ║
|
|
@@ -37,12 +39,13 @@ function wrapResponseWithUpdateMessage(response) {
|
|
|
37
39
|
║ Latest version: ${versionCheckResult.latest.padEnd(52)} ║
|
|
38
40
|
║ ║
|
|
39
41
|
║ To update in Cursor: ║
|
|
40
|
-
║ 1.
|
|
42
|
+
║ 1. Open a new terminal tab (Cmd/Ctrl + Shift + \`) ║
|
|
41
43
|
║ 2. Run: npm install -g ${PACKAGE_NAME}@latest ║
|
|
42
44
|
║ 3. Restart Cursor to use the updated MCP server ║
|
|
43
45
|
║ ║
|
|
44
|
-
║ ⚠️ Using outdated version may cause issues!
|
|
45
|
-
|
|
46
|
+
║ ⚠️ Using outdated version may cause unexpected issues! ║
|
|
47
|
+
╚════════════════════════════════════════════════════════════════════╝
|
|
48
|
+
`;
|
|
46
49
|
|
|
47
50
|
// Prepend update message to the response
|
|
48
51
|
if (response.content && response.content[0] && response.content[0].type === 'text') {
|
|
@@ -315,6 +318,14 @@ const server = new Server(
|
|
|
315
318
|
|
|
316
319
|
// Tool definitions
|
|
317
320
|
const TOOLS = [
|
|
321
|
+
{
|
|
322
|
+
name: 'mlgym_update_acknowledge',
|
|
323
|
+
description: 'Acknowledge the update notification and continue using the current version (not recommended)',
|
|
324
|
+
inputSchema: {
|
|
325
|
+
type: 'object',
|
|
326
|
+
properties: {}
|
|
327
|
+
}
|
|
328
|
+
},
|
|
318
329
|
{
|
|
319
330
|
name: 'mlgym_git_configure',
|
|
320
331
|
description: 'Check and configure git user settings (required before making commits)',
|
|
@@ -430,18 +441,18 @@ const TOOLS = [
|
|
|
430
441
|
},
|
|
431
442
|
{
|
|
432
443
|
name: 'mlgym_auth_check',
|
|
433
|
-
description: '🚨 ALWAYS USE THIS FIRST when deploying! Check if user account exists
|
|
444
|
+
description: '🚨 ALWAYS USE THIS FIRST when deploying! Check if user account exists. First call with email only, then call again with password if needed.',
|
|
434
445
|
inputSchema: {
|
|
435
446
|
type: 'object',
|
|
436
447
|
properties: {
|
|
437
448
|
email: {
|
|
438
449
|
type: 'string',
|
|
439
|
-
description: 'Email address to check
|
|
450
|
+
description: 'Email address to check',
|
|
440
451
|
pattern: '^[^@]+@[^@]+\\.[^@]+$'
|
|
441
452
|
},
|
|
442
453
|
password: {
|
|
443
454
|
type: 'string',
|
|
444
|
-
description: 'Password (
|
|
455
|
+
description: 'Password (optional - add on second call to authenticate)',
|
|
445
456
|
minLength: 8
|
|
446
457
|
}
|
|
447
458
|
},
|
|
@@ -1204,6 +1215,71 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1204
1215
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
1205
1216
|
const { name, arguments: args } = request.params;
|
|
1206
1217
|
|
|
1218
|
+
// Check for updates before executing ANY tool
|
|
1219
|
+
// Special handling: mlgym_version_check and mlgym_update_acknowledge bypass this check
|
|
1220
|
+
if (name !== 'mlgym_version_check' && name !== 'mlgym_update_acknowledge') {
|
|
1221
|
+
// Perform version check
|
|
1222
|
+
await checkForUpdates();
|
|
1223
|
+
|
|
1224
|
+
// If update is available and not acknowledged, force user to acknowledge
|
|
1225
|
+
if (versionCheckResult && versionCheckResult.updateAvailable && !updateAcknowledged) {
|
|
1226
|
+
return {
|
|
1227
|
+
content: [
|
|
1228
|
+
{
|
|
1229
|
+
type: 'text',
|
|
1230
|
+
text: `╔════════════════════════════════════════════════════════════════════╗
|
|
1231
|
+
║ 🚨 UPDATE REQUIRED 🚨 ║
|
|
1232
|
+
╚════════════════════════════════════════════════════════════════════╝
|
|
1233
|
+
|
|
1234
|
+
A newer version of MLGym MCP Server is available!
|
|
1235
|
+
|
|
1236
|
+
Current version: ${CURRENT_VERSION}
|
|
1237
|
+
Latest version: ${versionCheckResult.latest}
|
|
1238
|
+
|
|
1239
|
+
The MCP server requires an update before you can continue using it.
|
|
1240
|
+
|
|
1241
|
+
Please choose one of the following options:
|
|
1242
|
+
|
|
1243
|
+
1. **UPDATE NOW (Recommended)**
|
|
1244
|
+
Open a new terminal in Cursor and run:
|
|
1245
|
+
\`\`\`bash
|
|
1246
|
+
npm install -g ${PACKAGE_NAME}@latest
|
|
1247
|
+
\`\`\`
|
|
1248
|
+
Then restart Cursor to use the updated MCP server.
|
|
1249
|
+
|
|
1250
|
+
2. **ACKNOWLEDGE AND CONTINUE**
|
|
1251
|
+
If you need to continue without updating, use the special tool:
|
|
1252
|
+
\`mlgym_update_acknowledge\`
|
|
1253
|
+
|
|
1254
|
+
⚠️ Warning: Continuing with an outdated version may cause:
|
|
1255
|
+
- Missing features
|
|
1256
|
+
- Compatibility issues
|
|
1257
|
+
- Unexpected errors
|
|
1258
|
+
- Deployment failures
|
|
1259
|
+
|
|
1260
|
+
Please update the MCP server or explicitly acknowledge to continue.`
|
|
1261
|
+
}
|
|
1262
|
+
]
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// Handle special update acknowledgment tool
|
|
1268
|
+
if (name === 'mlgym_update_acknowledge') {
|
|
1269
|
+
updateAcknowledged = true;
|
|
1270
|
+
return {
|
|
1271
|
+
content: [
|
|
1272
|
+
{
|
|
1273
|
+
type: 'text',
|
|
1274
|
+
text: `✓ Update acknowledgment received. You can now continue using the MCP server.
|
|
1275
|
+
|
|
1276
|
+
⚠️ You are using version ${CURRENT_VERSION} while version ${versionCheckResult?.latest || 'unknown'} is available.
|
|
1277
|
+
Some features may not work correctly. Please update as soon as possible.`
|
|
1278
|
+
}
|
|
1279
|
+
]
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1207
1283
|
let response;
|
|
1208
1284
|
switch (name) {
|
|
1209
1285
|
case 'mlgym_git_configure':
|
|
@@ -1864,44 +1940,22 @@ async function checkUserExists(args) {
|
|
|
1864
1940
|
}
|
|
1865
1941
|
}
|
|
1866
1942
|
|
|
1867
|
-
//
|
|
1868
|
-
|
|
1869
|
-
const result = await apiRequest('POST', '/api/v1/auth/login', {
|
|
1870
|
-
email,
|
|
1871
|
-
password: 'dummy_check'
|
|
1872
|
-
}, false);
|
|
1873
|
-
|
|
1874
|
-
// If we get here, it means the endpoint is accessible
|
|
1875
|
-
// The error message will tell us if user exists
|
|
1876
|
-
if (result.error && result.error.includes('Invalid credentials')) {
|
|
1877
|
-
return {
|
|
1878
|
-
content: [{
|
|
1879
|
-
type: 'text',
|
|
1880
|
-
text: JSON.stringify({
|
|
1881
|
-
status: 'success',
|
|
1882
|
-
exists: true,
|
|
1883
|
-
authenticated: false,
|
|
1884
|
-
email: email,
|
|
1885
|
-
message: 'User exists but needs password to authenticate',
|
|
1886
|
-
next_step: 'Please provide password to check SSH keys'
|
|
1887
|
-
}, null, 2)
|
|
1888
|
-
}]
|
|
1889
|
-
};
|
|
1890
|
-
}
|
|
1891
|
-
} catch (err) {
|
|
1892
|
-
// Network or other error
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
// User doesn't exist
|
|
1943
|
+
// Without password, we cannot definitively check if user exists
|
|
1944
|
+
// Return a response that prompts for password to check
|
|
1896
1945
|
return {
|
|
1897
1946
|
content: [{
|
|
1898
1947
|
type: 'text',
|
|
1899
1948
|
text: JSON.stringify({
|
|
1900
1949
|
status: 'success',
|
|
1901
|
-
exists:
|
|
1950
|
+
exists: 'unknown',
|
|
1951
|
+
authenticated: false,
|
|
1902
1952
|
email: email,
|
|
1903
|
-
message: '
|
|
1904
|
-
next_step: '
|
|
1953
|
+
message: 'Cannot determine if account exists without password',
|
|
1954
|
+
next_step: 'Please provide your password to check if you have an existing account, or provide full details to create a new account',
|
|
1955
|
+
options: [
|
|
1956
|
+
'If you have an account: Provide your password',
|
|
1957
|
+
'If you are new: Provide name, password, and accept terms to create account'
|
|
1958
|
+
]
|
|
1905
1959
|
}, null, 2)
|
|
1906
1960
|
}]
|
|
1907
1961
|
};
|