mlgym-deploy 3.0.4 → 3.0.6

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 (3) hide show
  1. package/DEBUG.md +78 -0
  2. package/index.js +134 -20
  3. package/package.json +5 -2
package/DEBUG.md ADDED
@@ -0,0 +1,78 @@
1
+ # MCP Debug Mode
2
+
3
+ ## Debug Logging (Enabled by Default)
4
+
5
+ **✨ Debug mode is ON by default!** You'll automatically see detailed messages when you start Cursor from a terminal.
6
+
7
+ ### To see debug output:
8
+ ```bash
9
+ # Just start Cursor from terminal
10
+ cd ~/your-project
11
+ cursor .
12
+ ```
13
+
14
+ ### To DISABLE debug logging (if too verbose):
15
+ ```bash
16
+ export MLGYM_DEBUG=false
17
+ cursor .
18
+ ```
19
+
20
+ Or:
21
+ ```bash
22
+ export DEBUG=off
23
+ cursor .
24
+ ```
25
+
26
+ ## What You'll See
27
+
28
+ When debug mode is enabled, you'll see colored output in the terminal:
29
+
30
+ ```
31
+ ╔═══════════════════════════════════════════════════════╗
32
+ ║ MLGym MCP Server v3.0.6 ║
33
+ ╚═══════════════════════════════════════════════════════╝
34
+ Backend: https://backend.eu.ezb.net
35
+ Debug mode: ENABLED
36
+ ✓ Server ready and waiting for requests...
37
+
38
+ [12:34:56.789] ℹ INFO ═══════════════════════════════════════════════════
39
+ [12:34:56.790] ℹ INFO Tool called: mlgym_deploy (MCP v3.0.6)
40
+ [12:34:56.791] ⋯ DEBUG Arguments: {...}
41
+ [12:34:56.792] ℹ INFO Starting deployment workflow...
42
+ [12:34:58.123] ✓ SUCCESS Tool mlgym_deploy completed in 1331ms
43
+ [12:34:58.124] ℹ INFO ═══════════════════════════════════════════════════
44
+ ```
45
+
46
+ ## Log Levels
47
+
48
+ - **ℹ INFO** (cyan) - General information about operations
49
+ - **✓ SUCCESS** (green) - Successful completions
50
+ - **⚠ WARNING** (yellow) - Non-fatal issues (always shown)
51
+ - **✗ ERROR** (red) - Errors and failures (always shown)
52
+ - **⋯ DEBUG** (dim) - Detailed debugging info (only in debug mode)
53
+
54
+ ## Debugging Tips
55
+
56
+ 1. **Start Cursor from terminal** to see the output:
57
+ ```bash
58
+ cd ~/your-project
59
+ cursor .
60
+ ```
61
+
62
+ 2. **Check the terminal** where you launched Cursor - all MCP logs appear there
63
+
64
+ 3. **Errors and warnings** are always shown
65
+
66
+ 4. **Disable debug mode** if output is too verbose:
67
+ ```bash
68
+ export MLGYM_DEBUG=false
69
+ cursor .
70
+ ```
71
+
72
+ ## Troubleshooting
73
+
74
+ If you don't see debug messages:
75
+ 1. Make sure you started Cursor from a terminal (not from GUI/Dock)
76
+ 2. Check that you're using MCP v3.0.6 or later
77
+ 3. Verify debug isn't explicitly disabled: `echo $MLGYM_DEBUG`
78
+ 4. Look at the terminal where you launched Cursor, not inside Cursor itself
package/index.js CHANGED
@@ -17,9 +17,68 @@ import crypto from 'crypto';
17
17
  const execAsync = promisify(exec);
18
18
 
19
19
  // Current version of this MCP server - INCREMENT FOR WORKFLOW FIXES
20
- const CURRENT_VERSION = '3.0.4'; // Added administrator (chka@stratus5.com) as project member for debugging
20
+ const CURRENT_VERSION = '3.0.6'; // Added debug logging with colored terminal output
21
21
  const PACKAGE_NAME = 'mlgym-deploy';
