@mycompbox/compbox-mcp 1.21.8 → 1.21.9

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 +204 -18
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1711,6 +1711,12 @@ function stackEnvironments(tier) {
1711
1711
  function deployRunTitle(environment) {
1712
1712
  return `Deploy to ${environment}`;
1713
1713
  }
1714
+ function teardownRunTitle(environment) {
1715
+ return `Tear down ${environment}`;
1716
+ }
1717
+ function teardownConfirmation(app, environment) {
1718
+ return `${app}-${environment}`;
1719
+ }
1714
1720
  function cloudRunUrl(service, projectNumber, region) {
1715
1721
  return `https://${service}-${projectNumber}.${region}.run.app`;
1716
1722
  }
@@ -1726,8 +1732,8 @@ function cloudSqlInstanceName(app, environment) {
1726
1732
  function databaseSecretName(app, environment, database) {
1727
1733
  return `${app}-${environment}-${database === "cloudsql" ? "cloudsql-url" : "database-url"}`;
1728
1734
  }
1729
- function envSettings(env) {
1730
- return env === "prod" ? { min: 0, max: 10 } : { min: 0, max: 2 };
1735
+ function stackEnvSettings(tier) {
1736
+ return stackEnvironments(tier).map((environment) => environment === "prod" ? { environment, minInstances: 0, maxInstances: 10 } : { environment, minInstances: 0, maxInstances: 2 });
1731
1737
  }
1732
1738
  function buildStackFiles(input) {
1733
1739
  const { tier, app, defaultBranch, cloud } = input;
@@ -1742,6 +1748,16 @@ function buildStackFiles(input) {
1742
1748
  const envs = stackEnvironments(tier);
1743
1749
  const registry = `${cloud.region}-docker.pkg.dev/${cloud.projectId}/${app}`;
1744
1750
  const files = [];
1751
+ const stateBucket = gcpStateBucket(cloud.projectId);
1752
+ const cloudSetupSteps = ` - uses: google-github-actions/auth@v2
1753
+ with:
1754
+ workload_identity_provider: ${cloud.workloadProvider}
1755
+ service_account: ${cloud.serviceAccountEmail}
1756
+
1757
+ - uses: google-github-actions/setup-gcloud@v2
1758
+
1759
+ - uses: hashicorp/setup-terraform@v3`;
1760
+ const terraformInit = `terraform init -input=false -backend-config="bucket=$STATE_BUCKET" -backend-config="prefix=$APP/$ENVIRONMENT"`;
1745
1761
  files.push({
1746
1762
  path: "infra/versions.tf",
1747
1763
  content: `# Managed by CompBox. Changes here are applied on the next deploy.
@@ -1948,16 +1964,16 @@ output "database_instance" {
1948
1964
  `
1949
1965
  });
1950
1966
  }
1951
- for (const env of envs) {
1952
- const s = envSettings(env);
1967
+ for (const s of stackEnvSettings(tier)) {
1968
+ const env = s.environment;
1953
1969
  files.push({
1954
1970
  path: `infra/envs/${env}.tfvars`,
1955
1971
  content: `project_id = "${cloud.projectId}"
1956
1972
  region = "${cloud.region}"
1957
1973
  app = "${app}"
1958
1974
  environment = "${env}"
1959
- min_instances = ${String(s.min)}
1960
- max_instances = ${String(s.max)}
1975
+ min_instances = ${String(s.minInstances)}
1976
+ max_instances = ${String(s.maxInstances)}
1961
1977
  `
1962
1978
  });
1963
1979
  }
@@ -2025,7 +2041,7 @@ env:
2025
2041
  REGION: ${cloud.region}
2026
2042
  APP: ${app}
2027
2043
  IMAGE: ${registry}/app:\${{ github.sha }}
2028
- STATE_BUCKET: ${gcpStateBucket(cloud.projectId)}
2044
+ STATE_BUCKET: ${stateBucket}
2029
2045
 
2030
2046
  jobs:
2031
2047
  build:
@@ -2038,19 +2054,12 @@ jobs:
2038
2054
  steps:
2039
2055
  - uses: actions/checkout@v4
2040
2056
 
2041
- - uses: google-github-actions/auth@v2
2042
- with:
2043
- workload_identity_provider: ${cloud.workloadProvider}
2044
- service_account: ${cloud.serviceAccountEmail}
2045
-
2046
- - uses: google-github-actions/setup-gcloud@v2
2047
-
2048
- - uses: hashicorp/setup-terraform@v3
2057
+ ${cloudSetupSteps}
2049
2058
 
2050
2059
  - name: Infrastructure
2051
2060
  working-directory: infra
2052
2061
  run: |
2053
- terraform init -input=false -backend-config="bucket=$STATE_BUCKET" -backend-config="prefix=$APP/$ENVIRONMENT"
2062
+ ${terraformInit}
2054
2063
  terraform apply -input=false -auto-approve -var-file="envs/$ENVIRONMENT.tfvars"
2055
2064
 
2056
2065
  ${cloudSql ? ` - name: Database secret
@@ -2176,6 +2185,85 @@ ${cloudSql ? ` - name: Database secret
2176
2185
  echo "### Live at $URL" >> "$GITHUB_STEP_SUMMARY"
2177
2186
  `
2178
2187
  });
2188
+ if (tier === "full") {
2189
+ files.push({
2190
+ path: `.github/workflows/${TEARDOWN_WORKFLOW}`,
2191
+ content: `# Managed by CompBox. Destroys stage or prod; dev is never torn down here.
2192
+ # Start it from CompBox, or Actions \u2192 CompBox teardown \u2192 Run workflow and type "${app}-<environment>".
2193
+ name: CompBox teardown
2194
+ run-name: Tear down \${{ inputs.environment }}
2195
+
2196
+ on:
2197
+ workflow_dispatch:
2198
+ inputs:
2199
+ environment:
2200
+ description: What to tear down
2201
+ type: choice
2202
+ options:
2203
+ ${TEARDOWN_ENVIRONMENTS.map((e) => ` - ${e}`).join("\n")}
2204
+ confirm:
2205
+ description: Type ${app}-<environment> to confirm
2206
+ type: string
2207
+ required: true
2208
+
2209
+ permissions:
2210
+ contents: read
2211
+ id-token: write
2212
+
2213
+ concurrency:
2214
+ group: compbox-\${{ inputs.environment }}
2215
+ cancel-in-progress: false
2216
+
2217
+ jobs:
2218
+ teardown:
2219
+ runs-on: ubuntu-latest
2220
+ environment:
2221
+ name: \${{ inputs.environment }}
2222
+ env:
2223
+ ENVIRONMENT: \${{ inputs.environment }}
2224
+ CONFIRM: \${{ inputs.confirm }}
2225
+ APP: ${app}
2226
+ STATE_BUCKET: ${stateBucket}
2227
+ steps:
2228
+ - name: Confirm
2229
+ run: |
2230
+ case "$ENVIRONMENT" in
2231
+ stage|prod) ;;
2232
+ *) echo "::error::Only stage and prod can be torn down."; exit 1 ;;
2233
+ esac
2234
+ if [ "$CONFIRM" != "$APP-$ENVIRONMENT" ]; then
2235
+ echo "::error::Type $APP-$ENVIRONMENT to confirm the teardown."
2236
+ exit 1
2237
+ fi
2238
+
2239
+ - uses: actions/checkout@v4
2240
+
2241
+ ${cloudSetupSteps}
2242
+
2243
+ - name: Init
2244
+ working-directory: infra
2245
+ run: ${terraformInit}
2246
+
2247
+ # main.tf keeps prod's service protected; a Terraform override file
2248
+ # (created only on the runner, never committed) lifts that for this run.
2249
+ - name: Turn off deletion protection
2250
+ if: inputs.environment == 'prod'
2251
+ working-directory: infra
2252
+ run: |
2253
+ printf '%s\\n' 'resource "google_cloud_run_v2_service" "app" {' ' deletion_protection = false' '}' > compbox_teardown_override.tf
2254
+ terraform apply -input=false -auto-approve -var-file="envs/$ENVIRONMENT.tfvars" -target=google_cloud_run_v2_service.app
2255
+
2256
+ - name: Destroy
2257
+ working-directory: infra
2258
+ run: terraform destroy -input=false -auto-approve -var-file="envs/$ENVIRONMENT.tfvars"
2259
+
2260
+ - name: Remove state
2261
+ run: |
2262
+ gcloud storage rm -r "gs://$STATE_BUCKET/$APP/$ENVIRONMENT"
2263
+ echo "### $APP-$ENVIRONMENT torn down" >> "$GITHUB_STEP_SUMMARY"
2264
+ `
2265
+ });
2266
+ }
2179
2267
  files.push({
2180
2268
  path: "infra/README.md",
2181
2269
  content: `# Infrastructure (managed by CompBox)
@@ -2191,7 +2279,7 @@ This project deploys to Google Cloud project \`${cloud.projectId}\` (${cloud.reg
2191
2279
  });
2192
2280
  return files;
2193
2281
  }
2194
- var STACK_TIERS, STACK_WORKFLOW, CLOUD_SQL_PROXY_VERSION, APP, BRANCH;
2282
+ var STACK_TIERS, STACK_WORKFLOW, TEARDOWN_WORKFLOW, TEARDOWN_ENVIRONMENTS, CLOUD_SQL_PROXY_VERSION, APP, BRANCH;
2195
2283
  var init_stack_files = __esm({
2196
2284
  "../shared/dist/stack-files.js"() {
2197
2285
  "use strict";
@@ -2201,12 +2289,102 @@ var init_stack_files = __esm({
2201
2289
  full: { label: "Dev, stage and prod", environments: ["dev", "stage", "prod"] }
2202
2290
  };
2203
2291
  STACK_WORKFLOW = "compbox.yml";
2292
+ TEARDOWN_WORKFLOW = "compbox-teardown.yml";
2293
+ TEARDOWN_ENVIRONMENTS = ["stage", "prod"];
2204
2294
  CLOUD_SQL_PROXY_VERSION = "v2.14.1";
2205
2295
  APP = /^[a-z][a-z0-9-]{1,19}$/;
2206
2296
  BRANCH = /^[A-Za-z0-9._/-]{1,200}$/;
2207
2297
  }
2208
2298
  });
2209
2299
 
2300
+ // ../shared/dist/stack-cost.js
2301
+ function lowUsage() {
2302
+ const busySeconds = LOW_REQUESTS * LOW_REQUEST_SECONDS;
2303
+ return {
2304
+ vcpuSeconds: busySeconds * INSTANCE_VCPU,
2305
+ gibSeconds: busySeconds * INSTANCE_GIB,
2306
+ requests: LOW_REQUESTS,
2307
+ imagesGb: LOW_IMAGES_GB
2308
+ };
2309
+ }
2310
+ function highUsage(maxInstances) {
2311
+ const busySeconds = maxInstances * MONTH_SECONDS * HIGH_BUSY_SHARE;
2312
+ return {
2313
+ vcpuSeconds: busySeconds * INSTANCE_VCPU,
2314
+ gibSeconds: busySeconds * INSTANCE_GIB,
2315
+ requests: busySeconds * HIGH_REQUESTS_PER_SECOND,
2316
+ imagesGb: HIGH_IMAGES_GB
2317
+ };
2318
+ }
2319
+ function cost(usage, free, p) {
2320
+ const take = (key) => {
2321
+ const covered = Math.min(usage[key], free[key]);
2322
+ free[key] -= covered;
2323
+ return usage[key] - covered;
2324
+ };
2325
+ return take("vcpuSeconds") * p.cloudRunVcpuSecond + take("gibSeconds") * p.cloudRunGibSecond + take("requests") / 1e6 * p.cloudRunPerMillionRequests + usage.imagesGb * p.artifactRegistryGbMonth + STATE_GB * p.storageGbMonth;
2326
+ }
2327
+ function estimateStackCost(tier, cloud) {
2328
+ if (cloud.provider !== "gcp")
2329
+ return null;
2330
+ const p = STACK_PRICING.gcp;
2331
+ const settings = stackEnvSettings(tier);
2332
+ const lowFree = { ...p.freeTier };
2333
+ const highFree = { ...p.freeTier };
2334
+ const environments = settings.map((s) => ({
2335
+ environment: s.environment,
2336
+ low: Math.round(cost(lowUsage(), lowFree, p)),
2337
+ high: Math.round(cost(highUsage(s.maxInstances), highFree, p))
2338
+ }));
2339
+ const total = environments.reduce((t, e) => ({ low: t.low + e.low, high: t.high + e.high }), { low: 0, high: 0 });
2340
+ const busyHours = Math.round(MONTH_SECONDS * HIGH_BUSY_SHARE / 3600);
2341
+ return {
2342
+ currency: p.currency,
2343
+ pricesAsOf: p.pricesAsOf,
2344
+ calculatorUrl: p.calculatorUrl,
2345
+ environments,
2346
+ total,
2347
+ assumptions: [
2348
+ `List prices for Google Cloud as of ${p.pricesAsOf}, for a Tier 1 region; ${cloud.region} may cost more if it is a Tier 2 region.`,
2349
+ `Each instance has ${String(INSTANCE_VCPU)} vCPU and ${String(INSTANCE_GIB * 1024)} MiB of memory and is billed only while handling requests.`,
2350
+ `Low: light traffic \u2014 about ${LOW_REQUESTS.toLocaleString("en-US")} requests a month per environment, ${String(LOW_REQUEST_SECONDS * 1e3)} ms each; the app scales to zero when idle.`,
2351
+ `High: every allowed instance (${settings.map((s) => `${s.environment} ${String(s.maxInstances)}`).join(", ")}) busy for ${String(HIGH_BUSY_SHARE * 100)}% of the month (about ${String(busyHours)} hours), serving ${String(HIGH_REQUESTS_PER_SECOND)} requests a second each.`,
2352
+ `Google's monthly free tier (${p.freeTier.vcpuSeconds.toLocaleString("en-US")} vCPU-seconds, ${p.freeTier.gibSeconds.toLocaleString("en-US")} GiB-seconds, ${(p.freeTier.requests / 1e6).toLocaleString("en-US")} million requests) is counted once for the whole stack.`,
2353
+ `Includes ${String(LOW_IMAGES_GB)}\u2013${String(HIGH_IMAGES_GB)} GB of stored container images per environment; databases, networking and other services you add are not included.`
2354
+ ]
2355
+ };
2356
+ }
2357
+ var STACK_PRICING, INSTANCE_VCPU, INSTANCE_GIB, MONTH_SECONDS, LOW_REQUESTS, LOW_REQUEST_SECONDS, LOW_IMAGES_GB, HIGH_BUSY_SHARE, HIGH_REQUESTS_PER_SECOND, HIGH_IMAGES_GB, STATE_GB;
2358
+ var init_stack_cost = __esm({
2359
+ "../shared/dist/stack-cost.js"() {
2360
+ "use strict";
2361
+ init_stack_files();
2362
+ STACK_PRICING = {
2363
+ gcp: {
2364
+ pricesAsOf: "2026-05-11",
2365
+ calculatorUrl: "https://cloud.google.com/products/calculator",
2366
+ currency: "USD",
2367
+ cloudRunVcpuSecond: 24e-6,
2368
+ cloudRunGibSecond: 25e-7,
2369
+ cloudRunPerMillionRequests: 0.4,
2370
+ freeTier: { vcpuSeconds: 18e4, gibSeconds: 36e4, requests: 2e6 },
2371
+ artifactRegistryGbMonth: 0.1,
2372
+ storageGbMonth: 0.02
2373
+ }
2374
+ };
2375
+ INSTANCE_VCPU = 1;
2376
+ INSTANCE_GIB = 0.5;
2377
+ MONTH_SECONDS = 30 * 24 * 60 * 60;
2378
+ LOW_REQUESTS = 1e4;
2379
+ LOW_REQUEST_SECONDS = 0.2;
2380
+ LOW_IMAGES_GB = 0.5;
2381
+ HIGH_BUSY_SHARE = 0.25;
2382
+ HIGH_REQUESTS_PER_SECOND = 20;
2383
+ HIGH_IMAGES_GB = 2;
2384
+ STATE_GB = 0.01;
2385
+ }
2386
+ });
2387
+
2210
2388
  // ../shared/dist/github-repo.js
2211
2389
  function githubRepoKey(remote) {
2212
2390
  if (typeof remote !== "string")
@@ -2297,6 +2475,7 @@ __export(dist_exports, {
2297
2475
  ORG_ROLES: () => ORG_ROLES,
2298
2476
  PXPIPE_DEFAULT_PROXY_URL: () => PXPIPE_DEFAULT_PROXY_URL,
2299
2477
  RETURN_TO_MAX_LENGTH: () => RETURN_TO_MAX_LENGTH,
2478
+ STACK_PRICING: () => STACK_PRICING,
2300
2479
  STACK_TIERS: () => STACK_TIERS,
2301
2480
  STACK_WORKFLOW: () => STACK_WORKFLOW,
2302
2481
  START_EXECUTION_KINDS: () => START_EXECUTION_KINDS,
@@ -2304,6 +2483,8 @@ __export(dist_exports, {
2304
2483
  SUMMARY_MAX: () => SUMMARY_MAX,
2305
2484
  SessionEventType: () => SessionEventType,
2306
2485
  TARGET_COMPLIANCE_TIER: () => TARGET_COMPLIANCE_TIER,
2486
+ TEARDOWN_ENVIRONMENTS: () => TEARDOWN_ENVIRONMENTS,
2487
+ TEARDOWN_WORKFLOW: () => TEARDOWN_WORKFLOW,
2307
2488
  TERMINAL_JOB_STATUSES: () => TERMINAL_JOB_STATUSES,
2308
2489
  TURN_ROLES: () => TURN_ROLES,
2309
2490
  agentSchema: () => agentSchema,
@@ -2325,6 +2506,7 @@ __export(dist_exports, {
2325
2506
  databaseSecretName: () => databaseSecretName,
2326
2507
  deployRunTitle: () => deployRunTitle,
2327
2508
  err: () => err,
2509
+ estimateStackCost: () => estimateStackCost,
2328
2510
  extractCompletionJson: () => extractCompletionJson,
2329
2511
  gcpServiceAccountEmail: () => gcpServiceAccountEmail,
2330
2512
  gcpStateBucket: () => gcpStateBucket,
@@ -2387,7 +2569,10 @@ __export(dist_exports, {
2387
2569
  skillSchema: () => skillSchema,
2388
2570
  sleep: () => sleep,
2389
2571
  stackAppName: () => stackAppName,
2572
+ stackEnvSettings: () => stackEnvSettings,
2390
2573
  stackEnvironments: () => stackEnvironments,
2574
+ teardownConfirmation: () => teardownConfirmation,
2575
+ teardownRunTitle: () => teardownRunTitle,
2391
2576
  thinkingLevelValues: () => thinkingLevelValues,
2392
2577
  toConversationMessages: () => toConversationMessages,
2393
2578
  validatePackName: () => validatePackName,
@@ -2408,6 +2593,7 @@ var init_dist = __esm({
2408
2593
  init_cloud_setup();
2409
2594
  init_cloud_connect();
2410
2595
  init_stack_files();
2596
+ init_stack_cost();
2411
2597
  init_github_repo();
2412
2598
  init_return_to();
2413
2599
  }
@@ -12636,7 +12822,7 @@ function withLegacyToolCallRewrite(transport) {
12636
12822
  var SERVER_NAME = "compbox-mcp";
12637
12823
  function resolveServerVersion() {
12638
12824
  if (true) {
12639
- return "1.21.8";
12825
+ return "1.21.9";
12640
12826
  }
12641
12827
  const require2 = createRequire(import.meta.url);
12642
12828
  for (const candidate of ["../package.json", "./package.json"]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycompbox/compbox-mcp",
3
- "version": "1.21.8",
3
+ "version": "1.21.9",
4
4
  "description": "CompBox MCP server - Uses HTTP API client (no direct database access)",
5
5
  "license": "MIT",
6
6
  "type": "module",