mlgym-deploy 3.3.0 → 3.3.2
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 +205 -80
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
9
9
|
import axios from 'axios';
|
|
10
10
|
import fs from 'fs/promises';
|
|
11
|
+
import fsSync from 'fs';
|
|
11
12
|
import path from 'path';
|
|
12
13
|
import os from 'os';
|
|
13
14
|
import { exec } from 'child_process';
|
|
@@ -17,7 +18,7 @@ import crypto from 'crypto';
|
|
|
17
18
|
const execAsync = promisify(exec);
|
|
18
19
|
|
|
19
20
|
// Current version of this MCP server - INCREMENT FOR WORKFLOW FIXES
|
|
20
|
-
const CURRENT_VERSION = '3.3.
|
|
21
|
+
const CURRENT_VERSION = '3.3.2'; // Fixed fs.existsSync bug by importing fsSync for synchronous file operations
|
|
21
22
|
const PACKAGE_NAME = 'mlgym-deploy';
|
|
22
23
|
|
|
23
24
|
// Debug logging configuration - ENABLED BY DEFAULT
|
|
@@ -1302,9 +1303,9 @@ async function initProject(args) {
|
|
|
1302
1303
|
|
|
1303
1304
|
for (const filename of composeFiles) {
|
|
1304
1305
|
const composePath = path.join(local_path, filename);
|
|
1305
|
-
if (
|
|
1306
|
+
if (fsSync.existsSync(composePath)) {
|
|
1306
1307
|
try {
|
|
1307
|
-
composeContent =
|
|
1308
|
+
composeContent = fsSync.readFileSync(composePath, 'utf8');
|
|
1308
1309
|
log.info(`MCP >>> [initProject] Read ${filename}: ${composeContent.length} bytes`);
|
|
1309
1310
|
break;
|
|
1310
1311
|
} catch (err) {
|
|
@@ -2014,10 +2015,10 @@ async function deployProject(args) {
|
|
|
2014
2015
|
if (strategy.type === 'docker-compose') {
|
|
2015
2016
|
const composePath = path.join(local_path, 'docker-compose.yml');
|
|
2016
2017
|
const composePathYAML = path.join(local_path, 'docker-compose.yaml');
|
|
2017
|
-
const actualPath =
|
|
2018
|
+
const actualPath = fsSync.existsSync(composePath) ? composePath : composePathYAML;
|
|
2018
2019
|
|
|
2019
|
-
if (
|
|
2020
|
-
const content =
|
|
2020
|
+
if (fsSync.existsSync(actualPath)) {
|
|
2021
|
+
const content = fsSync.readFileSync(actualPath, 'utf8');
|
|
2021
2022
|
const validation = validateAndFixDockerCompose(content);
|
|
2022
2023
|
|
|
2023
2024
|
if (!validation.isValid) {
|
|
@@ -2028,11 +2029,11 @@ async function deployProject(args) {
|
|
|
2028
2029
|
|
|
2029
2030
|
// Auto-fix the issues
|
|
2030
2031
|
log.info('MCP >>> Auto-fixing docker-compose.yml port mappings...');
|
|
2031
|
-
|
|
2032
|
+
fsSync.writeFileSync(actualPath, validation.fixedContent);
|
|
2032
2033
|
|
|
2033
2034
|
// Create backup
|
|
2034
2035
|
const backupPath = actualPath + '.backup';
|
|
2035
|
-
|
|
2036
|
+
fsSync.writeFileSync(backupPath, content);
|
|
2036
2037
|
log.info(`MCP >>> Created backup at ${backupPath}`);
|
|
2037
2038
|
|
|
2038
2039
|
log.success('MCP >>> Fixed docker-compose.yml:');
|
|
@@ -2044,8 +2045,8 @@ async function deployProject(args) {
|
|
|
2044
2045
|
} else if (strategy.type === 'dockerfile') {
|
|
2045
2046
|
const dockerfilePath = path.join(local_path, 'Dockerfile');
|
|
2046
2047
|
|
|
2047
|
-
if (
|
|
2048
|
-
const content =
|
|
2048
|
+
if (fsSync.existsSync(dockerfilePath)) {
|
|
2049
|
+
const content = fsSync.readFileSync(dockerfilePath, 'utf8');
|
|
2049
2050
|
const validation = validateDockerfile(content);
|
|
2050
2051
|
|
|
2051
2052
|
if (!validation.isValid) {
|
|
@@ -2073,8 +2074,8 @@ async function deployProject(args) {
|
|
|
2073
2074
|
const fixedContent = lines.join('\n');
|
|
2074
2075
|
|
|
2075
2076
|
// Create backup
|
|
2076
|
-
|
|
2077
|
-
|
|
2077
|
+
fsSync.writeFileSync(dockerfilePath + '.backup', content);
|
|
2078
|
+
fsSync.writeFileSync(dockerfilePath, fixedContent);
|
|
2078
2079
|
|
|
2079
2080
|
log.success('MCP >>> Fixed Dockerfile: added EXPOSE 80');
|
|
2080
2081
|
}
|
|
@@ -2833,127 +2834,186 @@ async function showHelp(args) {
|
|
|
2833
2834
|
║ Complete Deployment Platform for GitLab + Coolify ║
|
|
2834
2835
|
╚═══════════════════════════════════════════════════════════════════════╝
|
|
2835
2836
|
|
|
2837
|
+
HOW TO USE THIS GUIDE:
|
|
2838
|
+
Users speak in plain English. When they say "deploy to mlgym" or "show me
|
|
2839
|
+
the status", the AI translates this to the appropriate tool call.
|
|
2840
|
+
|
|
2841
|
+
Examples show both what users say AND the tool call that gets executed.
|
|
2842
|
+
|
|
2836
2843
|
📦 DEPLOYMENT TOOLS
|
|
2837
2844
|
───────────────────────────────────────────────────────────────────────
|
|
2838
2845
|
|
|
2839
|
-
🚀 mlgym_deploy
|
|
2840
|
-
|
|
2846
|
+
🚀 mlgym_deploy - Deploy your application
|
|
2847
|
+
What users say:
|
|
2848
|
+
• "Deploy to mlgym"
|
|
2849
|
+
• "Deploy this project to mlgym"
|
|
2850
|
+
• "I want to deploy my app"
|
|
2851
|
+
• "Push this to production"
|
|
2841
2852
|
|
|
2842
|
-
|
|
2853
|
+
Tool call:
|
|
2843
2854
|
mlgym_deploy({
|
|
2844
2855
|
project_name: "my-app",
|
|
2845
2856
|
project_description: "My application",
|
|
2846
|
-
email: "user@example.com", // optional if already
|
|
2847
|
-
password: "password123" // optional if already
|
|
2857
|
+
email: "user@example.com", // optional if already logged in
|
|
2858
|
+
password: "password123" // optional if already logged in
|
|
2848
2859
|
})
|
|
2849
2860
|
|
|
2850
|
-
📊 mlgym_status
|
|
2851
|
-
|
|
2861
|
+
📊 mlgym_status - Check deployment status
|
|
2862
|
+
What users say:
|
|
2863
|
+
• "Show me the status"
|
|
2864
|
+
• "What's deployed?"
|
|
2865
|
+
• "Am I logged in?"
|
|
2866
|
+
• "Check if my project is configured"
|
|
2852
2867
|
|
|
2853
|
-
|
|
2854
|
-
mlgym_status({
|
|
2868
|
+
Tool call:
|
|
2869
|
+
mlgym_status({
|
|
2870
|
+
local_path: "." // optional, defaults to current directory
|
|
2871
|
+
})
|
|
2855
2872
|
|
|
2856
|
-
📝 mlgym_deploy_logs
|
|
2857
|
-
|
|
2873
|
+
📝 mlgym_deploy_logs - View deployment logs
|
|
2874
|
+
What users say:
|
|
2875
|
+
• "Show me the deployment logs"
|
|
2876
|
+
• "What happened in the last deployment?"
|
|
2877
|
+
• "Why did my deployment fail?"
|
|
2878
|
+
• "Show the build logs"
|
|
2858
2879
|
|
|
2859
|
-
|
|
2880
|
+
Tool call:
|
|
2860
2881
|
mlgym_deploy_logs({
|
|
2861
2882
|
project_name: "my-app",
|
|
2862
|
-
depth: 3 // number of deployments
|
|
2883
|
+
depth: 3 // optional, number of recent deployments
|
|
2863
2884
|
})
|
|
2864
2885
|
|
|
2865
2886
|
⚙️ CONFIGURATION TOOLS
|
|
2866
2887
|
───────────────────────────────────────────────────────────────────────
|
|
2867
2888
|
|
|
2868
|
-
🔧 mlgym_set_env_vars
|
|
2869
|
-
|
|
2889
|
+
🔧 mlgym_set_env_vars - Set environment variables
|
|
2890
|
+
What users say:
|
|
2891
|
+
• "Set the database URL"
|
|
2892
|
+
• "Add these environment variables"
|
|
2893
|
+
• "Configure my API keys"
|
|
2894
|
+
• "I need to set DATABASE_URL and STRIPE_KEY"
|
|
2870
2895
|
|
|
2871
|
-
|
|
2896
|
+
Tool call:
|
|
2872
2897
|
mlgym_set_env_vars({
|
|
2873
2898
|
project_name: "my-app",
|
|
2874
2899
|
variables: {
|
|
2875
|
-
DATABASE_URL: "postgresql
|
|
2876
|
-
|
|
2900
|
+
DATABASE_URL: "postgresql://user:pass@host:5432/db",
|
|
2901
|
+
STRIPE_KEY: "sk_live_123...",
|
|
2902
|
+
NODE_ENV: "production"
|
|
2877
2903
|
}
|
|
2878
2904
|
})
|
|
2879
2905
|
|
|
2880
|
-
❤️ mlgym_set_health_check
|
|
2881
|
-
|
|
2906
|
+
❤️ mlgym_set_health_check - Configure health monitoring
|
|
2907
|
+
What users say:
|
|
2908
|
+
• "Set up a health check"
|
|
2909
|
+
• "Monitor my /health endpoint"
|
|
2910
|
+
• "Check if my app is alive every 30 seconds"
|
|
2911
|
+
• "Enable health checks on /api/health"
|
|
2882
2912
|
|
|
2883
|
-
|
|
2913
|
+
Tool call:
|
|
2884
2914
|
mlgym_set_health_check({
|
|
2885
2915
|
project_name: "my-app",
|
|
2886
2916
|
enabled: true,
|
|
2887
|
-
path: "/health",
|
|
2888
|
-
method: "GET",
|
|
2889
|
-
return_code: 200,
|
|
2890
|
-
interval:
|
|
2917
|
+
path: "/health", // endpoint to check
|
|
2918
|
+
method: "GET", // HTTP method
|
|
2919
|
+
return_code: 200, // expected status code
|
|
2920
|
+
interval: 30 // check every 30 seconds
|
|
2891
2921
|
})
|
|
2892
2922
|
|
|
2893
|
-
🌐 mlgym_set_domain
|
|
2894
|
-
|
|
2923
|
+
🌐 mlgym_set_domain - Set custom domain
|
|
2924
|
+
What users say:
|
|
2925
|
+
• "Use my custom domain"
|
|
2926
|
+
• "Point myapp.com to this deployment"
|
|
2927
|
+
• "Set the domain to app.example.com"
|
|
2928
|
+
• "Change the URL to www.mysite.com"
|
|
2895
2929
|
|
|
2896
|
-
|
|
2930
|
+
Tool call:
|
|
2897
2931
|
mlgym_set_domain({
|
|
2898
2932
|
project_name: "my-app",
|
|
2899
|
-
domain: "myapp.example.com"
|
|
2933
|
+
domain: "myapp.example.com" // your custom domain
|
|
2900
2934
|
})
|
|
2901
2935
|
|
|
2902
|
-
📜 mlgym_set_deployment_commands
|
|
2903
|
-
|
|
2936
|
+
📜 mlgym_set_deployment_commands - Configure build commands
|
|
2937
|
+
What users say:
|
|
2938
|
+
• "Run migrations before deploying"
|
|
2939
|
+
• "Seed the database after deployment"
|
|
2940
|
+
• "Execute npm run build before starting"
|
|
2941
|
+
• "Run these commands during deployment"
|
|
2904
2942
|
|
|
2905
|
-
|
|
2943
|
+
Tool call:
|
|
2906
2944
|
mlgym_set_deployment_commands({
|
|
2907
2945
|
project_name: "my-app",
|
|
2908
|
-
pre_command: "npm run migrate",
|
|
2909
|
-
post_command: "npm run seed"
|
|
2946
|
+
pre_command: "npm run migrate", // runs before deployment
|
|
2947
|
+
post_command: "npm run seed" // runs after deployment
|
|
2910
2948
|
})
|
|
2911
2949
|
|
|
2912
|
-
⚙️ mlgym_set_options
|
|
2913
|
-
|
|
2950
|
+
⚙️ mlgym_set_options - Configure deployment options
|
|
2951
|
+
What users say:
|
|
2952
|
+
• "Disable build cache"
|
|
2953
|
+
• "Turn off the build cache"
|
|
2954
|
+
• "Don't use cached builds"
|
|
2955
|
+
• "Force a fresh build"
|
|
2914
2956
|
|
|
2915
|
-
|
|
2957
|
+
Tool call:
|
|
2916
2958
|
mlgym_set_options({
|
|
2917
2959
|
project_name: "my-app",
|
|
2918
|
-
disable_build_cache: true
|
|
2960
|
+
disable_build_cache: true // force fresh builds
|
|
2919
2961
|
})
|
|
2920
2962
|
|
|
2921
2963
|
🎬 DEPLOYMENT MANAGEMENT
|
|
2922
2964
|
───────────────────────────────────────────────────────────────────────
|
|
2923
2965
|
|
|
2924
|
-
▶️ mlgym_deploy_manual
|
|
2925
|
-
|
|
2966
|
+
▶️ mlgym_deploy_manual - Trigger deployment manually
|
|
2967
|
+
What users say:
|
|
2968
|
+
• "Deploy now"
|
|
2969
|
+
• "Trigger a deployment"
|
|
2970
|
+
• "Redeploy my application"
|
|
2971
|
+
• "Start a new deployment"
|
|
2926
2972
|
|
|
2927
|
-
|
|
2928
|
-
mlgym_deploy_manual({
|
|
2973
|
+
Tool call:
|
|
2974
|
+
mlgym_deploy_manual({
|
|
2975
|
+
project_name: "my-app"
|
|
2976
|
+
})
|
|
2929
2977
|
|
|
2930
|
-
⏪ mlgym_rollback
|
|
2931
|
-
|
|
2978
|
+
⏪ mlgym_rollback - Rollback to previous version
|
|
2979
|
+
What users say:
|
|
2980
|
+
• "Rollback my deployment"
|
|
2981
|
+
• "Go back to the previous version"
|
|
2982
|
+
• "Undo the last deployment"
|
|
2983
|
+
• "Revert to deployment #123"
|
|
2932
2984
|
|
|
2933
|
-
|
|
2985
|
+
Tool call:
|
|
2934
2986
|
mlgym_rollback({
|
|
2935
2987
|
project_name: "my-app",
|
|
2936
|
-
deployment_id: 123 // optional, uses previous if
|
|
2988
|
+
deployment_id: 123 // optional, uses previous if omitted
|
|
2937
2989
|
})
|
|
2938
2990
|
|
|
2939
2991
|
👤 USER MANAGEMENT
|
|
2940
2992
|
───────────────────────────────────────────────────────────────────────
|
|
2941
2993
|
|
|
2942
|
-
➕ mlgym_user_create
|
|
2943
|
-
|
|
2994
|
+
➕ mlgym_user_create - Create new account
|
|
2995
|
+
What users say:
|
|
2996
|
+
• "Create a new account"
|
|
2997
|
+
• "Sign me up"
|
|
2998
|
+
• "Register a new user"
|
|
2999
|
+
• "I need an account"
|
|
2944
3000
|
|
|
2945
|
-
|
|
3001
|
+
Tool call:
|
|
2946
3002
|
mlgym_user_create({
|
|
2947
3003
|
email: "user@example.com",
|
|
2948
3004
|
name: "John Doe",
|
|
2949
3005
|
password: "SecurePass123!",
|
|
2950
|
-
accept_terms: true
|
|
3006
|
+
accept_terms: true // must be true
|
|
2951
3007
|
})
|
|
2952
3008
|
|
|
2953
|
-
🔐 mlgym_auth_login
|
|
2954
|
-
|
|
3009
|
+
🔐 mlgym_auth_login - Login to existing account
|
|
3010
|
+
What users say:
|
|
3011
|
+
• "Login"
|
|
3012
|
+
• "Log me in"
|
|
3013
|
+
• "Authenticate with my credentials"
|
|
3014
|
+
• "Sign in to my account"
|
|
2955
3015
|
|
|
2956
|
-
|
|
3016
|
+
Tool call:
|
|
2957
3017
|
mlgym_auth_login({
|
|
2958
3018
|
email: "user@example.com",
|
|
2959
3019
|
password: "SecurePass123!"
|
|
@@ -2962,17 +3022,25 @@ async function showHelp(args) {
|
|
|
2962
3022
|
❓ HELP
|
|
2963
3023
|
───────────────────────────────────────────────────────────────────────
|
|
2964
3024
|
|
|
2965
|
-
📖 mlgym_help
|
|
2966
|
-
|
|
3025
|
+
📖 mlgym_help - Display this help
|
|
3026
|
+
What users say:
|
|
3027
|
+
• "Help"
|
|
3028
|
+
• "Show me what I can do"
|
|
3029
|
+
• "What commands are available?"
|
|
3030
|
+
• "How do I use mlgym?"
|
|
2967
3031
|
|
|
2968
|
-
|
|
3032
|
+
Tool call:
|
|
2969
3033
|
mlgym_help()
|
|
2970
3034
|
|
|
2971
3035
|
╔═══════════════════════════════════════════════════════════════════════╗
|
|
2972
|
-
║
|
|
3036
|
+
║ COMMON WORKFLOW EXAMPLES ║
|
|
2973
3037
|
╚═══════════════════════════════════════════════════════════════════════╝
|
|
2974
3038
|
|
|
2975
|
-
1️⃣ Complete
|
|
3039
|
+
1️⃣ First Time User - Complete Deployment:
|
|
3040
|
+
|
|
3041
|
+
User: "Deploy to mlgym"
|
|
3042
|
+
|
|
3043
|
+
AI executes:
|
|
2976
3044
|
mlgym_deploy({
|
|
2977
3045
|
project_name: "my-app",
|
|
2978
3046
|
project_description: "My new app",
|
|
@@ -2981,22 +3049,79 @@ async function showHelp(args) {
|
|
|
2981
3049
|
})
|
|
2982
3050
|
|
|
2983
3051
|
2️⃣ Set Environment Variables:
|
|
3052
|
+
|
|
3053
|
+
User: "Set the database URL for my app"
|
|
3054
|
+
|
|
3055
|
+
AI executes:
|
|
2984
3056
|
mlgym_set_env_vars({
|
|
2985
3057
|
project_name: "my-app",
|
|
2986
|
-
variables: {
|
|
3058
|
+
variables: {
|
|
3059
|
+
DATABASE_URL: "postgresql://user:pass@host:5432/db"
|
|
3060
|
+
}
|
|
2987
3061
|
})
|
|
2988
3062
|
|
|
2989
|
-
3️⃣ Configure
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
3063
|
+
3️⃣ Configure Health Check:
|
|
3064
|
+
|
|
3065
|
+
User: "Monitor my /health endpoint every 30 seconds"
|
|
3066
|
+
|
|
3067
|
+
AI executes:
|
|
3068
|
+
mlgym_set_health_check({
|
|
3069
|
+
project_name: "my-app",
|
|
3070
|
+
enabled: true,
|
|
3071
|
+
path: "/health",
|
|
3072
|
+
interval: 30
|
|
3073
|
+
})
|
|
3074
|
+
|
|
3075
|
+
4️⃣ Set Custom Domain:
|
|
3076
|
+
|
|
3077
|
+
User: "Point myapp.com to this deployment"
|
|
3078
|
+
|
|
3079
|
+
AI executes:
|
|
3080
|
+
mlgym_set_domain({
|
|
3081
|
+
project_name: "my-app",
|
|
3082
|
+
domain: "myapp.com"
|
|
3083
|
+
})
|
|
3084
|
+
|
|
3085
|
+
5️⃣ Manually Trigger Deployment:
|
|
3086
|
+
|
|
3087
|
+
User: "Deploy now"
|
|
3088
|
+
|
|
3089
|
+
AI executes:
|
|
3090
|
+
mlgym_deploy_manual({
|
|
3091
|
+
project_name: "my-app"
|
|
3092
|
+
})
|
|
3093
|
+
|
|
3094
|
+
6️⃣ Check Deployment Logs:
|
|
3095
|
+
|
|
3096
|
+
User: "Show me the last 5 deployments"
|
|
3097
|
+
|
|
3098
|
+
AI executes:
|
|
3099
|
+
mlgym_deploy_logs({
|
|
3100
|
+
project_name: "my-app",
|
|
3101
|
+
depth: 5
|
|
3102
|
+
})
|
|
3103
|
+
|
|
3104
|
+
7️⃣ Rollback if Something Breaks:
|
|
3105
|
+
|
|
3106
|
+
User: "Rollback to the previous version"
|
|
3107
|
+
|
|
3108
|
+
AI executes:
|
|
3109
|
+
mlgym_rollback({
|
|
3110
|
+
project_name: "my-app"
|
|
3111
|
+
})
|
|
3112
|
+
|
|
3113
|
+
╔═══════════════════════════════════════════════════════════════════════╗
|
|
3114
|
+
║ QUICK TIPS ║
|
|
3115
|
+
╚═══════════════════════════════════════════════════════════════════════╝
|
|
2993
3116
|
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
3117
|
+
💡 Users speak naturally - AI translates to tool calls
|
|
3118
|
+
💡 Authentication is cached - login once, deploy many times
|
|
3119
|
+
💡 All tools work with project_name to identify the application
|
|
3120
|
+
💡 Most parameters are optional with sensible defaults
|
|
2997
3121
|
|
|
2998
|
-
📚
|
|
2999
|
-
|
|
3122
|
+
📚 Documentation: https://mlgym.info
|
|
3123
|
+
🌐 Backend: https://backend.eu.ezb.net
|
|
3124
|
+
📊 Dashboard: https://platform.mlgym.info
|
|
3000
3125
|
`;
|
|
3001
3126
|
|
|
3002
3127
|
return {
|
package/package.json
CHANGED