@sfdxy/anypoint-connect 0.14.0 → 0.16.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/README.md +39 -16
- package/dist/analysis/LogAnalyzer.d.ts +10 -4
- package/dist/analysis/LogAnalyzer.d.ts.map +1 -1
- package/dist/analysis/LogAnalyzer.js +29 -18
- package/dist/analysis/LogAnalyzer.js.map +1 -1
- package/dist/analysis/error-context.d.ts +2 -0
- package/dist/analysis/error-context.d.ts.map +1 -1
- package/dist/analysis/error-context.js +2 -1
- package/dist/analysis/error-context.js.map +1 -1
- package/dist/analysis/error-grouper.js +1 -1
- package/dist/analysis/error-grouper.js.map +1 -1
- package/dist/analysis/filter.d.ts +54 -0
- package/dist/analysis/filter.d.ts.map +1 -0
- package/dist/analysis/filter.js +100 -0
- package/dist/analysis/filter.js.map +1 -0
- package/dist/analysis/{utils.d.ts → normalize.d.ts} +1 -1
- package/dist/analysis/normalize.d.ts.map +1 -0
- package/dist/analysis/{utils.js → normalize.js} +2 -2
- package/dist/analysis/normalize.js.map +1 -0
- package/dist/analysis/parser.d.ts.map +1 -1
- package/dist/analysis/parser.js +45 -17
- package/dist/analysis/parser.js.map +1 -1
- package/dist/analysis/pattern-detector.js +1 -1
- package/dist/analysis/pattern-detector.js.map +1 -1
- package/dist/analysis/stats.d.ts +25 -0
- package/dist/analysis/stats.d.ts.map +1 -1
- package/dist/analysis/stats.js +35 -1
- package/dist/analysis/stats.js.map +1 -1
- package/dist/analysis/summary.d.ts +51 -0
- package/dist/analysis/summary.d.ts.map +1 -0
- package/dist/analysis/summary.js +47 -0
- package/dist/analysis/summary.js.map +1 -0
- package/dist/analysis/types.d.ts +14 -0
- package/dist/analysis/types.d.ts.map +1 -1
- package/dist/api/ApiManagerApi.d.ts +53 -0
- package/dist/api/ApiManagerApi.d.ts.map +1 -1
- package/dist/api/ApiManagerApi.js +53 -2
- package/dist/api/ApiManagerApi.js.map +1 -1
- package/dist/api/CloudHub2Api.d.ts +24 -4
- package/dist/api/CloudHub2Api.d.ts.map +1 -1
- package/dist/api/CloudHub2Api.js +10 -22
- package/dist/api/CloudHub2Api.js.map +1 -1
- package/dist/api/DesignCenterApi.d.ts +0 -20
- package/dist/api/DesignCenterApi.d.ts.map +1 -1
- package/dist/api/DesignCenterApi.js +0 -22
- package/dist/api/DesignCenterApi.js.map +1 -1
- package/dist/api/ExchangeApi.d.ts +15 -0
- package/dist/api/ExchangeApi.d.ts.map +1 -1
- package/dist/api/ExchangeApi.js +51 -0
- package/dist/api/ExchangeApi.js.map +1 -1
- package/dist/api/LogsApi.d.ts +50 -18
- package/dist/api/LogsApi.d.ts.map +1 -1
- package/dist/api/LogsApi.js +69 -98
- package/dist/api/LogsApi.js.map +1 -1
- package/dist/api/MonitoringApi.d.ts +137 -93
- package/dist/api/MonitoringApi.d.ts.map +1 -1
- package/dist/api/MonitoringApi.js +471 -204
- package/dist/api/MonitoringApi.js.map +1 -1
- package/dist/api/RuntimesApi.d.ts +56 -0
- package/dist/api/RuntimesApi.d.ts.map +1 -0
- package/dist/api/RuntimesApi.js +58 -0
- package/dist/api/RuntimesApi.js.map +1 -0
- package/dist/auth/FileStore.js +1 -1
- package/dist/auth/FileStore.js.map +1 -1
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/client/AnypointClient.d.ts +3 -1
- package/dist/client/AnypointClient.d.ts.map +1 -1
- package/dist/client/AnypointClient.js +5 -2
- package/dist/client/AnypointClient.js.map +1 -1
- package/dist/client/smoke-test.d.ts +111 -0
- package/dist/client/smoke-test.d.ts.map +1 -0
- package/dist/client/smoke-test.js +275 -0
- package/dist/client/smoke-test.js.map +1 -0
- package/dist/commands/api.d.ts +1 -1
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/api.js +175 -30
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/app-change-cli.d.ts +52 -0
- package/dist/commands/app-change-cli.d.ts.map +1 -0
- package/dist/commands/app-change-cli.js +149 -0
- package/dist/commands/app-change-cli.js.map +1 -0
- package/dist/commands/apps.d.ts +1 -1
- package/dist/commands/apps.d.ts.map +1 -1
- package/dist/commands/apps.js +199 -18
- package/dist/commands/apps.js.map +1 -1
- package/dist/commands/auth.js +1 -1
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/compare.d.ts +8 -0
- package/dist/commands/compare.d.ts.map +1 -0
- package/dist/commands/compare.js +104 -0
- package/dist/commands/compare.js.map +1 -0
- package/dist/commands/config.js +1 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/deploy.d.ts +6 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +89 -91
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/design-center.d.ts +1 -1
- package/dist/commands/design-center.d.ts.map +1 -1
- package/dist/commands/design-center.js +36 -25
- package/dist/commands/design-center.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/logs.d.ts +3 -2
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +142 -17
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/monitor.d.ts +5 -6
- package/dist/commands/monitor.d.ts.map +1 -1
- package/dist/commands/monitor.js +210 -230
- package/dist/commands/monitor.js.map +1 -1
- package/dist/commands/runtimes.d.ts +7 -0
- package/dist/commands/runtimes.d.ts.map +1 -0
- package/dist/commands/runtimes.js +66 -0
- package/dist/commands/runtimes.js.map +1 -0
- package/dist/commands/shared.d.ts +2 -0
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/shared.js +16 -1
- package/dist/commands/shared.js.map +1 -1
- package/dist/{utils/config.d.ts → config/profiles.d.ts} +9 -1
- package/dist/config/profiles.d.ts.map +1 -0
- package/dist/{utils/config.js → config/profiles.js} +1 -1
- package/dist/config/profiles.js.map +1 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/prompts.js +7 -7
- package/dist/mcp/prompts.js.map +1 -1
- package/dist/mcp/server.d.ts +14 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +61 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/analysis.d.ts.map +1 -1
- package/dist/mcp/tools/analysis.js +74 -46
- package/dist/mcp/tools/analysis.js.map +1 -1
- package/dist/mcp/tools/anypoint-mq.d.ts.map +1 -1
- package/dist/mcp/tools/anypoint-mq.js +25 -54
- package/dist/mcp/tools/anypoint-mq.js.map +1 -1
- package/dist/mcp/tools/api-manager.d.ts +2 -1
- package/dist/mcp/tools/api-manager.d.ts.map +1 -1
- package/dist/mcp/tools/api-manager.js +154 -89
- package/dist/mcp/tools/api-manager.js.map +1 -1
- package/dist/mcp/tools/app-inputs.d.ts +92 -0
- package/dist/mcp/tools/app-inputs.d.ts.map +1 -0
- package/dist/mcp/tools/app-inputs.js +142 -0
- package/dist/mcp/tools/app-inputs.js.map +1 -0
- package/dist/mcp/tools/apps-deploy.d.ts +13 -0
- package/dist/mcp/tools/apps-deploy.d.ts.map +1 -0
- package/dist/mcp/tools/apps-deploy.js +358 -0
- package/dist/mcp/tools/apps-deploy.js.map +1 -0
- package/dist/mcp/tools/apps-lifecycle.d.ts +11 -0
- package/dist/mcp/tools/apps-lifecycle.d.ts.map +1 -0
- package/dist/mcp/tools/apps-lifecycle.js +244 -0
- package/dist/mcp/tools/apps-lifecycle.js.map +1 -0
- package/dist/mcp/tools/apps-read.d.ts +9 -0
- package/dist/mcp/tools/apps-read.d.ts.map +1 -0
- package/dist/mcp/tools/apps-read.js +414 -0
- package/dist/mcp/tools/apps-read.js.map +1 -0
- package/dist/mcp/tools/artifacts.d.ts +8 -0
- package/dist/mcp/tools/artifacts.d.ts.map +1 -0
- package/dist/mcp/tools/artifacts.js +81 -0
- package/dist/mcp/tools/artifacts.js.map +1 -0
- package/dist/mcp/tools/audit.d.ts.map +1 -1
- package/dist/mcp/tools/audit.js +9 -17
- package/dist/mcp/tools/audit.js.map +1 -1
- package/dist/mcp/tools/design-center.d.ts +2 -3
- package/dist/mcp/tools/design-center.d.ts.map +1 -1
- package/dist/mcp/tools/design-center.js +41 -185
- package/dist/mcp/tools/design-center.js.map +1 -1
- package/dist/mcp/tools/exchange.d.ts +1 -2
- package/dist/mcp/tools/exchange.d.ts.map +1 -1
- package/dist/mcp/tools/exchange.js +51 -312
- package/dist/mcp/tools/exchange.js.map +1 -1
- package/dist/mcp/tools/governance.d.ts +8 -0
- package/dist/mcp/tools/governance.d.ts.map +1 -0
- package/dist/mcp/tools/governance.js +59 -0
- package/dist/mcp/tools/governance.js.map +1 -0
- package/dist/mcp/tools/identity.d.ts.map +1 -1
- package/dist/mcp/tools/identity.js +15 -36
- package/dist/mcp/tools/identity.js.map +1 -1
- package/dist/mcp/tools/index.d.ts +5 -1
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js +5 -1
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/logs.d.ts +48 -2
- package/dist/mcp/tools/logs.d.ts.map +1 -1
- package/dist/mcp/tools/logs.js +204 -54
- package/dist/mcp/tools/logs.js.map +1 -1
- package/dist/mcp/tools/monitoring.d.ts +1 -2
- package/dist/mcp/tools/monitoring.d.ts.map +1 -1
- package/dist/mcp/tools/monitoring.js +78 -285
- package/dist/mcp/tools/monitoring.js.map +1 -1
- package/dist/mcp/tools/object-store.d.ts +1 -1
- package/dist/mcp/tools/object-store.d.ts.map +1 -1
- package/dist/mcp/tools/object-store.js +19 -59
- package/dist/mcp/tools/object-store.js.map +1 -1
- package/dist/mcp/tools/profile.d.ts.map +1 -1
- package/dist/mcp/tools/profile.js +15 -35
- package/dist/mcp/tools/profile.js.map +1 -1
- package/dist/mcp/tools/shared.d.ts +43 -0
- package/dist/mcp/tools/shared.d.ts.map +1 -1
- package/dist/mcp/tools/shared.js +54 -0
- package/dist/mcp/tools/shared.js.map +1 -1
- package/dist/mcp.d.ts +3 -11
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +4 -56
- package/dist/mcp.js.map +1 -1
- package/dist/safety/deployment.d.ts +47 -2
- package/dist/safety/deployment.d.ts.map +1 -1
- package/dist/safety/deployment.js +139 -6
- package/dist/safety/deployment.js.map +1 -1
- package/dist/safety/guards.d.ts +2 -2
- package/dist/safety/guards.d.ts.map +1 -1
- package/dist/safety/guards.js +4 -4
- package/dist/safety/guards.js.map +1 -1
- package/dist/safety/paths.d.ts +29 -0
- package/dist/safety/paths.d.ts.map +1 -0
- package/dist/safety/paths.js +76 -0
- package/dist/safety/paths.js.map +1 -0
- package/dist/safety/runtime.d.ts +24 -0
- package/dist/safety/runtime.d.ts.map +1 -0
- package/dist/safety/runtime.js +59 -0
- package/dist/safety/runtime.js.map +1 -0
- package/dist/safety/secret-sources.d.ts +51 -0
- package/dist/safety/secret-sources.d.ts.map +1 -0
- package/dist/safety/secret-sources.js +124 -0
- package/dist/safety/secret-sources.js.map +1 -0
- package/dist/safety/secrets.d.ts +32 -0
- package/dist/safety/secrets.d.ts.map +1 -0
- package/dist/safety/secrets.js +91 -0
- package/dist/safety/secrets.js.map +1 -0
- package/dist/utils/errors.d.ts +14 -1
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +31 -3
- package/dist/utils/errors.js.map +1 -1
- package/dist/workflows/app-change.d.ts +124 -0
- package/dist/workflows/app-change.d.ts.map +1 -0
- package/dist/workflows/app-change.js +305 -0
- package/dist/workflows/app-change.js.map +1 -0
- package/dist/workflows/app-state.d.ts +60 -0
- package/dist/workflows/app-state.d.ts.map +1 -0
- package/dist/workflows/app-state.js +95 -0
- package/dist/workflows/app-state.js.map +1 -0
- package/dist/workflows/artifact-compare.d.ts +134 -0
- package/dist/workflows/artifact-compare.d.ts.map +1 -0
- package/dist/workflows/artifact-compare.js +419 -0
- package/dist/workflows/artifact-compare.js.map +1 -0
- package/dist/workflows/asset-naming.d.ts +72 -0
- package/dist/workflows/asset-naming.d.ts.map +1 -0
- package/dist/workflows/asset-naming.js +116 -0
- package/dist/workflows/asset-naming.js.map +1 -0
- package/dist/{api/DesignCenterWorkflow.d.ts → workflows/design-center.d.ts} +4 -4
- package/dist/workflows/design-center.d.ts.map +1 -0
- package/dist/{api/DesignCenterWorkflow.js → workflows/design-center.js} +1 -1
- package/dist/workflows/design-center.js.map +1 -0
- package/dist/workflows/jar-deployment.d.ts +156 -0
- package/dist/workflows/jar-deployment.d.ts.map +1 -0
- package/dist/workflows/jar-deployment.js +178 -0
- package/dist/workflows/jar-deployment.js.map +1 -0
- package/package.json +12 -4
- package/dist/analysis/utils.d.ts.map +0 -1
- package/dist/analysis/utils.js.map +0 -1
- package/dist/api/DesignCenterWorkflow.d.ts.map +0 -1
- package/dist/api/DesignCenterWorkflow.js.map +0 -1
- package/dist/api/index.d.ts +0 -13
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -13
- package/dist/api/index.js.map +0 -1
- package/dist/mcp/tools/applications.d.ts +0 -4
- package/dist/mcp/tools/applications.d.ts.map +0 -1
- package/dist/mcp/tools/applications.js +0 -815
- package/dist/mcp/tools/applications.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool Registrar — Application deployment tools (production-guarded)
|
|
3
|
+
* deploy_jar, deploy_app, update_app, update_app_artifact, rollback_app
|
|
4
|
+
*
|
|
5
|
+
* Every tool previews by default and applies on confirm: true; production also needs
|
|
6
|
+
* confirmProduction: true. Changes to an existing app go through one workflow
|
|
7
|
+
* (src/workflows/app-change.ts): one PATCH, a runtime check against the target, and
|
|
8
|
+
* an optional stop, change, start sequence.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { guardWrite, mcpText, resolveEnvironment, writeInputs } from './shared.js';
|
|
12
|
+
import { modeInput, runAppChangeTool, runtimeFromArgs, runtimeInputs, settingsFromArgs, settingsInputs, updateStrategyInput, waitInputs, } from './app-inputs.js';
|
|
13
|
+
import { buildCreatePayload, resolveRollbackTarget } from '../../safety/deployment.js';
|
|
14
|
+
import { redactText } from '../../safety/secrets.js';
|
|
15
|
+
import { errorMessage } from '../../utils/errors.js';
|
|
16
|
+
import { resolveSettingsInput } from '../../workflows/app-change.js';
|
|
17
|
+
import { waitForAppPhase } from '../../workflows/app-state.js';
|
|
18
|
+
import { describeJarDeployment, executeJarDeployment, planJarDeployment } from '../../workflows/jar-deployment.js';
|
|
19
|
+
const createOnlyInputs = {
|
|
20
|
+
replicas: z.number().min(1).max(8).optional().describe('[new app only] Number of replicas (default: 1)'),
|
|
21
|
+
region: z.string().optional().describe('[new app only] CloudHub 2.0 target region (default: "cloudhub-us-east-2")'),
|
|
22
|
+
vcores: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('[new app only] vCore size (default: "0.1"). Options: 0.1, 0.2, 0.5, 1, 1.5, 2, 2.5, 3, 4'),
|
|
26
|
+
jvmArgs: z.string().optional().describe('[new app only] JVM arguments'),
|
|
27
|
+
};
|
|
28
|
+
const refInputs = {
|
|
29
|
+
artifactId: z.string().optional().describe('Maven artifact ID. Default: keep the current one'),
|
|
30
|
+
groupId: z.string().optional().describe('Maven group ID. Default: keep the current one'),
|
|
31
|
+
packaging: z.string().optional().describe('Artifact packaging. Default: keep the current one (usually "jar")'),
|
|
32
|
+
};
|
|
33
|
+
function errorText(error, secretValues) {
|
|
34
|
+
return {
|
|
35
|
+
content: [{ type: 'text', text: `Error: ${redactText(errorMessage(error), secretValues)}` }],
|
|
36
|
+
isError: true,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function registerAppDeployTools(server, client) {
|
|
40
|
+
server.registerTool('deploy_jar', {
|
|
41
|
+
title: 'Deploy JAR (Publish + Deploy)',
|
|
42
|
+
description: 'Publishes a locally built Mule application JAR to Exchange and deploys it to CloudHub 2.0: creates the app if it does not exist, otherwise updates it in one change (artifact plus any runtime or settings change). ' +
|
|
43
|
+
'Asset coordinates come from explicit inputs, then the project naming convention, then the pattern of the asset the app runs today, then the JAR. ' +
|
|
44
|
+
'Region, vCores, replicas and JVM arguments apply only to a new app. Previews by default; pass confirm: true to publish and deploy.',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
jarPath: z
|
|
47
|
+
.string()
|
|
48
|
+
.describe('Path to the built .jar file (e.g. "target/orders-sapi-1.0.0-mule-application.jar")'),
|
|
49
|
+
appName: z.string().describe('CloudHub 2.0 application name'),
|
|
50
|
+
environment: z.string().describe('Environment name (e.g. "Sandbox") or ID'),
|
|
51
|
+
assetId: z
|
|
52
|
+
.string()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe('Exchange asset ID, also the deployment artifactId. Default: naming convention'),
|
|
55
|
+
assetVersion: z.string().optional().describe('Exchange asset version. Default: naming convention'),
|
|
56
|
+
groupId: z.string().optional().describe('Exchange/Maven group ID (default: the organization ID)'),
|
|
57
|
+
...runtimeInputs,
|
|
58
|
+
...createOnlyInputs,
|
|
59
|
+
...settingsInputs,
|
|
60
|
+
mode: modeInput,
|
|
61
|
+
updateStrategy: updateStrategyInput,
|
|
62
|
+
...waitInputs,
|
|
63
|
+
expectedSha256: z
|
|
64
|
+
.string()
|
|
65
|
+
.regex(/^[a-fA-F0-9]{64}$/)
|
|
66
|
+
.optional()
|
|
67
|
+
.describe('SHA-256 from the preview; rejects changed artifact bytes'),
|
|
68
|
+
...writeInputs,
|
|
69
|
+
},
|
|
70
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
|
|
71
|
+
}, async (args) => {
|
|
72
|
+
let secretValues = [];
|
|
73
|
+
try {
|
|
74
|
+
const { orgId, env } = await resolveEnvironment(client, args.environment);
|
|
75
|
+
const plan = await planJarDeployment(client, {
|
|
76
|
+
jarPath: args.jarPath,
|
|
77
|
+
appName: args.appName,
|
|
78
|
+
orgId,
|
|
79
|
+
env,
|
|
80
|
+
assetId: args.assetId,
|
|
81
|
+
assetVersion: args.assetVersion,
|
|
82
|
+
groupId: args.groupId,
|
|
83
|
+
expectedSha256: args.expectedSha256,
|
|
84
|
+
runtime: runtimeFromArgs(args),
|
|
85
|
+
replicas: args.replicas,
|
|
86
|
+
region: args.region,
|
|
87
|
+
vcores: args.vcores,
|
|
88
|
+
jvmArgs: args.jvmArgs,
|
|
89
|
+
settings: settingsFromArgs(args),
|
|
90
|
+
mode: args.mode,
|
|
91
|
+
updateStrategy: args.updateStrategy,
|
|
92
|
+
});
|
|
93
|
+
secretValues = plan.secretValues;
|
|
94
|
+
const preview = describeJarDeployment(plan);
|
|
95
|
+
if (plan.rejectedSettings.length > 0 || plan.change?.blockers.length) {
|
|
96
|
+
return {
|
|
97
|
+
...mcpText({
|
|
98
|
+
refused: true,
|
|
99
|
+
message: plan.rejectedSettings.length > 0
|
|
100
|
+
? `"${args.appName}" already exists in ${env.name}; region, vCores, replicas and JVM arguments apply only to a new app. Remove: ${plan.rejectedSettings.join(', ')}`
|
|
101
|
+
: 'The change cannot be applied.',
|
|
102
|
+
...preview,
|
|
103
|
+
}),
|
|
104
|
+
isError: true,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const gate = guardWrite({
|
|
108
|
+
env,
|
|
109
|
+
confirm: args.confirm,
|
|
110
|
+
confirmProduction: args.confirmProduction,
|
|
111
|
+
preview,
|
|
112
|
+
});
|
|
113
|
+
if (gate)
|
|
114
|
+
return gate;
|
|
115
|
+
const result = await executeJarDeployment(client, plan, {
|
|
116
|
+
wait: args.wait,
|
|
117
|
+
timeoutMs: args.waitTimeoutSeconds ? args.waitTimeoutSeconds * 1000 : undefined,
|
|
118
|
+
});
|
|
119
|
+
const response = mcpText(JSON.parse(redactText(JSON.stringify({
|
|
120
|
+
message: `Deployed "${args.appName}" to ${env.name} (${plan.existing ? 'updated' : 'created'})`,
|
|
121
|
+
published: result.published,
|
|
122
|
+
deploymentId: result.deployment.id,
|
|
123
|
+
...(plan.existing ? { previousRef: plan.existing.application?.ref } : {}),
|
|
124
|
+
...(result.change ? { performed: result.change.performed } : {}),
|
|
125
|
+
...(result.snapshot
|
|
126
|
+
? {
|
|
127
|
+
phase: result.snapshot.phase,
|
|
128
|
+
settled: result.snapshot.settled,
|
|
129
|
+
...(result.snapshot.reason ? { reason: result.snapshot.reason } : {}),
|
|
130
|
+
...(result.timedOut ? { timedOut: true } : {}),
|
|
131
|
+
}
|
|
132
|
+
: {
|
|
133
|
+
tip: 'Pass wait: true, or call get_app_status with wait: true, to follow the rollout.',
|
|
134
|
+
}),
|
|
135
|
+
}), secretValues)));
|
|
136
|
+
return result.snapshot?.terminal && !result.snapshot.settled
|
|
137
|
+
? { ...response, isError: true }
|
|
138
|
+
: response;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
return errorText(error, secretValues);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
server.registerTool('deploy_app', {
|
|
145
|
+
title: 'Deploy Application',
|
|
146
|
+
description: 'Deploys an artifact already in Exchange (groupId:artifactId:version) to CloudHub 2.0. Creates the app if it does not exist; otherwise updates it in one change, including any runtime or settings change. ' +
|
|
147
|
+
'Region, vCores, replicas and JVM arguments apply only to a new app. Previews by default; pass confirm: true to apply.',
|
|
148
|
+
inputSchema: {
|
|
149
|
+
appName: z.string().describe('Application name (also the public URL slug)'),
|
|
150
|
+
environment: z.string().describe('Environment name (e.g. "Sandbox") or ID'),
|
|
151
|
+
groupId: z.string().describe('Maven group ID of the artifact (usually the organization ID)'),
|
|
152
|
+
artifactId: z.string().describe('Maven artifact ID (e.g. "orders-sapi")'),
|
|
153
|
+
version: z.string().describe('Artifact version (e.g. "1.2.0")'),
|
|
154
|
+
...runtimeInputs,
|
|
155
|
+
...createOnlyInputs,
|
|
156
|
+
...settingsInputs,
|
|
157
|
+
mode: modeInput,
|
|
158
|
+
updateStrategy: updateStrategyInput,
|
|
159
|
+
...waitInputs,
|
|
160
|
+
...writeInputs,
|
|
161
|
+
},
|
|
162
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
|
|
163
|
+
}, async (args) => {
|
|
164
|
+
let secretValues = [];
|
|
165
|
+
try {
|
|
166
|
+
const { orgId, env } = await resolveEnvironment(client, args.environment);
|
|
167
|
+
const existing = await client.cloudHub2.findDetailByName(orgId, env.id, args.appName);
|
|
168
|
+
if (existing) {
|
|
169
|
+
const rejected = ['region', 'vcores', 'replicas', 'jvmArgs'].filter((key) => args[key] !== undefined);
|
|
170
|
+
if (rejected.length) {
|
|
171
|
+
return {
|
|
172
|
+
...mcpText({
|
|
173
|
+
refused: true,
|
|
174
|
+
message: `"${args.appName}" already exists in ${env.name}; ${rejected.join(', ')} apply only to a new app.`,
|
|
175
|
+
}),
|
|
176
|
+
isError: true,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return runAppChangeTool(client, args, {
|
|
180
|
+
existing,
|
|
181
|
+
ref: { groupId: args.groupId, artifactId: args.artifactId, version: args.version },
|
|
182
|
+
runtime: runtimeFromArgs(args),
|
|
183
|
+
settings: settingsFromArgs(args),
|
|
184
|
+
mode: args.mode,
|
|
185
|
+
updateStrategy: args.updateStrategy,
|
|
186
|
+
}, { done: 'Updated' });
|
|
187
|
+
}
|
|
188
|
+
const resolved = resolveSettingsInput(settingsFromArgs(args));
|
|
189
|
+
secretValues = resolved.secretValues;
|
|
190
|
+
if (resolved.change?.removeProperties ||
|
|
191
|
+
resolved.change?.removeSecureProperties ||
|
|
192
|
+
resolved.change?.moveToSecure) {
|
|
193
|
+
throw new Error('removeProperties, removeSecureProperties and moveToSecure apply only to an existing app');
|
|
194
|
+
}
|
|
195
|
+
const payload = buildCreatePayload({
|
|
196
|
+
appName: args.appName,
|
|
197
|
+
groupId: args.groupId,
|
|
198
|
+
artifactId: args.artifactId,
|
|
199
|
+
version: args.version,
|
|
200
|
+
runtime: args.runtime,
|
|
201
|
+
javaVersion: args.javaVersion,
|
|
202
|
+
releaseChannel: args.releaseChannel,
|
|
203
|
+
replicas: args.replicas,
|
|
204
|
+
region: args.region,
|
|
205
|
+
vcores: args.vcores,
|
|
206
|
+
properties: resolved.change?.properties,
|
|
207
|
+
secureProperties: resolved.change?.secureProperties,
|
|
208
|
+
jvmArgs: args.jvmArgs,
|
|
209
|
+
});
|
|
210
|
+
const preview = {
|
|
211
|
+
action: 'create new deployment',
|
|
212
|
+
app: args.appName,
|
|
213
|
+
environment: env.name,
|
|
214
|
+
next: {
|
|
215
|
+
ref: payload.application.ref,
|
|
216
|
+
runtime: payload.target.deploymentSettings.runtime,
|
|
217
|
+
region: payload.target.targetId,
|
|
218
|
+
vCores: payload.application.vCores,
|
|
219
|
+
replicas: payload.target.replicas,
|
|
220
|
+
properties: Object.keys(resolved.change?.properties ?? {}),
|
|
221
|
+
secureProperties: Object.keys(resolved.change?.secureProperties ?? {}),
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
const gate = guardWrite({
|
|
225
|
+
env,
|
|
226
|
+
confirm: args.confirm,
|
|
227
|
+
confirmProduction: args.confirmProduction,
|
|
228
|
+
preview,
|
|
229
|
+
});
|
|
230
|
+
if (gate)
|
|
231
|
+
return gate;
|
|
232
|
+
const sentAt = Date.now();
|
|
233
|
+
const deployment = await client.cloudHub2.createDeployment(orgId, env.id, payload);
|
|
234
|
+
if (!args.wait) {
|
|
235
|
+
return mcpText({
|
|
236
|
+
message: `Created "${args.appName}" in ${env.name}`,
|
|
237
|
+
deploymentId: deployment.id,
|
|
238
|
+
...preview.next,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const result = await waitForAppPhase(client.cloudHub2, orgId, env.id, deployment.id, {
|
|
242
|
+
sinceChange: sentAt,
|
|
243
|
+
timeoutMs: args.waitTimeoutSeconds ? args.waitTimeoutSeconds * 1000 : undefined,
|
|
244
|
+
});
|
|
245
|
+
const response = mcpText({
|
|
246
|
+
message: `Created "${args.appName}" in ${env.name}`,
|
|
247
|
+
deploymentId: deployment.id,
|
|
248
|
+
phase: result.snapshot.phase,
|
|
249
|
+
settled: result.snapshot.settled,
|
|
250
|
+
...(result.snapshot.reason ? { reason: result.snapshot.reason } : {}),
|
|
251
|
+
...(result.timedOut ? { timedOut: true } : {}),
|
|
252
|
+
});
|
|
253
|
+
return result.snapshot.terminal && !result.snapshot.settled
|
|
254
|
+
? { ...response, isError: true }
|
|
255
|
+
: response;
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
return errorText(error, secretValues);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
server.registerTool('update_app', {
|
|
262
|
+
title: 'Update Application',
|
|
263
|
+
description: 'Changes an existing CloudHub 2.0 application in one call: artifact version, Mule runtime, properties and update strategy together, as one new spec. ' +
|
|
264
|
+
'mode stopStart stops the app, applies the change and starts it, so old and new replicas never process events together; use it for apps with streaming, subscription or polling listeners. ' +
|
|
265
|
+
'The runtime is checked against what the target offers before anything is written; a retired runtime is refused with the nearest supported versions. ' +
|
|
266
|
+
'Waits for the rollout by default. Previews by default; pass confirm: true to apply.',
|
|
267
|
+
inputSchema: {
|
|
268
|
+
appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
|
|
269
|
+
environment: z.string().describe('Environment name or ID'),
|
|
270
|
+
version: z.string().optional().describe('New artifact version. Default: keep the current one'),
|
|
271
|
+
...refInputs,
|
|
272
|
+
...runtimeInputs,
|
|
273
|
+
...settingsInputs,
|
|
274
|
+
mode: modeInput,
|
|
275
|
+
updateStrategy: updateStrategyInput,
|
|
276
|
+
wait: z.boolean().optional().describe('Wait until every replica runs the new spec (default: true)'),
|
|
277
|
+
waitTimeoutSeconds: waitInputs.waitTimeoutSeconds,
|
|
278
|
+
...writeInputs,
|
|
279
|
+
},
|
|
280
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
|
|
281
|
+
}, async (args) => runAppChangeTool(client, { ...args, wait: args.wait ?? true }, {
|
|
282
|
+
ref: {
|
|
283
|
+
version: args.version,
|
|
284
|
+
artifactId: args.artifactId,
|
|
285
|
+
groupId: args.groupId,
|
|
286
|
+
packaging: args.packaging,
|
|
287
|
+
},
|
|
288
|
+
runtime: runtimeFromArgs(args),
|
|
289
|
+
settings: settingsFromArgs(args),
|
|
290
|
+
mode: args.mode,
|
|
291
|
+
updateStrategy: args.updateStrategy,
|
|
292
|
+
}, { done: 'Updated' }));
|
|
293
|
+
server.registerTool('update_app_artifact', {
|
|
294
|
+
title: 'Update Application Artifact',
|
|
295
|
+
description: 'Moves an existing CloudHub 2.0 application to another artifact version, optionally with a runtime change in the same update. Target, replicas, resources and settings are preserved. ' +
|
|
296
|
+
'Use runtime when the current runtime has been retired; the preview names supported versions. For settings changes in the same call use update_app. Previews by default; pass confirm: true to apply.',
|
|
297
|
+
inputSchema: {
|
|
298
|
+
appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
|
|
299
|
+
environment: z.string().describe('Environment name or ID'),
|
|
300
|
+
version: z.string().describe('New artifact version (e.g. "1.4.12")'),
|
|
301
|
+
...refInputs,
|
|
302
|
+
...runtimeInputs,
|
|
303
|
+
mode: modeInput,
|
|
304
|
+
...waitInputs,
|
|
305
|
+
...writeInputs,
|
|
306
|
+
},
|
|
307
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
|
|
308
|
+
}, async (args) => runAppChangeTool(client, args, {
|
|
309
|
+
ref: {
|
|
310
|
+
version: args.version,
|
|
311
|
+
artifactId: args.artifactId,
|
|
312
|
+
groupId: args.groupId,
|
|
313
|
+
packaging: args.packaging,
|
|
314
|
+
},
|
|
315
|
+
runtime: runtimeFromArgs(args),
|
|
316
|
+
mode: args.mode,
|
|
317
|
+
}, { done: 'Updated artifact of' }));
|
|
318
|
+
server.registerTool('rollback_app', {
|
|
319
|
+
title: 'Roll Back Application',
|
|
320
|
+
description: 'Rolls an existing CloudHub 2.0 application back to a previous artifact; runtime, target, replicas and settings are preserved. By default it picks the last successful or newest distinct earlier artifact; toVersion selects one. Previews by default; pass confirm: true to apply.',
|
|
321
|
+
inputSchema: {
|
|
322
|
+
appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
|
|
323
|
+
environment: z.string().describe('Environment name or ID'),
|
|
324
|
+
toVersion: z
|
|
325
|
+
.string()
|
|
326
|
+
.optional()
|
|
327
|
+
.describe('Artifact version to roll back to. Default: newest distinct earlier artifact'),
|
|
328
|
+
mode: modeInput,
|
|
329
|
+
...waitInputs,
|
|
330
|
+
...writeInputs,
|
|
331
|
+
},
|
|
332
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
|
|
333
|
+
}, async (args) => {
|
|
334
|
+
try {
|
|
335
|
+
const { orgId, env } = await resolveEnvironment(client, args.environment);
|
|
336
|
+
const existing = await client.cloudHub2.findDetailByName(orgId, env.id, args.appName);
|
|
337
|
+
if (!existing) {
|
|
338
|
+
return {
|
|
339
|
+
...mcpText({ message: `Application "${args.appName}" not found in ${env.name}` }),
|
|
340
|
+
isError: true,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
const specs = await client.cloudHub2.getDeploymentSpecs(orgId, env.id, existing.id);
|
|
344
|
+
const target = resolveRollbackTarget(existing, specs, args.toVersion);
|
|
345
|
+
if (!target) {
|
|
346
|
+
return mcpText({
|
|
347
|
+
noop: true,
|
|
348
|
+
message: `No distinct rollback target for "${args.appName}" in ${env.name}. Pass toVersion to select one.`,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
return runAppChangeTool(client, args, { existing, ref: target.ref, mode: args.mode }, { done: 'Rolled back' });
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
return errorText(error, []);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=apps-deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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AK,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;YACpF,MAAM,MAAM,GAAG,qBAAqB,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YACtE,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,OAAO,OAAO,CAAC;oBACX,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,oCAAoC,IAAI,CAAC,OAAO,QAAQ,GAAG,CAAC,IAAI,iCAAiC;iBAC7G,CAAC,CAAC;YACP,CAAC;YACD,OAAO,gBAAgB,CACnB,MAAM,EACN,IAAI,EACJ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAC9C,EAAE,IAAI,EAAE,aAAa,EAAE,CAC1B,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;IACL,CAAC,CACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool Registrar — Application lifecycle tools (production-guarded)
|
|
3
|
+
* restart_app, scale_app, stop_app, start_app, update_app_settings, delete_app
|
|
4
|
+
*
|
|
5
|
+
* Every tool here previews by default and applies on confirm: true; production also needs
|
|
6
|
+
* confirmProduction: true.
|
|
7
|
+
*/
|
|
8
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
|
+
import type { AnypointClient } from '../../client/AnypointClient.js';
|
|
10
|
+
export declare function registerAppLifecycleTools(server: McpServer, client: AnypointClient): void;
|
|
11
|
+
//# sourceMappingURL=apps-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apps-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/apps-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAiFrE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,QAsPlF"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool Registrar — Application lifecycle tools (production-guarded)
|
|
3
|
+
* restart_app, scale_app, stop_app, start_app, update_app_settings, delete_app
|
|
4
|
+
*
|
|
5
|
+
* Every tool here previews by default and applies on confirm: true; production also needs
|
|
6
|
+
* confirmProduction: true.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { mcpError, mcpText, dryRunPreview, guardWrite, resolveEnvironment, writeInputs } from './shared.js';
|
|
10
|
+
import { modeInput, runAppChangeTool, settingsFromArgs, settingsInputs, waitInputs } from './app-inputs.js';
|
|
11
|
+
import { buildApplicationDeletionPreview, deploymentIdMatches } from '../../safety/deletion.js';
|
|
12
|
+
import { deploymentPhase, waitForAppPhase } from '../../workflows/app-state.js';
|
|
13
|
+
const appInputs = {
|
|
14
|
+
appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
|
|
15
|
+
environment: z.string().describe('Environment name or ID'),
|
|
16
|
+
};
|
|
17
|
+
function notFound(appName, envName) {
|
|
18
|
+
return { ...mcpText({ message: `Application "${appName}" not found in ${envName}` }), isError: true };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Apply a narrow state change (stop, start, scale), then optionally wait for it to settle.
|
|
22
|
+
*/
|
|
23
|
+
async function runStateChange(client, args, describe, apply) {
|
|
24
|
+
try {
|
|
25
|
+
const { orgId, env } = await resolveEnvironment(client, args.environment);
|
|
26
|
+
const detail = await client.cloudHub2.findDetailByName(orgId, env.id, args.appName);
|
|
27
|
+
if (!detail)
|
|
28
|
+
return notFound(args.appName, env.name);
|
|
29
|
+
const described = describe(detail);
|
|
30
|
+
if (typeof described === 'string')
|
|
31
|
+
return mcpText({ noop: true, message: described });
|
|
32
|
+
const preview = {
|
|
33
|
+
app: detail.name,
|
|
34
|
+
environment: env.name,
|
|
35
|
+
current: {
|
|
36
|
+
desiredState: detail.application.desiredState,
|
|
37
|
+
replicas: detail.target?.replicas,
|
|
38
|
+
phase: deploymentPhase(detail).phase,
|
|
39
|
+
},
|
|
40
|
+
...described,
|
|
41
|
+
};
|
|
42
|
+
const gate = guardWrite({ env, confirm: args.confirm, confirmProduction: args.confirmProduction, preview });
|
|
43
|
+
if (gate)
|
|
44
|
+
return gate;
|
|
45
|
+
const sentAt = Date.now();
|
|
46
|
+
await apply(orgId, env.id, detail);
|
|
47
|
+
if (!args.wait) {
|
|
48
|
+
return mcpText({
|
|
49
|
+
...preview,
|
|
50
|
+
applied: true,
|
|
51
|
+
tip: 'Pass wait: true, or call get_app_status with wait: true, to follow it.',
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const result = await waitForAppPhase(client.cloudHub2, orgId, env.id, detail.id, {
|
|
55
|
+
sinceChange: sentAt,
|
|
56
|
+
timeoutMs: args.waitTimeoutSeconds ? args.waitTimeoutSeconds * 1000 : undefined,
|
|
57
|
+
});
|
|
58
|
+
const response = mcpText({
|
|
59
|
+
...preview,
|
|
60
|
+
applied: true,
|
|
61
|
+
phase: result.snapshot.phase,
|
|
62
|
+
settled: result.snapshot.settled,
|
|
63
|
+
...(result.snapshot.reason ? { reason: result.snapshot.reason } : {}),
|
|
64
|
+
...(result.timedOut ? { timedOut: true } : {}),
|
|
65
|
+
});
|
|
66
|
+
return result.snapshot.terminal && !result.snapshot.settled
|
|
67
|
+
? { ...response, isError: true }
|
|
68
|
+
: response;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return mcpError(error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function registerAppLifecycleTools(server, client) {
|
|
75
|
+
server.registerTool('restart_app', {
|
|
76
|
+
title: 'Restart Application',
|
|
77
|
+
description: 'Restarts a CloudHub 2.0 application by stopping it, waiting until every replica is down, and starting it again, so old and new replicas never run together. Expect a short outage. Use when an app misbehaves (memory pressure, stale connections) and no new version is needed. Previews by default; pass confirm: true to apply.',
|
|
78
|
+
inputSchema: { ...appInputs, ...waitInputs, ...writeInputs },
|
|
79
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
|
|
80
|
+
}, async (args) => runAppChangeTool(client, args, { restart: true, mode: 'stopStart' }, { done: 'Restarted' }));
|
|
81
|
+
server.registerTool('scale_app', {
|
|
82
|
+
title: 'Scale Application',
|
|
83
|
+
description: 'Changes the number of replicas of a CloudHub 2.0 application. New replicas receive traffic once their health checks pass. Previews by default; pass confirm: true to apply.',
|
|
84
|
+
inputSchema: {
|
|
85
|
+
...appInputs,
|
|
86
|
+
replicas: z.number().min(1).max(8).describe('Desired number of replicas (1-8)'),
|
|
87
|
+
...waitInputs,
|
|
88
|
+
...writeInputs,
|
|
89
|
+
},
|
|
90
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
|
|
91
|
+
}, async (args) => runStateChange(client, args, (detail) => detail.target?.replicas === args.replicas
|
|
92
|
+
? `"${detail.name}" already runs ${args.replicas} replica(s)`
|
|
93
|
+
: { action: 'scale', next: { replicas: args.replicas } }, (orgId, envId, detail) => client.cloudHub2.scaleApp(orgId, envId, detail.id, args.replicas)));
|
|
94
|
+
server.registerTool('stop_app', {
|
|
95
|
+
title: 'Stop Application',
|
|
96
|
+
description: 'Stops a CloudHub 2.0 application without deleting it: replicas terminate and the deployment configuration is kept. Use start_app to bring it back. Previews by default; pass confirm: true to apply.',
|
|
97
|
+
inputSchema: { ...appInputs, ...waitInputs, ...writeInputs },
|
|
98
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
|
|
99
|
+
}, async (args) => runStateChange(client, args, (detail) => detail.application.desiredState === 'STOPPED'
|
|
100
|
+
? `"${detail.name}" is already stopped`
|
|
101
|
+
: { action: 'stop', next: { desiredState: 'STOPPED' } }, (orgId, envId, detail) => client.cloudHub2.setDesiredState(orgId, envId, detail.id, 'STOPPED')));
|
|
102
|
+
server.registerTool('start_app', {
|
|
103
|
+
title: 'Start Application',
|
|
104
|
+
description: 'Starts a stopped CloudHub 2.0 application. With wait: true it returns once every replica is running, without reporting the brief FAILED status the platform shows during start-up. Previews by default; pass confirm: true to apply.',
|
|
105
|
+
inputSchema: { ...appInputs, ...waitInputs, ...writeInputs },
|
|
106
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
|
|
107
|
+
}, async (args) => runStateChange(client, args, (detail) => detail.application.desiredState === 'STARTED' && deploymentPhase(detail).settled
|
|
108
|
+
? `"${detail.name}" is already running`
|
|
109
|
+
: { action: 'start', next: { desiredState: 'STARTED' } }, (orgId, envId, detail) => client.cloudHub2.setDesiredState(orgId, envId, detail.id, 'STARTED')));
|
|
110
|
+
server.registerTool('update_app_settings', {
|
|
111
|
+
title: 'Update Application Settings',
|
|
112
|
+
description: 'Adds, changes, removes or moves application properties of a CloudHub 2.0 app. Untouched properties are kept; stored secure values are kept too, because the platform retains a secure value whenever it is sent back masked. ' +
|
|
113
|
+
'Pass secrets through securePropertiesFrom (a project file or environment variables read on the server) so they never appear in the conversation, and use moveToSecure to turn a plain property into a secure one without exposing its value. ' +
|
|
114
|
+
'The app references secure properties as plain ${key}. Applying restarts the app; use mode stopStart for apps with streaming or polling listeners. Previews by default; pass confirm: true to apply.',
|
|
115
|
+
inputSchema: { ...appInputs, ...settingsInputs, mode: modeInput, ...waitInputs, ...writeInputs },
|
|
116
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
|
|
117
|
+
}, async (args) => {
|
|
118
|
+
const settings = settingsFromArgs(args);
|
|
119
|
+
const empty = Object.values(settings).every((value) => value === undefined ||
|
|
120
|
+
(Array.isArray(value) ? value.length === 0 : Object.keys(value).length === 0));
|
|
121
|
+
if (empty) {
|
|
122
|
+
return {
|
|
123
|
+
...mcpText({
|
|
124
|
+
message: 'Nothing to change: pass properties, secureProperties, propertiesFrom, securePropertiesFrom, removeProperties, removeSecureProperties or moveToSecure.',
|
|
125
|
+
}),
|
|
126
|
+
isError: true,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return runAppChangeTool(client, args, { settings, mode: args.mode }, { done: 'Updated settings of' });
|
|
130
|
+
});
|
|
131
|
+
server.registerTool('delete_app', {
|
|
132
|
+
title: 'Delete Application Deployment',
|
|
133
|
+
description: 'Permanently deletes a CloudHub 2.0 application deployment while leaving its Exchange artifact and other Anypoint resources untouched. This is a bound two-step operation: call without confirm for a preview, then re-call with confirm:true and the exact expectedDeploymentId from that preview. Production also requires confirmProduction:true. Use stop_app instead when the deployment configuration should be preserved.',
|
|
134
|
+
inputSchema: {
|
|
135
|
+
appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
|
|
136
|
+
environment: z.string().describe('Environment name or ID'),
|
|
137
|
+
confirm: z.boolean().optional().describe('Set true only after reviewing the dry-run preview.'),
|
|
138
|
+
expectedDeploymentId: z
|
|
139
|
+
.string()
|
|
140
|
+
.optional()
|
|
141
|
+
.describe('Exact deployment ID returned by the dry-run preview; binds confirmation to one deployment.'),
|
|
142
|
+
confirmProduction: z
|
|
143
|
+
.boolean()
|
|
144
|
+
.optional()
|
|
145
|
+
.describe('Required in addition to confirm:true when the resolved environment is production.'),
|
|
146
|
+
},
|
|
147
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
|
|
148
|
+
}, async ({ appName, environment, confirm, expectedDeploymentId, confirmProduction }) => {
|
|
149
|
+
try {
|
|
150
|
+
const { orgId, env } = await resolveEnvironment(client, environment);
|
|
151
|
+
const deployment = await client.cloudHub2.findDetailByName(orgId, env.id, appName);
|
|
152
|
+
if (!deployment) {
|
|
153
|
+
if (confirm && expectedDeploymentId) {
|
|
154
|
+
return mcpText({
|
|
155
|
+
deleted: false,
|
|
156
|
+
alreadyAbsent: true,
|
|
157
|
+
verifiedAbsent: true,
|
|
158
|
+
app: appName,
|
|
159
|
+
environment: env.name,
|
|
160
|
+
expectedDeploymentId,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
...mcpText({ message: `Application "${appName}" not found in ${env.name}` }),
|
|
165
|
+
isError: true,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const preview = buildApplicationDeletionPreview(deployment, env);
|
|
169
|
+
if (!confirm) {
|
|
170
|
+
return dryRunPreview({
|
|
171
|
+
...preview,
|
|
172
|
+
confirmation: {
|
|
173
|
+
confirm: true,
|
|
174
|
+
expectedDeploymentId: deployment.id,
|
|
175
|
+
...(preview.production ? { confirmProduction: true } : {}),
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (!deploymentIdMatches(expectedDeploymentId, deployment.id)) {
|
|
180
|
+
return {
|
|
181
|
+
...mcpText({
|
|
182
|
+
message: 'Deletion refused: expectedDeploymentId is missing or does not match the current deployment.',
|
|
183
|
+
expectedDeploymentId: expectedDeploymentId ?? null,
|
|
184
|
+
currentDeploymentId: deployment.id,
|
|
185
|
+
app: deployment.name,
|
|
186
|
+
environment: env.name,
|
|
187
|
+
}),
|
|
188
|
+
isError: true,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (preview.production && !confirmProduction) {
|
|
192
|
+
return {
|
|
193
|
+
...mcpText({
|
|
194
|
+
message: 'Deletion refused: production requires confirmProduction:true.',
|
|
195
|
+
app: deployment.name,
|
|
196
|
+
environment: env.name,
|
|
197
|
+
deploymentId: deployment.id,
|
|
198
|
+
}),
|
|
199
|
+
isError: true,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
await client.cloudHub2.deleteDeployment(orgId, env.id, deployment.id);
|
|
203
|
+
const verification = await client.cloudHub2.waitForDeploymentDeletion(orgId, env.id, deployment.name, deployment.id);
|
|
204
|
+
if (verification.replacementDeploymentId) {
|
|
205
|
+
return {
|
|
206
|
+
...mcpText({
|
|
207
|
+
deletionAccepted: true,
|
|
208
|
+
verifiedAbsent: false,
|
|
209
|
+
replacementDetected: true,
|
|
210
|
+
deletedDeploymentId: deployment.id,
|
|
211
|
+
replacementDeploymentId: verification.replacementDeploymentId,
|
|
212
|
+
message: 'The original deployment was deleted, but a new deployment now uses the same name.',
|
|
213
|
+
}),
|
|
214
|
+
isError: true,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
if (!verification.verifiedAbsent) {
|
|
218
|
+
return mcpText({
|
|
219
|
+
deletionAccepted: true,
|
|
220
|
+
verifiedAbsent: false,
|
|
221
|
+
...(verification.deletionState ? { deletionState: verification.deletionState } : {}),
|
|
222
|
+
deploymentId: deployment.id,
|
|
223
|
+
app: deployment.name,
|
|
224
|
+
environment: env.name,
|
|
225
|
+
message: verification.deletionState
|
|
226
|
+
? 'CloudHub marks the deployment as DELETED, but its tombstone remains visible in the list.'
|
|
227
|
+
: 'CloudHub accepted deletion, but absence was not verified within 60 seconds.',
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return mcpText({
|
|
231
|
+
deleted: true,
|
|
232
|
+
verifiedAbsent: true,
|
|
233
|
+
deploymentId: deployment.id,
|
|
234
|
+
app: deployment.name,
|
|
235
|
+
environment: env.name,
|
|
236
|
+
preserved: preview.preserved,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
return mcpError(error);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=apps-lifecycle.js.map
|