22
22
 
23
+ // Debug logging configuration - ENABLED BY DEFAULT
24
+ const DEBUG_ENABLED = process.env.MLGYM_DEBUG !== 'false' && process.env.DEBUG !== 'off';
25
+ const DEBUG_COLORS = {
26
+ reset: '\x1b[0m',
27
+ bright: '\x1b[1m',
28
+ dim: '\x1b[2m',
29
+ cyan: '\x1b[36m',
30
+ green: '\x1b[32m',
31
+ yellow: '\x1b[33m',
32
+ red: '\x1b[31m',
33
+ magenta: '\x1b[35m',
34
+ blue: '\x1b[34m'
35
+ };
36
+
37
+ // Enhanced debug logging functions
38
+ function debugLog(level, message, ...args) {
39
+ const timestamp = new Date().toISOString().split('T')[1].replace('Z', '');
40
+ let color = DEBUG_COLORS.reset;
41
+ let prefix = '';
42
+
43
+ switch(level) {
44
+ case 'info':
45
+ color = DEBUG_COLORS.cyan;
46
+ prefix = 'ℹ INFO';
47
+ break;
48
+ case 'success':
49
+ color = DEBUG_COLORS.green;
50
+ prefix = '✓ SUCCESS';
51
+ break;
52
+ case 'warning':
53
+ color = DEBUG_COLORS.yellow;
54
+ prefix = '⚠ WARNING';
55
+ break;
56
+ case 'error':
57
+ color = DEBUG_COLORS.red;
58
+ prefix = '✗ ERROR';
59
+ break;
60
+ case 'debug':
61
+ color = DEBUG_COLORS.dim;
62
+ prefix = '⋯ DEBUG';
63
+ break;
64
+ default:
65
+ prefix = '• LOG';
66
+ }
67
+
68
+ if (DEBUG_ENABLED || level === 'error' || level === 'warning') {
69
+ console.error(`${DEBUG_COLORS.dim}[${timestamp}]${DEBUG_COLORS.reset} ${color}${prefix}${DEBUG_COLORS.reset} ${message}`, ...args);
70
+ }
71
+ }
72
+
73
+ // Convenience logging functions
74
+ const log = {
75
+ info: (msg, ...args) => debugLog('info', msg, ...args),
76
+ success: (msg, ...args) => debugLog('success', msg, ...args),
77
+ warning: (msg, ...args) => debugLog('warning', msg, ...args),
78
+ error: (msg, ...args) => debugLog('error', msg, ...args),
79
+ debug: (msg, ...args) => debugLog('debug', msg, ...args)
80
+ };
81
+
23
82
  // Version check state
24
83
  let versionCheckResult = null;
25
84
  let lastVersionCheck = 0;
