@mcp-use/cli 3.1.2 → 3.1.3-canary.1

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/index.js CHANGED
@@ -3141,6 +3141,27 @@ function parseEnvVar(envStr) {
3141
3141
  }
3142
3142
  return { key, value };
3143
3143
  }
3144
+ async function syncEnvVarsToServer(api, serverId, envVars) {
3145
+ const entries = Object.entries(envVars);
3146
+ if (entries.length === 0) return { created: 0, updated: 0 };
3147
+ const existing = await api.listEnvVariables(serverId);
3148
+ const byKey = new Map(existing.map((v) => [v.key, v]));
3149
+ const results = await Promise.all(
3150
+ entries.map(async ([key, value]) => {
3151
+ const found = byKey.get(key);
3152
+ if (found) {
3153
+ await api.updateEnvVariable(serverId, found.id, { value });
3154
+ return "updated";
3155
+ }
3156
+ await api.createEnvVariable(serverId, { key, value });
3157
+ return "created";
3158
+ })
3159
+ );
3160
+ return {
3161
+ created: results.filter((r) => r === "created").length,
3162
+ updated: results.filter((r) => r === "updated").length
3163
+ };
3164
+ }
3144
3165
  async function buildEnvVars(options) {
3145
3166
  const envVars = {};
3146
3167
  if (options.envFile) {
@@ -4085,6 +4106,16 @@ async function deployCommand(options) {
4085
4106
  console.log(source_default.gray(` Redeploying to maintain the same URL...`));
4086
4107
  console.log(source_default.cyan(` URL: ${getMcpServerUrl(existingDep)}
4087
4108
  `));
4109
+ if (Object.keys(envVars).length > 0) {
4110
+ const synced = await syncEnvVarsToServer(api, serverId, envVars);
4111
+ console.log(
4112
+ source_default.green(
4113
+ `\u2713 Synced ${synced.created + synced.updated} environment variable(s)` + (synced.created || synced.updated ? source_default.gray(
4114
+ ` (${synced.created} created, ${synced.updated} updated)`
4115
+ ) : "")
4116
+ )
4117
+ );
4118
+ }
4088
4119
  const newDep = await api.createDeployment({
4089
4120
  serverId,
4090
4121
  branch,
@@ -4123,6 +4154,16 @@ async function deployCommand(options) {
4123
4154
  }
4124
4155
  let deploymentId;
4125
4156
  if (serverId) {
4157
+ if (Object.keys(envVars).length > 0) {
4158
+ const synced = await syncEnvVarsToServer(api, serverId, envVars);
4159
+ console.log(
4160
+ source_default.green(
4161
+ `\u2713 Synced ${synced.created + synced.updated} environment variable(s)` + (synced.created || synced.updated ? source_default.gray(
4162
+ ` (${synced.created} created, ${synced.updated} updated)`
4163
+ ) : "")
4164
+ )
4165
+ );
4166
+ }
4126
4167
  console.log(source_default.gray("Creating deployment..."));
4127
4168
  try {
4128
4169
  const result = await api.createDeployment({