@studiometa/forge-mcp 0.4.8 → 0.5.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.
@@ -1,8 +1,8 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- import { HttpClient, isForgeApiError } from "@studiometa/forge-api";
5
- import { PHP_CONFIG_TYPES, RESOURCES, activateCertificate, createAuditLogger, createBackupConfig, createCertificate, createCommand, createDaemon, createDatabase, createDatabaseUser, createFirewallRule, createMonitor, createNginxTemplate, createRecipe, createRedirectRule, createScheduledJob, createSecurityRule, createServer, createSite, createSshKey, deleteBackupConfig, deleteCertificate, deleteDaemon, deleteDatabase, deleteDatabaseUser, deleteFirewallRule, deleteMonitor, deleteNginxTemplate, deleteRecipe, deleteRedirectRule, deleteScheduledJob, deleteSecurityRule, deleteServer, deleteSite, deleteSshKey, deploySiteAndWait, disablePhpOpcache, enablePhpOpcache, getBackupConfig, getCertificate, getCommand, getDaemon, getDaemonLog, getDatabase, getDatabaseUser, getDeploymentLog, getDeploymentScript, getEnv, getFirewallRule, getMonitor, getNginxConfig, getNginxTemplate, getPhpConfig, getPhpMaxExecutionTime, getPhpMaxUploadSize, getPhpOpcache, getPhpVersion, getRecipe, getRedirectRule, getScheduledJob, getSecurityRule, getServer, getSite, getSshKey, getUser, listBackupConfigs, listCommands, listDaemons, listDatabaseUsers, listDatabases, listDeployments, listFirewallRules, listMonitors, listNginxTemplates, listPhpVersions, listRecipes, listRedirectRules, listScheduledJobs, listSecurityRules, listServers, listServices, listSites, listSshKeys, rebootServer, resolveServers, resolveSites, restartDaemon, restartService, runRecipe, updateBackupConfig, updateDaemon, updateDatabaseUser, updateDeploymentScript, updateEnv, updateNginxConfig, updateNginxTemplate, updatePhpConfig, updatePhpMaxExecutionTime, updatePhpMaxUploadSize, updateRecipe, updateSecurityRule, updateSite } from "@studiometa/forge-core";
4
+ import { HttpClient, STORAGE_PROVIDER_TYPES, isForgeApiError } from "@studiometa/forge-api";
5
+ import { PHP_CONFIG_TYPES, RESOURCES, activateCertificate, createAuditLogger, createBackupConfig, createCertificate, createCommand, createDaemon, createDatabase, createDatabaseUser, createFirewallRule, createMonitor, createNginxTemplate, createRecipe, createRedirectRule, createScheduledJob, createSecurityRule, createServer, createSite, createSshKey, createStorageProvider, deleteBackupConfig, deleteCertificate, deleteDaemon, deleteDatabase, deleteDatabaseUser, deleteFirewallRule, deleteMonitor, deleteNginxTemplate, deleteRecipe, deleteRedirectRule, deleteScheduledJob, deleteSecurityRule, deleteServer, deleteSite, deleteSshKey, deleteStorageProvider, deploySiteAndWait, disablePhpOpcache, enablePhpOpcache, getBackupConfig, getCertificate, getCommand, getDaemon, getDaemonLog, getDatabase, getDatabaseUser, getDeploymentLog, getDeploymentScript, getEnv, getFirewallRule, getMonitor, getNginxConfig, getNginxTemplate, getPhpConfig, getPhpMaxExecutionTime, getPhpMaxUploadSize, getPhpOpcache, getPhpVersion, getRecipe, getRedirectRule, getScheduledJob, getSecurityRule, getServer, getSite, getSshKey, getStorageProvider, getUser, listBackupConfigs, listCommands, listDaemons, listDatabaseUsers, listDatabases, listDeployments, listFirewallRules, listMonitors, listNginxTemplates, listPhpVersions, listRecipes, listRedirectRules, listScheduledJobs, listSecurityRules, listServers, listServices, listSites, listSshKeys, listStorageProviders, rebootServer, resolveServers, resolveSites, restartDaemon, restartService, runRecipe, updateBackupConfig, updateDaemon, updateDatabaseUser, updateDeploymentScript, updateEnv, updateNginxConfig, updateNginxTemplate, updatePhpConfig, updatePhpMaxExecutionTime, updatePhpMaxUploadSize, updateRecipe, updateSecurityRule, updateSite } from "@studiometa/forge-core";
6
6
  //#region src/instructions.ts
