@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.
Files changed (278) hide show
  1. package/README.md +39 -16
  2. package/dist/analysis/LogAnalyzer.d.ts +10 -4
  3. package/dist/analysis/LogAnalyzer.d.ts.map +1 -1
  4. package/dist/analysis/LogAnalyzer.js +29 -18
  5. package/dist/analysis/LogAnalyzer.js.map +1 -1
  6. package/dist/analysis/error-context.d.ts +2 -0
  7. package/dist/analysis/error-context.d.ts.map +1 -1
  8. package/dist/analysis/error-context.js +2 -1
  9. package/dist/analysis/error-context.js.map +1 -1
  10. package/dist/analysis/error-grouper.js +1 -1
  11. package/dist/analysis/error-grouper.js.map +1 -1
  12. package/dist/analysis/filter.d.ts +54 -0
  13. package/dist/analysis/filter.d.ts.map +1 -0
  14. package/dist/analysis/filter.js +100 -0
  15. package/dist/analysis/filter.js.map +1 -0
  16. package/dist/analysis/{utils.d.ts → normalize.d.ts} +1 -1
  17. package/dist/analysis/normalize.d.ts.map +1 -0
  18. package/dist/analysis/{utils.js → normalize.js} +2 -2
  19. package/dist/analysis/normalize.js.map +1 -0
  20. package/dist/analysis/parser.d.ts.map +1 -1
  21. package/dist/analysis/parser.js +45 -17
  22. package/dist/analysis/parser.js.map +1 -1
  23. package/dist/analysis/pattern-detector.js +1 -1
  24. package/dist/analysis/pattern-detector.js.map +1 -1
  25. package/dist/analysis/stats.d.ts +25 -0
  26. package/dist/analysis/stats.d.ts.map +1 -1
  27. package/dist/analysis/stats.js +35 -1
  28. package/dist/analysis/stats.js.map +1 -1
  29. package/dist/analysis/summary.d.ts +51 -0
  30. package/dist/analysis/summary.d.ts.map +1 -0
  31. package/dist/analysis/summary.js +47 -0
  32. package/dist/analysis/summary.js.map +1 -0
  33. package/dist/analysis/types.d.ts +14 -0
  34. package/dist/analysis/types.d.ts.map +1 -1
  35. package/dist/api/ApiManagerApi.d.ts +53 -0
  36. package/dist/api/ApiManagerApi.d.ts.map +1 -1
  37. package/dist/api/ApiManagerApi.js +53 -2
  38. package/dist/api/ApiManagerApi.js.map +1 -1
  39. package/dist/api/CloudHub2Api.d.ts +24 -4
  40. package/dist/api/CloudHub2Api.d.ts.map +1 -1
  41. package/dist/api/CloudHub2Api.js +10 -22
  42. package/dist/api/CloudHub2Api.js.map +1 -1
  43. package/dist/api/DesignCenterApi.d.ts +0 -20
  44. package/dist/api/DesignCenterApi.d.ts.map +1 -1
  45. package/dist/api/DesignCenterApi.js +0 -22
  46. package/dist/api/DesignCenterApi.js.map +1 -1
  47. package/dist/api/ExchangeApi.d.ts +15 -0
  48. package/dist/api/ExchangeApi.d.ts.map +1 -1
  49. package/dist/api/ExchangeApi.js +51 -0
  50. package/dist/api/ExchangeApi.js.map +1 -1
  51. package/dist/api/LogsApi.d.ts +50 -18
  52. package/dist/api/LogsApi.d.ts.map +1 -1
  53. package/dist/api/LogsApi.js +69 -98
  54. package/dist/api/LogsApi.js.map +1 -1
  55. package/dist/api/MonitoringApi.d.ts +137 -93
  56. package/dist/api/MonitoringApi.d.ts.map +1 -1
  57. package/dist/api/MonitoringApi.js +471 -204
  58. package/dist/api/MonitoringApi.js.map +1 -1
  59. package/dist/api/RuntimesApi.d.ts +56 -0
  60. package/dist/api/RuntimesApi.d.ts.map +1 -0
  61. package/dist/api/RuntimesApi.js +58 -0
  62. package/dist/api/RuntimesApi.js.map +1 -0
  63. package/dist/auth/FileStore.js +1 -1
  64. package/dist/auth/FileStore.js.map +1 -1
  65. package/dist/cli.js +4 -2
  66. package/dist/cli.js.map +1 -1
  67. package/dist/client/AnypointClient.d.ts +3 -1
  68. package/dist/client/AnypointClient.d.ts.map +1 -1
  69. package/dist/client/AnypointClient.js +5 -2
  70. package/dist/client/AnypointClient.js.map +1 -1
  71. package/dist/client/smoke-test.d.ts +111 -0
  72. package/dist/client/smoke-test.d.ts.map +1 -0
  73. package/dist/client/smoke-test.js +275 -0
  74. package/dist/client/smoke-test.js.map +1 -0
  75. package/dist/commands/api.d.ts +1 -1
  76. package/dist/commands/api.d.ts.map +1 -1
  77. package/dist/commands/api.js +175 -30
  78. package/dist/commands/api.js.map +1 -1
  79. package/dist/commands/app-change-cli.d.ts +52 -0
  80. package/dist/commands/app-change-cli.d.ts.map +1 -0
  81. package/dist/commands/app-change-cli.js +149 -0
  82. package/dist/commands/app-change-cli.js.map +1 -0
  83. package/dist/commands/apps.d.ts +1 -1
  84. package/dist/commands/apps.d.ts.map +1 -1
  85. package/dist/commands/apps.js +199 -18
  86. package/dist/commands/apps.js.map +1 -1
  87. package/dist/commands/auth.js +1 -1
  88. package/dist/commands/auth.js.map +1 -1
  89. package/dist/commands/compare.d.ts +8 -0
  90. package/dist/commands/compare.d.ts.map +1 -0
  91. package/dist/commands/compare.js +104 -0
  92. package/dist/commands/compare.js.map +1 -0
  93. package/dist/commands/config.js +1 -1
  94. package/dist/commands/config.js.map +1 -1
  95. package/dist/commands/deploy.d.ts +6 -1
  96. package/dist/commands/deploy.d.ts.map +1 -1
  97. package/dist/commands/deploy.js +89 -91
  98. package/dist/commands/deploy.js.map +1 -1
  99. package/dist/commands/design-center.d.ts +1 -1
  100. package/dist/commands/design-center.d.ts.map +1 -1
  101. package/dist/commands/design-center.js +36 -25
  102. package/dist/commands/design-center.js.map +1 -1
  103. package/dist/commands/index.d.ts +1 -0
  104. package/dist/commands/index.d.ts.map +1 -1
  105. package/dist/commands/index.js +1 -0
  106. package/dist/commands/index.js.map +1 -1
  107. package/dist/commands/logs.d.ts +3 -2
  108. package/dist/commands/logs.d.ts.map +1 -1
  109. package/dist/commands/logs.js +142 -17
  110. package/dist/commands/logs.js.map +1 -1
  111. package/dist/commands/monitor.d.ts +5 -6
  112. package/dist/commands/monitor.d.ts.map +1 -1
  113. package/dist/commands/monitor.js +210 -230
  114. package/dist/commands/monitor.js.map +1 -1
  115. package/dist/commands/runtimes.d.ts +7 -0
  116. package/dist/commands/runtimes.d.ts.map +1 -0
  117. package/dist/commands/runtimes.js +66 -0
  118. package/dist/commands/runtimes.js.map +1 -0
  119. package/dist/commands/shared.d.ts +2 -0
  120. package/dist/commands/shared.d.ts.map +1 -1
  121. package/dist/commands/shared.js +16 -1
  122. package/dist/commands/shared.js.map +1 -1
  123. package/dist/{utils/config.d.ts → config/profiles.d.ts} +9 -1
  124. package/dist/config/profiles.d.ts.map +1 -0
  125. package/dist/{utils/config.js → config/profiles.js} +1 -1
  126. package/dist/config/profiles.js.map +1 -0
  127. package/dist/index.d.ts +12 -3
  128. package/dist/index.d.ts.map +1 -1
  129. package/dist/index.js +12 -2
  130. package/dist/index.js.map +1 -1
  131. package/dist/mcp/prompts.js +7 -7
  132. package/dist/mcp/prompts.js.map +1 -1
  133. package/dist/mcp/server.d.ts +14 -0
  134. package/dist/mcp/server.d.ts.map +1 -0
  135. package/dist/mcp/server.js +61 -0
  136. package/dist/mcp/server.js.map +1 -0
  137. package/dist/mcp/tools/analysis.d.ts.map +1 -1
  138. package/dist/mcp/tools/analysis.js +74 -46
  139. package/dist/mcp/tools/analysis.js.map +1 -1
  140. package/dist/mcp/tools/anypoint-mq.d.ts.map +1 -1
  141. package/dist/mcp/tools/anypoint-mq.js +25 -54
  142. package/dist/mcp/tools/anypoint-mq.js.map +1 -1
  143. package/dist/mcp/tools/api-manager.d.ts +2 -1
  144. package/dist/mcp/tools/api-manager.d.ts.map +1 -1
  145. package/dist/mcp/tools/api-manager.js +154 -89
  146. package/dist/mcp/tools/api-manager.js.map +1 -1
  147. package/dist/mcp/tools/app-inputs.d.ts +92 -0
  148. package/dist/mcp/tools/app-inputs.d.ts.map +1 -0
  149. package/dist/mcp/tools/app-inputs.js +142 -0
  150. package/dist/mcp/tools/app-inputs.js.map +1 -0
  151. package/dist/mcp/tools/apps-deploy.d.ts +13 -0
  152. package/dist/mcp/tools/apps-deploy.d.ts.map +1 -0
  153. package/dist/mcp/tools/apps-deploy.js +358 -0
  154. package/dist/mcp/tools/apps-deploy.js.map +1 -0
  155. package/dist/mcp/tools/apps-lifecycle.d.ts +11 -0
  156. package/dist/mcp/tools/apps-lifecycle.d.ts.map +1 -0
  157. package/dist/mcp/tools/apps-lifecycle.js +244 -0
  158. package/dist/mcp/tools/apps-lifecycle.js.map +1 -0
  159. package/dist/mcp/tools/apps-read.d.ts +9 -0
  160. package/dist/mcp/tools/apps-read.d.ts.map +1 -0
  161. package/dist/mcp/tools/apps-read.js +414 -0
  162. package/dist/mcp/tools/apps-read.js.map +1 -0
  163. package/dist/mcp/tools/artifacts.d.ts +8 -0
  164. package/dist/mcp/tools/artifacts.d.ts.map +1 -0
  165. package/dist/mcp/tools/artifacts.js +81 -0
  166. package/dist/mcp/tools/artifacts.js.map +1 -0
  167. package/dist/mcp/tools/audit.d.ts.map +1 -1
  168. package/dist/mcp/tools/audit.js +9 -17
  169. package/dist/mcp/tools/audit.js.map +1 -1
  170. package/dist/mcp/tools/design-center.d.ts +2 -3
  171. package/dist/mcp/tools/design-center.d.ts.map +1 -1
  172. package/dist/mcp/tools/design-center.js +41 -185
  173. package/dist/mcp/tools/design-center.js.map +1 -1
  174. package/dist/mcp/tools/exchange.d.ts +1 -2
  175. package/dist/mcp/tools/exchange.d.ts.map +1 -1
  176. package/dist/mcp/tools/exchange.js +51 -312
  177. package/dist/mcp/tools/exchange.js.map +1 -1
  178. package/dist/mcp/tools/governance.d.ts +8 -0
  179. package/dist/mcp/tools/governance.d.ts.map +1 -0
  180. package/dist/mcp/tools/governance.js +59 -0
  181. package/dist/mcp/tools/governance.js.map +1 -0
  182. package/dist/mcp/tools/identity.d.ts.map +1 -1
  183. package/dist/mcp/tools/identity.js +15 -36
  184. package/dist/mcp/tools/identity.js.map +1 -1
  185. package/dist/mcp/tools/index.d.ts +5 -1
  186. package/dist/mcp/tools/index.d.ts.map +1 -1
  187. package/dist/mcp/tools/index.js +5 -1
  188. package/dist/mcp/tools/index.js.map +1 -1
  189. package/dist/mcp/tools/logs.d.ts +48 -2
  190. package/dist/mcp/tools/logs.d.ts.map +1 -1
  191. package/dist/mcp/tools/logs.js +204 -54
  192. package/dist/mcp/tools/logs.js.map +1 -1
  193. package/dist/mcp/tools/monitoring.d.ts +1 -2
  194. package/dist/mcp/tools/monitoring.d.ts.map +1 -1
  195. package/dist/mcp/tools/monitoring.js +78 -285
  196. package/dist/mcp/tools/monitoring.js.map +1 -1
  197. package/dist/mcp/tools/object-store.d.ts +1 -1
  198. package/dist/mcp/tools/object-store.d.ts.map +1 -1
  199. package/dist/mcp/tools/object-store.js +19 -59
  200. package/dist/mcp/tools/object-store.js.map +1 -1
  201. package/dist/mcp/tools/profile.d.ts.map +1 -1
  202. package/dist/mcp/tools/profile.js +15 -35
  203. package/dist/mcp/tools/profile.js.map +1 -1
  204. package/dist/mcp/tools/shared.d.ts +43 -0
  205. package/dist/mcp/tools/shared.d.ts.map +1 -1
  206. package/dist/mcp/tools/shared.js +54 -0
  207. package/dist/mcp/tools/shared.js.map +1 -1
  208. package/dist/mcp.d.ts +3 -11
  209. package/dist/mcp.d.ts.map +1 -1
  210. package/dist/mcp.js +4 -56
  211. package/dist/mcp.js.map +1 -1
  212. package/dist/safety/deployment.d.ts +47 -2
  213. package/dist/safety/deployment.d.ts.map +1 -1
  214. package/dist/safety/deployment.js +139 -6
  215. package/dist/safety/deployment.js.map +1 -1
  216. package/dist/safety/guards.d.ts +2 -2
  217. package/dist/safety/guards.d.ts.map +1 -1
  218. package/dist/safety/guards.js +4 -4
  219. package/dist/safety/guards.js.map +1 -1
  220. package/dist/safety/paths.d.ts +29 -0
  221. package/dist/safety/paths.d.ts.map +1 -0
  222. package/dist/safety/paths.js +76 -0
  223. package/dist/safety/paths.js.map +1 -0
  224. package/dist/safety/runtime.d.ts +24 -0
  225. package/dist/safety/runtime.d.ts.map +1 -0
  226. package/dist/safety/runtime.js +59 -0
  227. package/dist/safety/runtime.js.map +1 -0
  228. package/dist/safety/secret-sources.d.ts +51 -0
  229. package/dist/safety/secret-sources.d.ts.map +1 -0
  230. package/dist/safety/secret-sources.js +124 -0
  231. package/dist/safety/secret-sources.js.map +1 -0
  232. package/dist/safety/secrets.d.ts +32 -0
  233. package/dist/safety/secrets.d.ts.map +1 -0
  234. package/dist/safety/secrets.js +91 -0
  235. package/dist/safety/secrets.js.map +1 -0
  236. package/dist/utils/errors.d.ts +14 -1
  237. package/dist/utils/errors.d.ts.map +1 -1
  238. package/dist/utils/errors.js +31 -3
  239. package/dist/utils/errors.js.map +1 -1
  240. package/dist/workflows/app-change.d.ts +124 -0
  241. package/dist/workflows/app-change.d.ts.map +1 -0
  242. package/dist/workflows/app-change.js +305 -0
  243. package/dist/workflows/app-change.js.map +1 -0
  244. package/dist/workflows/app-state.d.ts +60 -0
  245. package/dist/workflows/app-state.d.ts.map +1 -0
  246. package/dist/workflows/app-state.js +95 -0
  247. package/dist/workflows/app-state.js.map +1 -0
  248. package/dist/workflows/artifact-compare.d.ts +134 -0
  249. package/dist/workflows/artifact-compare.d.ts.map +1 -0
  250. package/dist/workflows/artifact-compare.js +419 -0
  251. package/dist/workflows/artifact-compare.js.map +1 -0
  252. package/dist/workflows/asset-naming.d.ts +72 -0
  253. package/dist/workflows/asset-naming.d.ts.map +1 -0
  254. package/dist/workflows/asset-naming.js +116 -0
  255. package/dist/workflows/asset-naming.js.map +1 -0
  256. package/dist/{api/DesignCenterWorkflow.d.ts → workflows/design-center.d.ts} +4 -4
  257. package/dist/workflows/design-center.d.ts.map +1 -0
  258. package/dist/{api/DesignCenterWorkflow.js → workflows/design-center.js} +1 -1
  259. package/dist/workflows/design-center.js.map +1 -0
  260. package/dist/workflows/jar-deployment.d.ts +156 -0
  261. package/dist/workflows/jar-deployment.d.ts.map +1 -0
  262. package/dist/workflows/jar-deployment.js +178 -0
  263. package/dist/workflows/jar-deployment.js.map +1 -0
  264. package/package.json +12 -4
  265. package/dist/analysis/utils.d.ts.map +0 -1
  266. package/dist/analysis/utils.js.map +0 -1
  267. package/dist/api/DesignCenterWorkflow.d.ts.map +0 -1
  268. package/dist/api/DesignCenterWorkflow.js.map +0 -1
  269. package/dist/api/index.d.ts +0 -13
  270. package/dist/api/index.d.ts.map +0 -1
  271. package/dist/api/index.js +0 -13
  272. package/dist/api/index.js.map +0 -1
  273. package/dist/mcp/tools/applications.d.ts +0 -4
  274. package/dist/mcp/tools/applications.d.ts.map +0 -1
  275. package/dist/mcp/tools/applications.js +0 -815
  276. package/dist/mcp/tools/applications.js.map +0 -1
  277. package/dist/utils/config.d.ts.map +0 -1
  278. package/dist/utils/config.js.map +0 -1
