mlgym-deploy 3.3.26 → 3.3.29

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 (2) hide show
  1. package/index.js +50 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -18,7 +18,7 @@ import crypto from 'crypto';
18
18
  const execAsync = promisify(exec);
19
19
 
20
20
  // Current version of this MCP server - INCREMENT FOR WORKFLOW FIXES
21
- const CURRENT_VERSION = '3.3.23'; // Scala: flexible src structure, copy all .scala files
21
+ const CURRENT_VERSION = '3.3.29'; // Fix SSH key per-user when using MLGYM_TOKEN env var
22
22
  const PACKAGE_NAME = 'mlgym-deploy';
23
23
 
24
24
  // Debug logging configuration - ENABLED BY DEFAULT
@@ -94,10 +94,29 @@ const CONFIG = {
94
94
  };
95
95
 
96
96
  // Helper to load/save authentication
97
+ // Helper to extract email from JWT token
98
+ function extractEmailFromJWT(token) {
99
+ try {
100
+ // JWT format: header.payload.signature
101
+ const parts = token.split('.');
102
+ if (parts.length !== 3) return null;
103
+
104
+ // Decode base64url payload (replace - with + and _ with /)
105
+ const base64 = parts[1].replace(/-/g, '+').replace(/_/g, '/');
106
+ const payload = JSON.parse(Buffer.from(base64, 'base64').toString('utf8'));
107
+
108
+ return payload.email || payload.sub || null;
109
+ } catch {
110
+ return null;
111
+ }
112
+ }
113
+
97
114
  async function loadAuth() {
98
115
  // First check environment variable
99
116
  if (process.env.MLGYM_TOKEN) {
100
- return { token: process.env.MLGYM_TOKEN, email: process.env.MLGYM_EMAIL || 'env-token-user' };
117
+ // Try to extract email from JWT token if MLGYM_EMAIL is not set
118
+ const email = process.env.MLGYM_EMAIL || extractEmailFromJWT(process.env.MLGYM_TOKEN) || 'env-token-user';
119
+ return { token: process.env.MLGYM_TOKEN, email };
101
120
  }
102
121
 
103
122
  // Fall back to config file
@@ -550,6 +569,24 @@ async function analyzeProject(local_path = '.') {
550
569
  } catch {}
551
570
  }
552
571
 
572
+ // Check for PHP project
573
+ if (analysis.project_type === 'unknown') {
574
+ try {
575
+ await fs.access(path.join(absolutePath, 'index.php'));
576
+ analysis.project_type = 'php';
577
+ analysis.framework = 'php';
578
+ analysis.detected_files.push('index.php');
579
+ } catch {
580
+ // Also check for composer.json (PHP with Composer)
581
+ try {
582
+ await fs.access(path.join(absolutePath, 'composer.json'));
583
+ analysis.project_type = 'php';
584
+ analysis.framework = 'composer';
585
+ analysis.detected_files.push('composer.json');
586
+ } catch {}
587
+ }
588
+ }
589
+
553
590
  // Check for static HTML project
554
591
  if (analysis.project_type === 'unknown') {
555
592
  try {
@@ -723,6 +760,13 @@ COPY . .
723
760
  EXPOSE 8000
724
761
  CMD ["python", "main.py"]`;
725
762
  }
763
+ } else if (projectType === 'php') {
764
+ dockerfile = `FROM php:8.2-apache
765
+ WORKDIR /var/www/html
766
+ COPY . .
767
+ RUN chown -R www-data:www-data /var/www/html
768
+ EXPOSE 80
769
+ CMD ["apache2-foreground"]`;
726
770
  } else if (projectType === 'static') {
727
771
  dockerfile = `FROM nginx:alpine
728
772
  COPY . /usr/share/nginx/html
@@ -1694,6 +1738,10 @@ async function initProject(args) {
1694
1738
 
1695
1739
  const project = result.data;
1696
1740
 
1741
+ // Debug: Log the deployment_url received from backend
1742
+ log.debug('MCP >>> [initProject] Backend response - deployment_url:', project.deployment_url);
1743
+ log.debug('MCP >>> [initProject] Backend response - webhook_id:', project.webhook_id);
1744
+
1697
1745
  // Add administrator (chka@stratus5.com) as project member for debugging
1698
1746
  console.error('Adding administrator as project member...');
1699
1747
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mlgym-deploy",
3
- "version": "3.3.26",
3
+ "version": "3.3.29",
4
4
  "description": "MCP server for MLGym - Complete deployment management: deploy, configure, monitor, and rollback applications",
5
5
  "main": "index.js",
6
6
  "type": "module",