7
7
  /**
8
8
  * MCP Server Instructions
@@ -185,6 +185,22 @@ function integer(message$1) {
185
185
  };
186
186
  }
187
187
  /* @__NO_SIDE_EFFECTS__ */
188
+ function minLength(requirement, message$1) {
189
+ return {
190
+ kind: "validation",
191
+ type: "min_length",
192
+ reference: minLength,
193
+ async: false,
194
+ expects: `>=${requirement}`,
195
+ requirement,
196
+ message: message$1,
197
+ "~run"(dataset, config$1) {
198
+ if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
199
+ return dataset;
200
+ }
201
+ };
202
+ }
203
+ /* @__NO_SIDE_EFFECTS__ */
188
204
  function minValue(requirement, message$1) {
189
205
  return {
190
206
  kind: "validation",
@@ -898,6 +914,28 @@ function formatBackupConfig(backup) {
898
914
  ].join("\n");
899
915
  }
900
916
  /**
917
+ * Format a list of storage providers.
918
+ */
919
+ function formatStorageProviderList(providers) {
920
+ if (providers.length === 0) return "No storage providers found.";
921
+ const lines = providers.map((p) => `• ${p.name} (ID: ${p.id}) — ${p.provider_name} — bucket: ${p.bucket ?? "—"}${p.in_use ? " — in use" : ""}`);
922
+ return `${providers.length} storage provider(s):\n${lines.join("\n")}`;
923
+ }
924
+ /**
925
+ * Format a single storage provider. Forge never returns the keys.
926
+ */
927
+ function formatStorageProvider(provider) {
928
+ return [
929
+ `Storage Provider: ${provider.name} (ID: ${provider.id})`,
930
+ `Provider: ${provider.provider_name} (${provider.provider})`,
931
+ `Endpoint: ${provider.endpoint ?? "—"}`,
932
+ `Region: ${provider.region ?? "—"}`,
933
+ `Bucket: ${provider.bucket ?? "—"}`,
934
+ `Directory: ${provider.directory ?? "—"}`,
935
+ `In use: ${provider.in_use ? "yes" : "no"}`
936
+ ].join("\n");
937
+ }
938
+ /**
901
939
  * Format a list of recipes.
902
940
  */
903
941
  function formatRecipeList(recipes) {
@@ -1133,10 +1171,23 @@ var handleBackups = createResourceHandler({
1133
1171
  }),
1134
1172
  create: /* @__PURE__ */ object({
1135
1173
  server_id: /* @__PURE__ */ string(),
1136
- provider: /* @__PURE__ */ string(),
1137
- frequency: /* @__PURE__ */ string(),
1138
- credentials: /* @__PURE__ */ unknown(),
1139
- databases: /* @__PURE__ */ unknown()
1174
+ storage_provider_id: /* @__PURE__ */ number(),
1175
+ frequency: /* @__PURE__ */ picklist([
1176
+ "hourly",
1177
+ "daily",
1178
+ "weekly",
1179
+ "custom"
1180
+ ]),
1181
+ retention: /* @__PURE__ */ number(),
1182
+ database_ids: /* @__PURE__ */ pipe(/* @__PURE__ */ array(/* @__PURE__ */ number()), /* @__PURE__ */ minLength(1)),
1183
+ include_new_databases: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
1184
+ name: /* @__PURE__ */ optional(/* @__PURE__ */ nullable(/* @__PURE__ */ string())),
1185
+ bucket: /* @__PURE__ */ optional(/* @__PURE__ */ nullable(/* @__PURE__ */ string())),
1186
+ directory: /* @__PURE__ */ optional(/* @__PURE__ */ nullable(/* @__PURE__ */ string())),
1187
+ day: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
1188
+ time: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
1189
+ cron: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
1190
+ notification_email: /* @__PURE__ */ optional(/* @__PURE__ */ nullable(/* @__PURE__ */ string()))
1140
1191
  }),
1141
1192
  update: /* @__PURE__ */ object({
1142
1193
  server_id: /* @__PURE__ */ string(),
@@ -1382,11 +1433,11 @@ var TOOLS = [{
1382
1433
  },
1383
1434
  provider: {
1384
1435
  type: "string",
1385
- description: "Server provider (e.g. ocean2, linode, aws)"
1436
+ description: "Server provider (e.g. ocean2, linode, aws), or storage provider type (s3, spaces, hetzner, ovh, scaleway, custom)"
1386
1437
  },
1387
1438
  region: {
1388
1439
  type: "string",
1389
- description: "Server region (e.g. nyc3, us-east-1)"
1440
+ description: "Server region (e.g. nyc3, us-east-1), or storage provider bucket region"
1390
1441
  },
1391
1442
  size: {
1392
1443
  type: "string",
@@ -1459,7 +1510,60 @@ var TOOLS = [{
1459
1510
  },
1460
1511
  frequency: {
1461
1512
  type: "string",
1462
- description: "Cron frequency for scheduled jobs (e.g. minutely, hourly, nightly, custom)"
1513
+ description: "Frequency: scheduled jobs (minutely, hourly, nightly, custom) or backups (hourly, daily, weekly, custom)"
1514
+ },
1515
+ endpoint: {
1516
+ type: "string",
1517
+ description: "S3 endpoint URL for storage providers (e.g. https://s3.example.com)"
1518
+ },
1519
+ bucket: {
1520
+ type: "string",
1521
+ description: "Bucket for storage providers and backups"
1522
+ },
1523
+ directory: {
1524
+ type: "string",
1525
+ description: "Directory in the bucket for storage providers and backups"
1526
+ },
1527
+ access_key: {
1528
+ type: "string",
1529
+ description: "Storage provider access key ID"
1530
+ },
1531
+ secret_key: {
1532
+ type: "string",
1533
+ description: "Storage provider secret access key"
1534
+ },
1535
+ storage_provider_id: {
1536
+ type: "number",
1537
+ description: "Storage provider ID for backups (from storage-providers list)"
1538
+ },
1539
+ retention: {
1540
+ type: "number",
1541
+ description: "Number of backups to keep (1-8760)"
1542
+ },
1543
+ database_ids: {
1544
+ type: "array",
1545
+ description: "Database IDs to back up (at least one)",
1546
+ items: { type: "number" }
1547
+ },
1548
+ include_new_databases: {
1549
+ type: "boolean",
1550
+ description: "Backups: also back up databases created later"
1551
+ },
1552
+ day: {
1553
+ type: "string",
1554
+ description: "Weekly backups: day of week, 0 (Sunday) to 6"
1555
+ },
1556
+ time: {
1557
+ type: "string",
1558
+ description: "Daily or weekly backups: HH:MM on the hour or half hour (e.g. 02:00)"
1559
+ },
1560
+ cron: {
1561
+ type: "string",
1562
+ description: "Custom backups: cron expression"
1563
+ },
1564
+ notification_email: {
1565
+ type: "string",
1566
+ description: "Backups: email notified when a backup fails"
1463
1567
  },
1464
1568
  script: {
1465
1569
  type: "string",
@@ -3137,35 +3241,99 @@ var RESOURCE_HELP = {
3137
3241
  }]
3138
3242
  },
3139
3243
  backups: {
3140
- description: "Manage backup configurations — automated database backups to S3, Spaces, or other providers",
3244
+ description: "Manage database backup configurations — scheduled database backups to a storage provider (see storage-providers)",
3141
3245
  scope: "server (requires server_id)",
3142
3246
  actions: {
3143
3247
  list: "List backup configurations on a server",
3144
3248
  get: "Get backup config details (databases, schedule, retention)",
3145
3249
  create: "Create a new backup configuration",
3250
+ update: "Update a backup configuration (send every required field)",
3146
3251
  delete: "Delete a backup configuration"
3147
3252
  },
3148
3253
  fields: {
3149
- provider: "Backup provider (s3, spaces, custom)",
3150
- credentials: "Provider credentials (keys, bucket, region)",
3151
- schedule: "Backup schedule (daily, weekly, custom cron)",
3152
- databases: "Array of database IDs to back up",
3153
- retention: "Number of backups to retain"
3254
+ storage_provider_id: "Storage provider ID (from storage-providers list)",
3255
+ frequency: "hourly, daily, weekly or custom",
3256
+ day: "Weekly: day of week, 0 (Sunday) to 6",
3257
+ time: "Daily or weekly: HH:MM on the hour or half hour, e.g. 02:00",
3258
+ cron: "Custom: cron expression",
3259
+ retention: "Number of backups to keep (1-8760)",
3260
+ database_ids: "Array of database IDs to back up (at least one)",
3261
+ include_new_databases: "Also back up databases created later",
3262
+ bucket: "Bucket (overrides the provider bucket)",
3263
+ directory: "Directory in the bucket",
3264
+ notification_email: "Email notified when a backup fails"
3265
+ },
3266
+ examples: [
3267
+ {
3268
+ description: "List backup configs",
3269
+ params: {
3270
+ resource: "backups",
3271
+ action: "list",
3272
+ server_id: "123"
3273
+ }
3274
+ },
3275
+ {
3276
+ description: "Get backup config details",
3277
+ params: {
3278
+ resource: "backups",
3279
+ action: "get",
3280
+ server_id: "123",
3281
+ id: "456"
3282
+ }
3283
+ },
3284
+ {
3285
+ description: "Back up two databases every day at 02:00 and keep 7 backups",
3286
+ params: {
3287
+ resource: "backups",
3288
+ action: "create",
3289
+ server_id: "123",
3290
+ storage_provider_id: 7,
3291
+ frequency: "daily",
3292
+ time: "02:00",
3293
+ retention: 7,
3294
+ directory: "web-1",
3295
+ database_ids: [11, 12]
3296
+ }
3297
+ }
3298
+ ]
3299
+ },
3300
+ "storage-providers": {
3301
+ description: "Manage the organization's storage providers — S3-compatible buckets used by database backups",
3302
+ scope: "global (no parent ID needed)",
3303
+ actions: {
3304
+ list: "List storage providers (filter with provider, e.g. custom)",
3305
+ get: "Get storage provider details (keys are never returned)",
3306
+ create: "Create a storage provider",
3307
+ delete: "Delete a storage provider (fails when a backup configuration uses it)"
3308
+ },
3309
+ fields: {
3310
+ name: "Provider name",
3311
+ provider: "s3, spaces, hetzner, ovh, scaleway or custom (S3 compatible)",
3312
+ endpoint: "S3 endpoint URL (custom providers)",
3313
+ region: "Bucket region",
3314
+ bucket: "Default bucket",
3315
+ directory: "Default directory",
3316
+ access_key: "Access key ID",
3317
+ secret_key: "Secret access key"
3154
3318
  },
3155
3319
  examples: [{
3156
- description: "List backup configs",
3320
+ description: "List storage providers",
3157
3321
  params: {
3158
- resource: "backups",
3159
- action: "list",
3160
- server_id: "123"
3322
+ resource: "storage-providers",
3323
+ action: "list"
3161
3324
  }
3162
3325
  }, {
3163
- description: "Get backup config details",
3326
+ description: "Create a custom S3-compatible provider",
3164
3327
  params: {
3165
- resource: "backups",
3166
- action: "get",
3167
- server_id: "123",
3168
- id: "456"
3328
+ resource: "storage-providers",
3329
+ action: "create",
3330
+ name: "Backups",
3331
+ provider: "custom",
3332
+ endpoint: "https://s3.example.com",
3333
+ region: "eu-west-1",
3334
+ bucket: "my-bucket",
3335
+ access_key: "<access-key>",
3336
+ secret_key: "<secret-key>"
3169
3337
  }
3170
3338
  }]
3171
3339
  },
@@ -4288,6 +4456,7 @@ var RESOURCE_SCHEMAS = {
4288
4456
  "list",
4289
4457
  "get",
4290
4458
  "create",
4459
+ "update",
4291
4460
  "delete"
4292
4461
  ],
4293
4462
  scope: "server",
@@ -4296,41 +4465,121 @@ var RESOURCE_SCHEMAS = {
4296
4465
  get: ["server_id", "id"],
4297
4466
  create: [
4298
4467
  "server_id",
4299
- "provider",
4300
- "credentials",
4468
+ "storage_provider_id",
4301
4469
  "frequency",
4302
- "databases"
4470
+ "retention",
4471
+ "database_ids"
4472
+ ],
4473
+ update: [
4474
+ "server_id",
4475
+ "id",
4476
+ "storage_provider_id",
4477
+ "frequency",
4478
+ "retention",
4479
+ "database_ids"
4303
4480
  ],
4304
4481
  delete: ["server_id", "id"]
4305
4482
  },
4306
4483
  create: {
4307
- provider: {
4484
+ storage_provider_id: {
4308
4485
  required: true,
4309
- type: "string — s3, spaces, custom"
4486
+ type: "number — storage provider ID"
4310
4487
  },
4311
- credentials: {
4488
+ frequency: {
4312
4489
  required: true,
4313
- type: "object — provider credentials (key, secret, etc.)"
4490
+ type: "string — hourly, daily, weekly, custom"
4314
4491
  },
4315
- frequency: {
4492
+ retention: {
4316
4493
  required: true,
4317
- type: "string — daily, weekly, custom"
4494
+ type: "number — backups to keep (1-8760)"
4318
4495
  },
4319
- databases: {
4496
+ database_ids: {
4320
4497
  required: true,
4321
- type: "array — database IDs to back up"
4498
+ type: "number[] — database IDs to back up (at least one)"
4499
+ },
4500
+ include_new_databases: {
4501
+ required: false,
4502
+ type: "boolean — also back up new databases"
4503
+ },
4504
+ name: {
4505
+ required: false,
4506
+ type: "string — configuration name"
4507
+ },
4508
+ bucket: {
4509
+ required: false,
4510
+ type: "string — bucket (overrides the provider bucket)"
4322
4511
  },
4323
4512
  directory: {
4324
4513
  required: false,
4325
- type: "string — backup directory"
4514
+ type: "string — directory in the bucket"
4326
4515
  },
4327
- email: {
4516
+ day: {
4328
4517
  required: false,
4329
- type: "string — notification email"
4518
+ type: "string — weekly: day of week, 0 (Sunday) to 6"
4330
4519
  },
4331
- retention: {
4520
+ time: {
4521
+ required: false,
4522
+ type: "string — daily/weekly: HH:MM on the hour or half hour"
4523
+ },
4524
+ cron: {
4525
+ required: false,
4526
+ type: "string — custom: cron expression"
4527
+ },
4528
+ notification_email: {
4332
4529
  required: false,
4333
- type: "number — backups to retain (default: 7)"
4530
+ type: "string — email notified on failure"
4531
+ }
4532
+ }
4533
+ },
4534
+ "storage-providers": {
4535
+ actions: [
4536
+ "list",
4537
+ "get",
4538
+ "create",
4539
+ "delete"
4540
+ ],
4541
+ scope: "global",
4542
+ required: {
4543
+ get: ["id"],
4544
+ create: ["name", "provider"],
4545
+ delete: ["id"]
4546
+ },
4547
+ create: {
4548
+ name: {
4549
+ required: true,
4550
+ type: "string — provider name"
4551
+ },
4552
+ provider: {
4553
+ required: true,
4554
+ type: "string — s3, spaces, hetzner, ovh, scaleway, custom"
4555
+ },
4556
+ endpoint: {
4557
+ required: false,
4558
+ type: "string — S3 endpoint URL (custom providers)"
4559
+ },
4560
+ region: {
4561
+ required: false,
4562
+ type: "string — bucket region"
4563
+ },
4564
+ bucket: {
4565
+ required: false,
4566
+ type: "string — default bucket"
4567
+ },
4568
+ directory: {
4569
+ required: false,
4570
+ type: "string — default directory"
4571
+ },
4572
+ access_key: {
4573
+ required: false,
4574
+ type: "string — access key ID"
4575
+ },
4576
+ secret_key: {
4577
+ required: false,
4578
+ type: "string — secret access key"
4579
+ },
4580
+ assume_role: {
4581
+ required: false,
4582
+ type: "boolean — use the EC2 instance role (s3)"
4334
4583
  }
4335
4584
  }
4336
4585
  },
@@ -4858,6 +5107,48 @@ var handleSshKeys = createResourceHandler({
4858
5107
  }
4859
5108
  });
4860
5109
  //#endregion
5110
+ //#region src/handlers/storage-providers.ts
5111
+ var handleStorageProviders = createResourceHandler({
5112
+ resource: "storage-providers",
5113
+ actions: [
5114
+ "list",
5115
+ "get",
5116
+ "create",
5117
+ "delete"
5118
+ ],
5119
+ inputSchemas: {
5120
+ get: /* @__PURE__ */ object({ id: /* @__PURE__ */ string() }),
5121
+ create: /* @__PURE__ */ object({
5122
+ name: /* @__PURE__ */ string(),
5123
+ provider: /* @__PURE__ */ picklist(STORAGE_PROVIDER_TYPES),
5124
+ region: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
5125
+ bucket: /* @__PURE__ */ optional(/* @__PURE__ */ nullable(/* @__PURE__ */ string())),
5126
+ directory: /* @__PURE__ */ optional(/* @__PURE__ */ nullable(/* @__PURE__ */ string())),
5127
+ endpoint: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
5128
+ access_key: /* @__PURE__ */ optional(/* @__PURE__ */ nullable(/* @__PURE__ */ string())),
5129
+ secret_key: /* @__PURE__ */ optional(/* @__PURE__ */ nullable(/* @__PURE__ */ string())),
5130
+ assume_role: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
5131
+ }),
5132
+ delete: /* @__PURE__ */ object({ id: /* @__PURE__ */ string() })
5133
+ },
5134
+ executors: {
5135
+ list: listStorageProviders,
5136
+ get: getStorageProvider,
5137
+ create: createStorageProvider,
5138
+ delete: deleteStorageProvider
5139
+ },
5140
+ formatResult: (action, data, args) => {
5141
+ switch (action) {
5142
+ case "list": return formatStorageProviderList(data);
5143
+ case "get":
5144
+ case "create": return formatStorageProvider(data);
5145
+ case "delete": return `Storage provider ${args.id} deleted.`;
5146
+ /* v8 ignore next */
5147
+ default: return "Done.";
5148
+ }
5149
+ }
5150
+ });
5151
+ //#endregion
4861
5152
  //#region src/handlers/user.ts
4862
5153
  var handleUser = createResourceHandler({
4863
5154
  resource: "user",
@@ -4962,6 +5253,7 @@ function routeToHandler(resource, action, args, ctx) {
4962
5253
  case "nginx-templates": return handleNginxTemplates(action, args, ctx);
4963
5254
  case "recipes": return handleRecipes(action, args, ctx);
4964
5255
  case "backups": return handleBackups(action, args, ctx);
5256
+ case "storage-providers": return handleStorageProviders(action, args, ctx);
4965
5257
  case "commands": return handleCommands(action, args, ctx);
4966
5258
  case "scheduled-jobs": return handleScheduledJobs(action, args, ctx);
4967
5259
  case "services": return handleServices(action, args, ctx);
@@ -5055,8 +5347,8 @@ async function executeToolWithCredentials(name, args, credentials) {
5055
5347
  }
5056
5348
  //#endregion
5057
5349
  //#region src/version.ts
5058
- var VERSION = "0.4.8";
5350
+ var VERSION = "0.5.1";
5059
5351
  //#endregion
5060
5352
  export { INSTRUCTIONS as a, getTools as i, executeToolWithCredentials as n, STDIO_ONLY_TOOLS as r, VERSION as t };
5061
5353
 
5062
- //# sourceMappingURL=version-Cc6wPkZg.js.map
5354
+ //# sourceMappingURL=version-dKDIfOKC.js.map