@@ -1063,6 +1122,7 @@ async function initProject(args) {
1063
1122
 
1064
1123
  // Create initial commit and push (like CLI does)
1065
1124
  const gitSteps = [];
1125
+ let pushSucceeded = false;
1066
1126
 
1067
1127
  try {
1068
1128
  // Check if there are any files to commit
@@ -1094,11 +1154,20 @@ async function initProject(args) {
1094
1154
 
1095
1155
  // Push to trigger webhook and deployment
1096
1156
  gitSteps.push('Pushing to GitLab to trigger deployment');
1157
+ console.error('Executing: git push -u mlgym main');
1097
1158
  await execAsync('git push -u mlgym main', { cwd: absolutePath });
1159
+ gitSteps.push('✅ Successfully pushed to GitLab');
1160
+ pushSucceeded = true;
1161
+ console.error('✅ Git push completed successfully');
1098
1162
 
1099
1163
  } catch (pushError) {
1100
- console.error('Git operations warning:', pushError.message);
1101
- gitSteps.push(`Warning: ${pushError.message}`);
1164
+ console.error('Git push failed:', pushError.message);
1165
+ gitSteps.push(`❌ Push failed: ${pushError.message}`);
1166
+ // Include stderr if available
1167
+ if (pushError.stderr) {
1168
+ console.error('Git push stderr:', pushError.stderr);
1169
+ gitSteps.push(`Error details: ${pushError.stderr}`);
1170
+ }
1102
1171
  }
1103
1172
 
1104
1173
  // Monitor deployment if enabled (like CLI does)
@@ -1145,8 +1214,10 @@ async function initProject(args) {
1145
1214
  content: [{
1146
1215
  type: 'text',
1147
1216
  text: JSON.stringify({
1148
- status: 'success',
1149
- message: 'Project created and pushed successfully',
1217
+ status: pushSucceeded ? 'success' : 'partial_success',
1218
+ message: pushSucceeded
1219
+ ? 'Project created and pushed successfully'
1220
+ : 'Project created but git push failed - please push manually',
1150
1221
  project: {
1151
1222
  id: project.id,
1152
1223
  name: project.name,
@@ -1157,13 +1228,23 @@ async function initProject(args) {
1157
1228
  },
1158
1229
  git_operations: gitSteps,
1159
1230
  deployment: deploymentStatus,
1160
- next_steps: enable_deployment && deploymentStatus?.status === 'deployed' ? [
1161
- `✅ Your application is live at: ${deploymentStatus.url}`,
1162
- 'Future updates: git push mlgym main'
1163
- ] : [
1164
- 'To update: git push mlgym main',
1165
- enable_deployment ? 'Deployment will trigger automatically' : null
1166
- ].filter(Boolean)
1231
+ push_succeeded: pushSucceeded,
1232
+ next_steps: pushSucceeded
1233
+ ? (enable_deployment && deploymentStatus?.status === 'deployed' ? [
1234
+ `✅ Your application is live at: ${deploymentStatus.url}`,
1235
+ 'Future updates: git push mlgym main'
1236
+ ] : [
1237
+ enable_deployment ? 'Deployment triggered - check URL in a few minutes' : 'Project ready',
1238
+ enable_deployment ? `Expected URL: https://${hostname}.ezb.net` : null,
1239
+ 'To update: git push mlgym main'
1240
+ ].filter(Boolean))
1241
+ : [
1242
+ '❌ Git push failed - deployment not triggered',
1243
+ 'Manual steps required:',
1244
+ `1. cd ${local_path}`,
1245
+ '2. git push mlgym main',
1246
+ 'Check the git_operations array above for error details'
1247
+ ]
1167
1248
  }, null, 2)
1168
1249
  }]
1169
1250
  };
@@ -1841,27 +1922,47 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
1841
1922
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
1842
1923
  const { name, arguments: args } = request.params;
1843
1924
 
1844
- console.error(`Tool called: ${name} (MCP v${CURRENT_VERSION})`);
1925
+ log.info(`═══════════════════════════════════════════════════`);
1926
+ log.info(`Tool called: ${DEBUG_COLORS.bright}${name}${DEBUG_COLORS.reset} (MCP v${CURRENT_VERSION})`);
1927
+ log.debug(`Arguments:`, JSON.stringify(args, null, 2));
1845
1928
 
1846
1929
  try {
1930
+ let result;
1931
+ const startTime = Date.now();
1932
+
1847
1933
  switch (name) {
1848
1934
  case 'mlgym_deploy':
1849
- return await deployProject(args);
1935
+ log.info(`Starting deployment workflow...`);
1936
+ result = await deployProject(args);
1937
+ break;
1850
1938
 
1851
1939
  case 'mlgym_status':
1852
- return await getStatus(args);
1940
+ log.info(`Checking status...`);
1941
+ result = await getStatus(args);
1942
+ break;
1853
1943
 
1854
1944
  case 'mlgym_user_create':
1855
- return await createUser(args);
1945
+ log.info(`Creating user account...`);
1946
+ result = await createUser(args);
1947
+ break;
1856
1948
 
1857
1949
  case 'mlgym_auth_login':
1858
- return await loginUser(args);
1950
+ log.info(`Authenticating user...`);
1951
+ result = await loginUser(args);
1952
+ break;
1859
1953
 
1860
1954
  default:
1861
1955
  throw new Error(`Unknown tool: ${name}. Available tools: mlgym_deploy, mlgym_status, mlgym_user_create, mlgym_auth_login`);
1862
1956
  }
1957
+
1958
+ const duration = Date.now() - startTime;
1959
+ log.success(`Tool ${name} completed in ${duration}ms`);
1960
+ log.info(`═══════════════════════════════════════════════════`);
1961
+
1962
+ return result;
1863
1963
  } catch (error) {
1864
- console.error(`Tool execution failed:`, error);
1964
+ log.error(`Tool execution failed:`, error.message);
1965
+ log.error(`Stack trace:`, error.stack);
1865
1966
  return {
1866
1967
  content: [{
1867
1968
  type: 'text',
@@ -1878,10 +1979,23 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1878
1979
  async function main() {
1879
1980
  const transport = new StdioServerTransport();
1880
1981
  await server.connect(transport);
1881
- console.error(`MLGym MCP Server v${CURRENT_VERSION} started`);
1982
+
1983
+ console.error(`\n${DEBUG_COLORS.bright}${DEBUG_COLORS.cyan}╔═══════════════════════════════════════════════════════╗${DEBUG_COLORS.reset}`);
1984
+ console.error(`${DEBUG_COLORS.bright}${DEBUG_COLORS.cyan}║${DEBUG_COLORS.reset} ${DEBUG_COLORS.bright}MLGym MCP Server v${CURRENT_VERSION}${DEBUG_COLORS.reset} ${DEBUG_COLORS.bright}${DEBUG_COLORS.cyan}║${DEBUG_COLORS.reset}`);
1985
+ console.error(`${DEBUG_COLORS.bright}${DEBUG_COLORS.cyan}╚═══════════════════════════════════════════════════════╝${DEBUG_COLORS.reset}`);
1986
+ console.error(`${DEBUG_COLORS.dim}Backend: ${CONFIG.backend_url}${DEBUG_COLORS.reset}`);
1987
+ console.error(`${DEBUG_COLORS.dim}Debug mode: ${DEBUG_ENABLED ? DEBUG_COLORS.green + 'ENABLED (default)' : DEBUG_COLORS.yellow + 'DISABLED'}${DEBUG_COLORS.reset}`);
1988
+
1989
+ if (!DEBUG_ENABLED) {
1990
+ console.error(`${DEBUG_COLORS.yellow}💡 Debug disabled. To re-enable: unset MLGYM_DEBUG${DEBUG_COLORS.reset}`);
1991
+ } else {
1992
+ console.error(`${DEBUG_COLORS.dim}💡 To disable debug: export MLGYM_DEBUG=false${DEBUG_COLORS.reset}`);
1993
+ }
1994
+
1995
+ console.error(`${DEBUG_COLORS.green}✓ Server ready and waiting for requests...${DEBUG_COLORS.reset}\n`);
1882
1996
  }
1883
1997
 
1884
1998
  main().catch((error) => {
1885
- console.error('Server error:', error);
1999
+ log.error('Server startup failed:', error);
1886
2000
  process.exit(1);
1887
2001
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mlgym-deploy",
3
- "version": "3.0.4",
4
- "description": "MCP server for MLGym - Added administrator as project member for debugging",
3
+ "version": "3.0.6",
4
+ "description": "MCP server for MLGym - Added debug logging with colored terminal output",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "bin": {
@@ -51,3 +51,6 @@
51
51
  ]
52
52
  }
53
53
  }
54
+
55
+
56
+