@@ -1,815 +0,0 @@
1
- import { z } from 'zod';
2
- import { mcpError, mcpText, dryRunPreview } from './shared.js';
3
- import { buildCreatePayload, mergeApplicationProperties, mergeForArtifactUpdate, resolveRollbackTarget, } from '../../safety/deployment.js';
4
- import { buildApplicationDeletionPreview, deploymentIdMatches } from '../../safety/deletion.js';
5
- import { errorMessage } from '../../utils/errors.js';
6
- export function registerApplicationTools(server, client) {
7
- server.registerTool('list_apps', {
8
- title: 'List Applications',
9
- description: 'Lists all Mule applications deployed in a CloudHub 2.0 environment. Returns each app\'s name, deployment status (APPLIED, STARTED, FAILED), artifact version, Mule runtime version, vCores, and replica count. Accepts environment name (e.g. "Development") or environment ID.',
10
- inputSchema: {
11
- environment: z
12
- .string()
13
- .describe('Environment name (e.g. "Development", "Production") or environment ID'),
14
- },
15
- annotations: { readOnlyHint: true },
16
- }, async ({ environment }) => {
17
- try {
18
- const orgId = await client.getDefaultOrgId();
19
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
20
- const deployments = await client.cloudHub2.getDetailedDeployments(orgId, env.id);
21
- return {
22
- content: [
23
- {
24
- type: 'text',
25
- text: JSON.stringify(deployments.map((d) => ({
26
- name: d.name,
27
- status: d.status,
28
- version: d.application?.ref?.version,
29
- runtime: d.target?.deploymentSettings?.runtime?.version,
30
- vCores: d.application?.vCores,
31
- replicas: d.target?.replicas,
32
- id: d.id,
33
- })), null, 2),
34
- },
35
- ],
36
- };
37
- }
38
- catch (error) {
39
- return mcpError(error);
40
- }
41
- });
42
- server.registerTool('get_app_status', {
43
- title: 'Get Application Status',
44
- description: "Returns detailed deployment information for a specific Mule application: status, artifact version (groupId:artifactId:version), Mule runtime version, resource allocation (CPU, memory, vCores), autoscaling config, JVM args, clustering, each replica's state and deployment location, the public URL, and last update timestamp. Use this to check if an app is healthy, review resource allocation, or verify a deployment.",
45
- inputSchema: {
46
- appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
47
- environment: z.string().describe('Environment name (e.g. "Production") or environment ID'),
48
- },
49
- annotations: { readOnlyHint: true },
50
- }, async ({ appName, environment }) => {
51
- try {
52
- const orgId = await client.getDefaultOrgId();
53
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
54
- const deployment = await client.cloudHub2.findDetailByName(orgId, env.id, appName);
55
- if (!deployment) {
56
- return {
57
- content: [{ type: 'text', text: `Application "${appName}" not found in ${env.name}` }],
58
- };
59
- }
60
- return {
61
- content: [
62
- {
63
- type: 'text',
64
- text: JSON.stringify({
65
- name: deployment.name,
66
- status: deployment.status,
67
- version: deployment.application?.ref?.version,
68
- groupId: deployment.application?.ref?.groupId,
69
- artifactId: deployment.application?.ref?.artifactId,
70
- runtime: deployment.target?.deploymentSettings?.runtime?.version,
71
- resources: {
72
- cpu: deployment.target?.deploymentSettings?.resources?.cpu,
73
- memory: deployment.target?.deploymentSettings?.resources?.memory,
74
- vCores: deployment.application?.vCores,
75
- },
76
- autoscaling: deployment.target?.deploymentSettings?.autoscaling,
77
- jvm: deployment.target?.deploymentSettings?.jvm,
78
- clustered: deployment.target?.deploymentSettings?.clustered,
79
- updateStrategy: deployment.target?.deploymentSettings?.updateStrategy,
80
- replicas: deployment.replicas?.map((r) => ({
81
- id: r.id,
82
- state: r.state,
83
- location: r.deploymentLocation,
84
- })),
85
- publicUrl: deployment.target?.deploymentSettings?.http?.inbound?.publicUrl,
86
- updatedAt: deployment.lastModifiedDate
87
- ? new Date(deployment.lastModifiedDate).toISOString()
88
- : undefined,
89
- }, null, 2),
90
- },
91
- ],
92
- };
93
- }
94
- catch (error) {
95
- return mcpError(error);
96
- }
97
- });
98
- server.registerTool('get_deployment_spec', {
99
- title: 'Get Deployment Spec',
100
- description: 'Returns the full current deployment spec for a CloudHub 2.0 application — the "look before you leap" view used before a redeploy or rollback. Includes the exact artifact reference (groupId:artifactId:version:packaging), Mule runtime version, deployment target (a private space ID vs a shared cloudhub-* region), vCores, replica count with per-replica state and location, update strategy, clustering, JVM args, public URL, desired vs last-successful version, and timestamps. Unlike get_app_status this always fetches full deployment detail. Use it to confirm exactly what is running before changing an artifact, and to capture the current ref so you can roll back.',
101
- inputSchema: {
102
- appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
103
- environment: z.string().describe('Environment name (e.g. "Production") or environment ID'),
104
- },
105
- annotations: { readOnlyHint: true },
106
- }, async ({ appName, environment }) => {
107
- try {
108
- const orgId = await client.getDefaultOrgId();
109
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
110
- const d = await client.cloudHub2.findDetailByName(orgId, env.id, appName);
111
- if (!d) {
112
- return mcpText(`Application "${appName}" not found in ${env.name}`);
113
- }
114
- const settings = d.target?.deploymentSettings;
115
- const targetId = d.target?.targetId || '';
116
- const isPrivateSpace = !targetId.startsWith('cloudhub-');
117
- return mcpText({
118
- name: d.name,
119
- deploymentId: d.id,
120
- status: d.status,
121
- ref: d.application?.ref,
122
- runtime: settings?.runtime?.version,
123
- target: {
124
- provider: d.target?.provider,
125
- targetId,
126
- kind: isPrivateSpace ? 'private-space' : 'shared-region',
127
- },
128
- vCores: d.application?.vCores,
129
- resources: settings?.resources,
130
- replicas: {
131
- count: d.target?.replicas ?? 0,
132
- states: d.replicas?.map((r) => ({
133
- id: r.id,
134
- state: r.state,
135
- location: r.deploymentLocation,
136
- version: r.currentDeploymentVersion,
137
- })),
138
- },
139
- updateStrategy: settings?.updateStrategy,
140
- clustered: settings?.clustered,
141
- autoscaling: settings?.autoscaling,
142
- jvm: settings?.jvm,
143
- publicUrl: settings?.http?.inbound?.publicUrl,
144
- desiredVersion: d.desiredVersion,
145
- lastSuccessfulVersion: d.lastSuccessfulVersion,
146
- createdAt: d.creationDate ? new Date(d.creationDate).toISOString() : undefined,
147
- updatedAt: d.lastModifiedDate ? new Date(d.lastModifiedDate).toISOString() : undefined,
148
- });
149
- }
150
- catch (error) {
151
- return mcpError(error);
152
- }
153
- });
154
- server.registerTool('get_app_resources', {
155
- title: 'Get Application Resources',
156
- description: 'Returns resource allocation for all apps in an environment: CPU/memory limits and reservations, vCores, replica count, autoscaling config, and JVM args. Use this to identify over-provisioned or under-provisioned applications, compare resource distribution, and optimize costs.',
157
- inputSchema: {
158
- environment: z.string().describe('Environment name (e.g. "Production") or environment ID'),
159
- },
160
- annotations: { readOnlyHint: true },
161
- }, async ({ environment }) => {
162
- try {
163
- const orgId = await client.getDefaultOrgId();
164
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
165
- const deployments = await client.cloudHub2.getDetailedDeployments(orgId, env.id);
166
- const resources = deployments.map((d) => ({
167
- name: d.name,
168
- status: d.status,
169
- vCores: d.application?.vCores,
170
- cpu: d.target?.deploymentSettings?.resources?.cpu,
171
- memory: d.target?.deploymentSettings?.resources?.memory,
172
- replicas: d.target?.replicas ?? 0,
173
- autoscaling: d.target?.deploymentSettings?.autoscaling,
174
- jvm: d.target?.deploymentSettings?.jvm,
175
- clustered: d.target?.deploymentSettings?.clustered,
176
- updateStrategy: d.target?.deploymentSettings?.updateStrategy,
177
- }));
178
- return {
179
- content: [
180
- {
181
- type: 'text',
182
- text: JSON.stringify({
183
- environment: env.name,
184
- apps: resources,
185
- }, null, 2),
186
- },
187
- ],
188
- };
189
- }
190
- catch (error) {
191
- return mcpError(error);
192
- }
193
- });
194
- server.registerTool('get_app_settings', {
195
- title: 'Get Application Settings',
196
- description: 'Reads the application properties (configuration settings) for a deployed Mule application in CloudHub 2.0. Returns both plain-text properties as key-value pairs and the names of secure (encrypted) properties. Use this to verify configuration after a deploy, compare settings between environments, or check for missing properties.',
197
- inputSchema: {
198
- appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
199
- environment: z.string().describe('Environment name (e.g. "Production") or environment ID'),
200
- },
201
- annotations: { readOnlyHint: true },
202
- }, async ({ appName, environment }) => {
203
- try {
204
- const orgId = await client.getDefaultOrgId();
205
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
206
- const detail = await client.cloudHub2.findDetailByName(orgId, env.id, appName);
207
- if (!detail) {
208
- return {
209
- content: [{ type: 'text', text: `Application "${appName}" not found in ${env.name}` }],
210
- };
211
- }
212
- const config = (detail.application?.configuration ?? {});
213
- const propertiesService = config['mule.agent.application.properties.service'];
214
- const properties = (propertiesService?.properties ?? {});
215
- const secureProperties = propertiesService?.secureProperties;
216
- const securePropertyKeys = secureProperties ? Object.keys(secureProperties) : [];
217
- return {
218
- content: [
219
- {
220
- type: 'text',
221
- text: JSON.stringify({
222
- appName: detail.name,
223
- environment: env.name,
224
- properties,
225
- securePropertyKeys,
226
- rawConfiguration: config,
227
- }, null, 2),
228
- },
229
- ],
230
- };
231
- }
232
- catch (error) {
233
- return mcpError(error);
234
- }
235
- });
236
- server.registerTool('restart_app', {
237
- title: 'Restart Application',
238
- description: "Initiates a rolling restart of a deployed Mule application by re-applying its desired state. This causes new replicas to spin up before old ones are terminated, avoiding downtime. Use when an app is behaving unexpectedly (e.g. memory issues, stale connections) but you don't need to redeploy a new version.",
239
- inputSchema: {
240
- appName: z.string().describe('Application name exactly as deployed'),
241
- environment: z.string().describe('Environment name or ID'),
242
- },
243
- annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
244
- }, async ({ appName, environment }) => {
245
- try {
246
- const orgId = await client.getDefaultOrgId();
247
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
248
- const deployment = await client.cloudHub2.findByName(orgId, env.id, appName);
249
- if (!deployment) {
250
- return {
251
- content: [{ type: 'text', text: `Application "${appName}" not found in ${env.name}` }],
252
- isError: true,
253
- };
254
- }
255
- await client.cloudHub2.restartApp(orgId, env.id, deployment.id);
256
- return {
257
- content: [
258
- {
259
- type: 'text',
260
- text: `✅ Rolling restart initiated for "${appName}" in ${env.name}. Use get_app_status to monitor progress.`,
261
- },
262
- ],
263
- };
264
- }
265
- catch (error) {
266
- return mcpError(error);
267
- }
268
- });
269
- server.registerTool('scale_app', {
270
- title: 'Scale Application',
271
- description: 'Changes the number of running replicas for a CloudHub 2.0 application. Scaling up adds more replicas for higher throughput and availability; scaling down reduces cost. Each replica runs as an isolated Mule runtime instance. The change takes effect immediately and new replicas will begin receiving traffic once their health checks pass.',
272
- inputSchema: {
273
- appName: z.string().describe('Application name exactly as deployed'),
274
- environment: z.string().describe('Environment name or ID'),
275
- replicas: z.number().min(1).max(8).describe('Desired number of replicas (1–8)'),
276
- },
277
- annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
278
- }, async ({ appName, environment, replicas }) => {
279
- try {
280
- const orgId = await client.getDefaultOrgId();
281
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
282
- const deployment = await client.cloudHub2.findByName(orgId, env.id, appName);
283
- if (!deployment) {
284
- return {
285
- content: [{ type: 'text', text: `Application "${appName}" not found in ${env.name}` }],
286
- isError: true,
287
- };
288
- }
289
- await client.cloudHub2.scaleApp(orgId, env.id, deployment.id, replicas);
290
- return {
291
- content: [
292
- {
293
- type: 'text',
294
- text: `✅ Scaled "${appName}" to ${replicas} replica(s) in ${env.name}. Use get_app_status to monitor.`,
295
- },
296
- ],
297
- };
298
- }
299
- catch (error) {
300
- return mcpError(error);
301
- }
302
- });
303
- // ── New tools ─────────────────────────────────────────
304
- server.registerTool('deploy_app', {
305
- title: 'Deploy Application',
306
- description: 'Deploys or redeploys a Mule application to CloudHub 2.0 using Maven coordinates (groupId:artifactId:version) referencing an artifact already published to Exchange. If the application already exists it will be updated (redeployed); otherwise a new deployment is created. Returns the deployment ID and initial status — use get_app_status to monitor progress.',
307
- inputSchema: {
308
- appName: z.string().describe('Application name (used as deployment name and public URL slug)'),
309
- environment: z.string().describe('Environment name (e.g. "Sandbox", "Production") or environment ID'),
310
- groupId: z.string().describe('Maven group ID of the application artifact (usually the org ID)'),
311
- artifactId: z.string().describe('Maven artifact ID (e.g. "order-management-api")'),
312
- version: z.string().describe('Artifact version (e.g. "1.2.0", "1.0.0-SNAPSHOT")'),
313
- runtime: z
314
- .string()
315
- .optional()
316
- .describe('Mule runtime version (default: "4.8.0"). Examples: "4.6.0", "4.7.0", "4.8.0"'),
317
- replicas: z.number().min(1).max(8).optional().describe('Number of replicas (default: 1, max: 8)'),
318
- region: z
319
- .string()
320
- .optional()
321
- .describe('CloudHub 2.0 target region (default: "cloudhub-us-east-2"). Examples: "cloudhub-us-east-1", "cloudhub-eu-west-1", "cloudhub-ap-southeast-1"'),
322
- vcores: z
323
- .string()
324
- .optional()
325
- .describe('vCore size (default: "0.1"). Options: "0.1", "0.2", "0.5", "1", "1.5", "2", "2.5", "3", "4"'),
326
- properties: z
327
- .record(z.string())
328
- .optional()
329
- .describe('Application properties as key-value pairs to set on deploy'),
330
- secureProperties: z
331
- .record(z.string())
332
- .optional()
333
- .describe('Secure (encrypted) application properties as key-value pairs'),
334
- jvmArgs: z.string().optional().describe('JVM arguments (e.g. "-XX:MaxMetaspaceSize=256m")'),
335
- confirm: z
336
- .boolean()
337
- .optional()
338
- .describe('Set true to apply. When omitted/false, returns a dry-run preview and changes nothing.'),
339
- },
340
- annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
341
- }, async ({ appName, environment, groupId, artifactId, version, runtime, replicas, region, vcores, properties, secureProperties, jvmArgs, confirm, }) => {
342
- try {
343
- const orgId = await client.getDefaultOrgId();
344
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
345
- const existing = await client.cloudHub2.findDetailByName(orgId, env.id, appName);
346
- // ── Update path: existing app → SAFE artifact-ref-only redeploy ──
347
- // Infra params (runtime/region/vcores/replicas/jvmArgs) are intentionally NOT
348
- // restated here; doing so previously clobbered the live deployment. They are
349
- // ignored on redeploy and the caller is told so.
350
- if (existing) {
351
- const ignored = [
352
- runtime && 'runtime',
353
- region && 'region',
354
- vcores && 'vcores',
355
- replicas && 'replicas',
356
- jvmArgs && 'jvmArgs',
357
- properties && 'properties',
358
- secureProperties && 'secureProperties',
359
- ].filter(Boolean);
360
- const merged = mergeForArtifactUpdate(existing, { groupId, artifactId, version });
361
- const currentVersion = existing.application?.ref?.version || null;
362
- if (!confirm) {
363
- return dryRunPreview({
364
- action: 'redeploy (artifact ref only)',
365
- app: appName,
366
- environment: env.name,
367
- current: {
368
- version: currentVersion,
369
- runtime: existing.target?.deploymentSettings?.runtime?.version,
370
- targetId: existing.target?.targetId,
371
- replicas: existing.target?.replicas,
372
- },
373
- next: { ref: merged.application.ref },
374
- preserved: 'runtime, target/space, replicas, resources, settings',
375
- ...(ignored.length
376
- ? {
377
- note: `Ignored on redeploy (use update_app_settings / a fresh deploy to change infra): ${ignored.join(', ')}`,
378
- }
379
- : {}),
380
- });
381
- }
382
- const deployment = await client.cloudHub2.updateArtifactRef(orgId, env.id, existing.id, merged.application.ref);
383
- return mcpText({
384
- message: `✅ Redeployed "${appName}" in ${env.name} (artifact ref only)`,
385
- deploymentId: deployment.id,
386
- status: deployment.status,
387
- version: `${groupId}:${artifactId}:${version}`,
388
- previousVersion: currentVersion,
389
- preserved: 'runtime, target/space, replicas, resources, settings',
390
- ...(ignored.length ? { ignored } : {}),
391
- tip: 'Use get_app_status to monitor deployment progress.',
392
- });
393
- }
394
- // ── Create path: new app → full payload from the shared builder ──
395
- const payload = buildCreatePayload({
396
- appName,
397
- groupId,
398
- artifactId,
399
- version,
400
- runtime,
401
- replicas,
402
- region,
403
- vcores,
404
- properties,
405
- secureProperties,
406
- jvmArgs,
407
- });
408
- if (!confirm) {
409
- return dryRunPreview({
410
- action: 'create new deployment',
411
- app: appName,
412
- environment: env.name,
413
- next: {
414
- version: `${groupId}:${artifactId}:${version}`,
415
- runtime: payload.target.deploymentSettings.runtime.version,
416
- region: payload.target.targetId,
417
- vCores: payload.application.vCores,
418
- replicas: payload.target.replicas,
419
- },
420
- });
421
- }
422
- const deployment = await client.cloudHub2.createDeployment(orgId, env.id, payload);
423
- return mcpText({
424
- message: `✅ Created new deployment for "${appName}" in ${env.name}`,
425
- deploymentId: deployment.id,
426
- status: deployment.status,
427
- version: `${groupId}:${artifactId}:${version}`,
428
- runtime: payload.target.deploymentSettings.runtime.version,
429
- vCores: payload.application.vCores,
430
- replicas: payload.target.replicas,
431
- region: payload.target.targetId,
432
- tip: 'Use get_app_status to monitor deployment progress.',
433
- });
434
- }
435
- catch (error) {
436
- return mcpError(error);
437
- }
438
- });
439
- server.registerTool('update_app_artifact', {
440
- title: 'Update Application Artifact (Safe Redeploy)',
441
- description: 'Safely redeploys an existing CloudHub 2.0 application to a new artifact version by PATCHing ONLY the application reference. The live Mule runtime, deployment target/space, replica count, resources, and settings are all preserved — this is the correct tool for a production version bump, and is preferred over deploy_app for existing apps. Optionally waits for the deployment to reach a running state. Pass confirm:true to apply; without it you get a dry-run preview of the ref change.',
442
- inputSchema: {
443
- appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
444
- environment: z.string().describe('Environment name (e.g. "Production") or environment ID'),
445
- version: z.string().describe('New artifact version to deploy (e.g. "1.4.12")'),
446
- artifactId: z.string().optional().describe('Maven artifact ID. Default: keep the existing one.'),
447
- groupId: z.string().optional().describe('Maven group ID. Default: keep the existing one.'),
448
- packaging: z
449
- .string()
450
- .optional()
451
- .describe('Artifact packaging. Default: keep existing (usually "jar").'),
452
- wait: z
453
- .boolean()
454
- .optional()
455
- .describe('Wait for the redeploy to reach a running state before returning (default: false).'),
456
- confirm: z
457
- .boolean()
458
- .optional()
459
- .describe('Set true to apply. When omitted/false, returns a dry-run preview and changes nothing.'),
460
- },
461
- annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
462
- }, async ({ appName, environment, version, artifactId, groupId, packaging, wait, confirm }) => {
463
- try {
464
- const orgId = await client.getDefaultOrgId();
465
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
466
- const existing = await client.cloudHub2.findDetailByName(orgId, env.id, appName);
467
- if (!existing) {
468
- return mcpText(`Application "${appName}" not found in ${env.name}. Use deploy_app to create a new deployment.`);
469
- }
470
- const merged = mergeForArtifactUpdate(existing, { groupId, artifactId, version, packaging });
471
- const oldRef = existing.application?.ref;
472
- if (!confirm) {
473
- return dryRunPreview({
474
- action: 'update artifact ref (safe redeploy)',
475
- app: appName,
476
- environment: env.name,
477
- current: { ref: oldRef },
478
- next: { ref: merged.application.ref },
479
- preserved: 'runtime, target/space, replicas, resources, settings',
480
- });
481
- }
482
- let deployment = await client.cloudHub2.updateArtifactRef(orgId, env.id, existing.id, merged.application.ref);
483
- let waitResult;
484
- if (wait) {
485
- try {
486
- deployment = await client.cloudHub2.waitForDeployment(orgId, env.id, deployment.id);
487
- waitResult = deployment.status;
488
- }
489
- catch (waitErr) {
490
- waitResult = `did not settle: ${errorMessage(waitErr)}`;
491
- }
492
- }
493
- return mcpText({
494
- message: `✅ Updated "${appName}" in ${env.name} to v${version}`,
495
- deploymentId: deployment.id,
496
- status: deployment.status,
497
- from: oldRef,
498
- to: merged.application.ref,
499
- preserved: 'runtime, target/space, replicas, resources, settings',
500
- ...(wait ? { waitResult } : { tip: 'Pass wait:true or use get_app_status to monitor progress.' }),
501
- });
502
- }
503
- catch (error) {
504
- return mcpError(error);
505
- }
506
- });
507
- server.registerTool('rollback_app', {
508
- title: 'Roll Back Application',
509
- description: 'Rolls an existing CloudHub 2.0 application back to a previous artifact by PATCHing only the application reference (runtime, target, replicas, and settings are preserved). By default it resolves the last successful or newest distinct historical artifact ref; pass toVersion to select a specific artifact version. Pass confirm:true to apply; without it you get a dry-run preview.',
510
- inputSchema: {
511
- appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
512
- environment: z.string().describe('Environment name (e.g. "Production") or environment ID'),
513
- toVersion: z
514
- .string()
515
- .optional()
516
- .describe('Artifact version to roll back to. Default: newest distinct historical artifact.'),
517
- wait: z
518
- .boolean()
519
- .optional()
520
- .describe('Wait for the rollback to reach a running state (default: false).'),
521
- confirm: z
522
- .boolean()
523
- .optional()
524
- .describe('Set true to apply. When omitted/false, returns a dry-run preview and changes nothing.'),
525
- },
526
- annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
527
- }, async ({ appName, environment, toVersion, wait, confirm }) => {
528
- try {
529
- const orgId = await client.getDefaultOrgId();
530
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
531
- const existing = await client.cloudHub2.findDetailByName(orgId, env.id, appName);
532
- if (!existing) {
533
- return mcpText(`Application "${appName}" not found in ${env.name}`);
534
- }
535
- const specs = await client.cloudHub2.getDeploymentSpecs(orgId, env.id, existing.id);
536
- const target = resolveRollbackTarget(existing, specs, toVersion);
537
- if (!target) {
538
- return mcpText(`No distinct rollback target for "${appName}" in ${env.name}. ` +
539
- 'Pass toVersion to select a specific artifact version.');
540
- }
541
- if (!confirm) {
542
- return dryRunPreview({
543
- action: 'rollback (artifact ref only)',
544
- app: appName,
545
- environment: env.name,
546
- current: { ref: existing.application.ref, specId: existing.desiredVersion },
547
- next: { ref: target.ref, sourceSpecId: target.sourceSpecId },
548
- preserved: 'runtime, target/space, replicas, resources, settings',
549
- });
550
- }
551
- let deployment = await client.cloudHub2.rollbackToRef(orgId, env.id, existing.id, target.ref);
552
- let waitResult;
553
- if (wait) {
554
- try {
555
- deployment = await client.cloudHub2.waitForDeployment(orgId, env.id, deployment.id);
556
- waitResult = deployment.status;
557
- }
558
- catch (waitErr) {
559
- waitResult = `did not settle: ${errorMessage(waitErr)}`;
560
- }
561
- }
562
- return mcpText({
563
- message: `✅ Rolled back "${appName}" in ${env.name}: ${existing.application.ref.version} → ${target.ref.version}`,
564
- deploymentId: deployment.id,
565
- status: deployment.status,
566
- rolledBackFrom: existing.application.ref,
567
- rolledBackTo: target.ref,
568
- sourceSpecId: target.sourceSpecId,
569
- preserved: 'runtime, target/space, replicas, resources, settings',
570
- ...(wait ? { waitResult } : {}),
571
- });
572
- }
573
- catch (error) {
574
- return mcpError(error);
575
- }
576
- });
577
- server.registerTool('update_app_settings', {
578
- title: 'Update Application Settings',
579
- description: 'Updates application properties for a deployed Mule application in CloudHub 2.0. Merges the provided properties with existing ones (does not remove properties not specified). Triggers a rolling restart to apply the new configuration. Use this to change environment-specific config like database URLs, API keys, or feature flags without redeploying a new JAR.',
580
- inputSchema: {
581
- appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
582
- environment: z.string().describe('Environment name or ID'),
583
- properties: z
584
- .record(z.string())
585
- .optional()
586
- .describe('Plain-text application properties to set or update (merged with existing)'),
587
- secureProperties: z
588
- .record(z.string())
589
- .optional()
590
- .describe('Secure (encrypted) properties to set or update (merged with existing)'),
591
- },
592
- annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
593
- }, async ({ appName, environment, properties, secureProperties }) => {
594
- try {
595
- if (Object.keys(properties ?? {}).length + Object.keys(secureProperties ?? {}).length === 0) {
596
- return {
597
- content: [
598
- {
599
- type: 'text',
600
- text: 'At least one of "properties" or "secureProperties" must be provided.',
601
- },
602
- ],
603
- isError: true,
604
- };
605
- }
606
- const orgId = await client.getDefaultOrgId();
607
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
608
- const detail = await client.cloudHub2.findDetailByName(orgId, env.id, appName);
609
- if (!detail) {
610
- return {
611
- content: [{ type: 'text', text: `Application "${appName}" not found in ${env.name}` }],
612
- isError: true,
613
- };
614
- }
615
- const merged = mergeApplicationProperties(detail, properties, secureProperties);
616
- await client.cloudHub2.updateApplicationConfiguration(orgId, env.id, detail.id, merged);
617
- return {
618
- content: [
619
- {
620
- type: 'text',
621
- text: JSON.stringify({
622
- message: `✅ Updated settings for "${appName}" in ${env.name}. Rolling restart triggered.`,
623
- propertiesUpdated: properties ? Object.keys(properties) : [],
624
- securePropertiesUpdated: secureProperties ? Object.keys(secureProperties) : [],
625
- tip: 'Use get_app_status to monitor the restart, and get_app_settings to verify.',
626
- }, null, 2),
627
- },
628
- ],
629
- };
630
- }
631
- catch (error) {
632
- return mcpError(error);
633
- }
634
- });
635
- server.registerTool('delete_app', {
636
- title: 'Delete Application Deployment',
637
- 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.',
638
- inputSchema: {
639
- appName: z.string().describe('Application name exactly as deployed (case-insensitive match)'),
640
- environment: z.string().describe('Environment name or ID'),
641
- confirm: z.boolean().optional().describe('Set true only after reviewing the dry-run preview.'),
642
- expectedDeploymentId: z
643
- .string()
644
- .optional()
645
- .describe('Exact deployment ID returned by the dry-run preview; binds confirmation to one deployment.'),
646
- confirmProduction: z
647
- .boolean()
648
- .optional()
649
- .describe('Required in addition to confirm:true when the resolved environment is production.'),
650
- },
651
- annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
652
- }, async ({ appName, environment, confirm, expectedDeploymentId, confirmProduction }) => {
653
- try {
654
- const orgId = await client.getDefaultOrgId();
655
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
656
- const deployment = await client.cloudHub2.findDetailByName(orgId, env.id, appName);
657
- if (!deployment) {
658
- if (confirm && expectedDeploymentId) {
659
- return mcpText({
660
- deleted: false,
661
- alreadyAbsent: true,
662
- verifiedAbsent: true,
663
- app: appName,
664
- environment: env.name,
665
- expectedDeploymentId,
666
- });
667
- }
668
- return {
669
- ...mcpText({ message: `Application "${appName}" not found in ${env.name}` }),
670
- isError: true,
671
- };
672
- }
673
- const preview = buildApplicationDeletionPreview(deployment, env);
674
- if (!confirm) {
675
- return dryRunPreview({
676
- ...preview,
677
- confirmation: {
678
- confirm: true,
679
- expectedDeploymentId: deployment.id,
680
- ...(preview.production ? { confirmProduction: true } : {}),
681
- },
682
- });
683
- }
684
- if (!deploymentIdMatches(expectedDeploymentId, deployment.id)) {
685
- return {
686
- ...mcpText({
687
- message: 'Deletion refused: expectedDeploymentId is missing or does not match the current deployment.',
688
- expectedDeploymentId: expectedDeploymentId ?? null,
689
- currentDeploymentId: deployment.id,
690
- app: deployment.name,
691
- environment: env.name,
692
- }),
693
- isError: true,
694
- };
695
- }
696
- if (preview.production && !confirmProduction) {
697
- return {
698
- ...mcpText({
699
- message: 'Deletion refused: production requires confirmProduction:true.',
700
- app: deployment.name,
701
- environment: env.name,
702
- deploymentId: deployment.id,
703
- }),
704
- isError: true,
705
- };
706
- }
707
- await client.cloudHub2.deleteDeployment(orgId, env.id, deployment.id);
708
- const verification = await client.cloudHub2.waitForDeploymentDeletion(orgId, env.id, deployment.name, deployment.id);
709
- if (verification.replacementDeploymentId) {
710
- return {
711
- ...mcpText({
712
- deletionAccepted: true,
713
- verifiedAbsent: false,
714
- replacementDetected: true,
715
- deletedDeploymentId: deployment.id,
716
- replacementDeploymentId: verification.replacementDeploymentId,
717
- message: 'The original deployment was deleted, but a new deployment now uses the same name.',
718
- }),
719
- isError: true,
720
- };
721
- }
722
- if (!verification.verifiedAbsent) {
723
- return mcpText({
724
- deletionAccepted: true,
725
- verifiedAbsent: false,
726
- ...(verification.deletionState ? { deletionState: verification.deletionState } : {}),
727
- deploymentId: deployment.id,
728
- app: deployment.name,
729
- environment: env.name,
730
- message: verification.deletionState
731
- ? 'CloudHub marks the deployment as DELETED, but its tombstone remains visible in the list.'
732
- : 'CloudHub accepted deletion, but absence was not verified within 60 seconds.',
733
- });
734
- }
735
- return mcpText({
736
- deleted: true,
737
- verifiedAbsent: true,
738
- deploymentId: deployment.id,
739
- app: deployment.name,
740
- environment: env.name,
741
- preserved: preview.preserved,
742
- });
743
- }
744
- catch (error) {
745
- return mcpError(error);
746
- }
747
- });
748
- server.registerTool('stop_app', {
749
- title: 'Stop Application',
750
- description: "Stops a running Mule application in CloudHub 2.0 without deleting the deployment. The application's replicas are terminated but the deployment configuration is preserved. Use this to temporarily take an app offline for maintenance, cost savings, or to prevent traffic during investigations. Use start_app to bring it back online.",
751
- inputSchema: {
752
- appName: z.string().describe('Application name exactly as deployed'),
753
- environment: z.string().describe('Environment name or ID'),
754
- },
755
- annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
756
- }, async ({ appName, environment }) => {
757
- try {
758
- const orgId = await client.getDefaultOrgId();
759
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
760
- const deployment = await client.cloudHub2.findByName(orgId, env.id, appName);
761
- if (!deployment) {
762
- return {
763
- content: [{ type: 'text', text: `Application "${appName}" not found in ${env.name}` }],
764
- isError: true,
765
- };
766
- }
767
- await client.cloudHub2.setDesiredState(orgId, env.id, deployment.id, 'STOPPED');
768
- return {
769
- content: [
770
- {
771
- type: 'text',
772
- text: `✅ Stop initiated for "${appName}" in ${env.name}. Replicas will be terminated. Use get_app_status to monitor, and start_app to bring it back online.`,
773
- },
774
- ],
775
- };
776
- }
777
- catch (error) {
778
- return mcpError(error);
779
- }
780
- });
781
- server.registerTool('start_app', {
782
- title: 'Start Application',
783
- description: 'Starts a stopped Mule application in CloudHub 2.0. Brings the application back online by requesting the desired state to STARTED. Use this after stop_app to resume processing, or to recover an app that was manually stopped.',
784
- inputSchema: {
785
- appName: z.string().describe('Application name exactly as deployed'),
786
- environment: z.string().describe('Environment name or ID'),
787
- },
788
- annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
789
- }, async ({ appName, environment }) => {
790
- try {
791
- const orgId = await client.getDefaultOrgId();
792
- const env = await client.accessManagement.resolveEnvironment(orgId, environment);
793
- const deployment = await client.cloudHub2.findByName(orgId, env.id, appName);
794
- if (!deployment) {
795
- return {
796
- content: [{ type: 'text', text: `Application "${appName}" not found in ${env.name}` }],
797
- isError: true,
798
- };
799
- }
800
- await client.cloudHub2.setDesiredState(orgId, env.id, deployment.id, 'STARTED');
801
- return {
802
- content: [
803
- {
804
- type: 'text',
805
- text: `✅ Start initiated for "${appName}" in ${env.name}. Use get_app_status to monitor replica startup.`,
806
- },
807
- ],
808
- };
809
- }
810
- catch (error) {
811
- return mcpError(error);
812
- }
813
- });
814
- }
815
- //# sourceMappingURL=applications.js.map