@purplesquirrel/ibmcloud-mcp-server 1.0.0
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/.github/dependabot.yml +21 -0
- package/.github/workflows/ci.yml +36 -0
- package/LICENSE +21 -0
- package/README.md +238 -0
- package/package.json +27 -0
- package/src/cli.ts +103 -0
- package/src/index.ts +1401 -0
- package/tsconfig.json +20 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,1401 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import {
|
|
5
|
+
CallToolRequestSchema,
|
|
6
|
+
ListToolsRequestSchema,
|
|
7
|
+
Tool,
|
|
8
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
+
import { executeIBMCloud, formatResult } from "./cli.js";
|
|
10
|
+
|
|
11
|
+
// Authentication Tools
|
|
12
|
+
const authTools: Tool[] = [
|
|
13
|
+
{
|
|
14
|
+
name: "ibmcloud_login",
|
|
15
|
+
description: "Login to IBM Cloud with API key or SSO",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: {
|
|
19
|
+
apikey: { type: "string", description: "IBM Cloud API key" },
|
|
20
|
+
sso: { type: "boolean", description: "Use SSO for login" },
|
|
21
|
+
region: { type: "string", description: "Target region (e.g., us-south)" },
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "ibmcloud_logout",
|
|
27
|
+
description: "Logout from IBM Cloud",
|
|
28
|
+
inputSchema: { type: "object", properties: {} },
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "ibmcloud_target",
|
|
32
|
+
description: "View or set target region, resource group, org, and space",
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
region: { type: "string", description: "Target region" },
|
|
37
|
+
resource_group: { type: "string", description: "Target resource group" },
|
|
38
|
+
org: { type: "string", description: "Target Cloud Foundry org" },
|
|
39
|
+
space: { type: "string", description: "Target Cloud Foundry space" },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "ibmcloud_api",
|
|
45
|
+
description: "View or set IBM Cloud API endpoint",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
endpoint: { type: "string", description: "API endpoint URL" },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "ibmcloud_regions",
|
|
55
|
+
description: "List available IBM Cloud regions",
|
|
56
|
+
inputSchema: { type: "object", properties: {} },
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "ibmcloud_account_show",
|
|
60
|
+
description: "Show current account information",
|
|
61
|
+
inputSchema: { type: "object", properties: {} },
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "ibmcloud_account_list",
|
|
65
|
+
description: "List all accessible accounts",
|
|
66
|
+
inputSchema: { type: "object", properties: {} },
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "ibmcloud_config_list",
|
|
70
|
+
description: "List CLI configuration",
|
|
71
|
+
inputSchema: { type: "object", properties: {} },
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
// Resource Management Tools
|
|
76
|
+
const resourceTools: Tool[] = [
|
|
77
|
+
{
|
|
78
|
+
name: "ibmcloud_resource_groups",
|
|
79
|
+
description: "List resource groups",
|
|
80
|
+
inputSchema: { type: "object", properties: {} },
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "ibmcloud_resource_group_create",
|
|
84
|
+
description: "Create a resource group",
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
name: { type: "string", description: "Resource group name" },
|
|
89
|
+
},
|
|
90
|
+
required: ["name"],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "ibmcloud_resource_service_instances",
|
|
95
|
+
description: "List service instances",
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: {
|
|
99
|
+
service_name: { type: "string", description: "Filter by service name" },
|
|
100
|
+
resource_group: { type: "string", description: "Filter by resource group" },
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "ibmcloud_resource_service_instance",
|
|
106
|
+
description: "Get details of a service instance",
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
name: { type: "string", description: "Service instance name or ID" },
|
|
111
|
+
},
|
|
112
|
+
required: ["name"],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "ibmcloud_resource_service_instance_create",
|
|
117
|
+
description: "Create a service instance",
|
|
118
|
+
inputSchema: {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: {
|
|
121
|
+
name: { type: "string", description: "Instance name" },
|
|
122
|
+
service: { type: "string", description: "Service name (e.g., cloud-object-storage)" },
|
|
123
|
+
plan: { type: "string", description: "Service plan (e.g., standard, lite)" },
|
|
124
|
+
location: { type: "string", description: "Location (e.g., global, us-south)" },
|
|
125
|
+
resource_group: { type: "string", description: "Resource group name" },
|
|
126
|
+
parameters: { type: "string", description: "Service-specific parameters as JSON" },
|
|
127
|
+
},
|
|
128
|
+
required: ["name", "service", "plan"],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "ibmcloud_resource_service_instance_delete",
|
|
133
|
+
description: "Delete a service instance",
|
|
134
|
+
inputSchema: {
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
name: { type: "string", description: "Service instance name or ID" },
|
|
138
|
+
force: { type: "boolean", description: "Force deletion without confirmation" },
|
|
139
|
+
},
|
|
140
|
+
required: ["name"],
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "ibmcloud_resource_service_instance_update",
|
|
145
|
+
description: "Update a service instance",
|
|
146
|
+
inputSchema: {
|
|
147
|
+
type: "object",
|
|
148
|
+
properties: {
|
|
149
|
+
name: { type: "string", description: "Service instance name or ID" },
|
|
150
|
+
new_name: { type: "string", description: "New name for the instance" },
|
|
151
|
+
plan: { type: "string", description: "New service plan" },
|
|
152
|
+
parameters: { type: "string", description: "Service-specific parameters as JSON" },
|
|
153
|
+
},
|
|
154
|
+
required: ["name"],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "ibmcloud_resource_service_keys",
|
|
159
|
+
description: "List service keys/credentials",
|
|
160
|
+
inputSchema: {
|
|
161
|
+
type: "object",
|
|
162
|
+
properties: {
|
|
163
|
+
instance: { type: "string", description: "Service instance name" },
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "ibmcloud_resource_service_key",
|
|
169
|
+
description: "Get details of a service key",
|
|
170
|
+
inputSchema: {
|
|
171
|
+
type: "object",
|
|
172
|
+
properties: {
|
|
173
|
+
name: { type: "string", description: "Service key name" },
|
|
174
|
+
},
|
|
175
|
+
required: ["name"],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "ibmcloud_resource_service_key_create",
|
|
180
|
+
description: "Create a service key/credential",
|
|
181
|
+
inputSchema: {
|
|
182
|
+
type: "object",
|
|
183
|
+
properties: {
|
|
184
|
+
name: { type: "string", description: "Key name" },
|
|
185
|
+
instance: { type: "string", description: "Service instance name" },
|
|
186
|
+
role: { type: "string", description: "IAM role (e.g., Writer, Reader, Manager)" },
|
|
187
|
+
parameters: { type: "string", description: "Service-specific parameters as JSON" },
|
|
188
|
+
},
|
|
189
|
+
required: ["name", "instance"],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "ibmcloud_resource_service_key_delete",
|
|
194
|
+
description: "Delete a service key",
|
|
195
|
+
inputSchema: {
|
|
196
|
+
type: "object",
|
|
197
|
+
properties: {
|
|
198
|
+
name: { type: "string", description: "Service key name" },
|
|
199
|
+
force: { type: "boolean", description: "Force deletion without confirmation" },
|
|
200
|
+
},
|
|
201
|
+
required: ["name"],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "ibmcloud_resource_search",
|
|
206
|
+
description: "Search for resources",
|
|
207
|
+
inputSchema: {
|
|
208
|
+
type: "object",
|
|
209
|
+
properties: {
|
|
210
|
+
query: { type: "string", description: "Search query (Lucene syntax)" },
|
|
211
|
+
},
|
|
212
|
+
required: ["query"],
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: "ibmcloud_resource_tags",
|
|
217
|
+
description: "List tags",
|
|
218
|
+
inputSchema: {
|
|
219
|
+
type: "object",
|
|
220
|
+
properties: {
|
|
221
|
+
resource_id: { type: "string", description: "Filter by resource CRN" },
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: "ibmcloud_resource_tag_attach",
|
|
227
|
+
description: "Attach tags to a resource",
|
|
228
|
+
inputSchema: {
|
|
229
|
+
type: "object",
|
|
230
|
+
properties: {
|
|
231
|
+
resource_id: { type: "string", description: "Resource CRN" },
|
|
232
|
+
tags: { type: "string", description: "Comma-separated list of tags" },
|
|
233
|
+
},
|
|
234
|
+
required: ["resource_id", "tags"],
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
];
|
|
238
|
+
|
|
239
|
+
// Cloud Foundry Tools
|
|
240
|
+
const cfTools: Tool[] = [
|
|
241
|
+
{
|
|
242
|
+
name: "ibmcloud_cf_orgs",
|
|
243
|
+
description: "List Cloud Foundry organizations",
|
|
244
|
+
inputSchema: { type: "object", properties: {} },
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "ibmcloud_cf_spaces",
|
|
248
|
+
description: "List Cloud Foundry spaces",
|
|
249
|
+
inputSchema: {
|
|
250
|
+
type: "object",
|
|
251
|
+
properties: {
|
|
252
|
+
org: { type: "string", description: "Organization name" },
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "ibmcloud_cf_apps",
|
|
258
|
+
description: "List Cloud Foundry applications",
|
|
259
|
+
inputSchema: { type: "object", properties: {} },
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: "ibmcloud_cf_app",
|
|
263
|
+
description: "Get Cloud Foundry application details",
|
|
264
|
+
inputSchema: {
|
|
265
|
+
type: "object",
|
|
266
|
+
properties: {
|
|
267
|
+
name: { type: "string", description: "Application name" },
|
|
268
|
+
},
|
|
269
|
+
required: ["name"],
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "ibmcloud_cf_push",
|
|
274
|
+
description: "Deploy a Cloud Foundry application",
|
|
275
|
+
inputSchema: {
|
|
276
|
+
type: "object",
|
|
277
|
+
properties: {
|
|
278
|
+
name: { type: "string", description: "Application name" },
|
|
279
|
+
path: { type: "string", description: "Path to application" },
|
|
280
|
+
manifest: { type: "string", description: "Path to manifest file" },
|
|
281
|
+
memory: { type: "string", description: "Memory limit (e.g., 256M, 1G)" },
|
|
282
|
+
instances: { type: "number", description: "Number of instances" },
|
|
283
|
+
buildpack: { type: "string", description: "Buildpack name or URL" },
|
|
284
|
+
docker_image: { type: "string", description: "Docker image" },
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: "ibmcloud_cf_start",
|
|
290
|
+
description: "Start a Cloud Foundry application",
|
|
291
|
+
inputSchema: {
|
|
292
|
+
type: "object",
|
|
293
|
+
properties: {
|
|
294
|
+
name: { type: "string", description: "Application name" },
|
|
295
|
+
},
|
|
296
|
+
required: ["name"],
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: "ibmcloud_cf_stop",
|
|
301
|
+
description: "Stop a Cloud Foundry application",
|
|
302
|
+
inputSchema: {
|
|
303
|
+
type: "object",
|
|
304
|
+
properties: {
|
|
305
|
+
name: { type: "string", description: "Application name" },
|
|
306
|
+
},
|
|
307
|
+
required: ["name"],
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: "ibmcloud_cf_restart",
|
|
312
|
+
description: "Restart a Cloud Foundry application",
|
|
313
|
+
inputSchema: {
|
|
314
|
+
type: "object",
|
|
315
|
+
properties: {
|
|
316
|
+
name: { type: "string", description: "Application name" },
|
|
317
|
+
},
|
|
318
|
+
required: ["name"],
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: "ibmcloud_cf_delete",
|
|
323
|
+
description: "Delete a Cloud Foundry application",
|
|
324
|
+
inputSchema: {
|
|
325
|
+
type: "object",
|
|
326
|
+
properties: {
|
|
327
|
+
name: { type: "string", description: "Application name" },
|
|
328
|
+
force: { type: "boolean", description: "Force deletion without confirmation" },
|
|
329
|
+
delete_routes: { type: "boolean", description: "Also delete mapped routes" },
|
|
330
|
+
},
|
|
331
|
+
required: ["name"],
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: "ibmcloud_cf_logs",
|
|
336
|
+
description: "View recent logs for an application",
|
|
337
|
+
inputSchema: {
|
|
338
|
+
type: "object",
|
|
339
|
+
properties: {
|
|
340
|
+
name: { type: "string", description: "Application name" },
|
|
341
|
+
recent: { type: "boolean", description: "Show recent logs (default: true)" },
|
|
342
|
+
},
|
|
343
|
+
required: ["name"],
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "ibmcloud_cf_env",
|
|
348
|
+
description: "Show environment variables for an application",
|
|
349
|
+
inputSchema: {
|
|
350
|
+
type: "object",
|
|
351
|
+
properties: {
|
|
352
|
+
name: { type: "string", description: "Application name" },
|
|
353
|
+
},
|
|
354
|
+
required: ["name"],
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: "ibmcloud_cf_set_env",
|
|
359
|
+
description: "Set an environment variable for an application",
|
|
360
|
+
inputSchema: {
|
|
361
|
+
type: "object",
|
|
362
|
+
properties: {
|
|
363
|
+
name: { type: "string", description: "Application name" },
|
|
364
|
+
var_name: { type: "string", description: "Environment variable name" },
|
|
365
|
+
var_value: { type: "string", description: "Environment variable value" },
|
|
366
|
+
},
|
|
367
|
+
required: ["name", "var_name", "var_value"],
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: "ibmcloud_cf_scale",
|
|
372
|
+
description: "Scale a Cloud Foundry application",
|
|
373
|
+
inputSchema: {
|
|
374
|
+
type: "object",
|
|
375
|
+
properties: {
|
|
376
|
+
name: { type: "string", description: "Application name" },
|
|
377
|
+
instances: { type: "number", description: "Number of instances" },
|
|
378
|
+
memory: { type: "string", description: "Memory limit (e.g., 512M)" },
|
|
379
|
+
disk: { type: "string", description: "Disk limit (e.g., 1G)" },
|
|
380
|
+
},
|
|
381
|
+
required: ["name"],
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "ibmcloud_cf_routes",
|
|
386
|
+
description: "List Cloud Foundry routes",
|
|
387
|
+
inputSchema: { type: "object", properties: {} },
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: "ibmcloud_cf_services",
|
|
391
|
+
description: "List Cloud Foundry services",
|
|
392
|
+
inputSchema: { type: "object", properties: {} },
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "ibmcloud_cf_marketplace",
|
|
396
|
+
description: "List marketplace services",
|
|
397
|
+
inputSchema: {
|
|
398
|
+
type: "object",
|
|
399
|
+
properties: {
|
|
400
|
+
service: { type: "string", description: "Show plans for a specific service" },
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "ibmcloud_cf_create_service",
|
|
406
|
+
description: "Create a Cloud Foundry service instance",
|
|
407
|
+
inputSchema: {
|
|
408
|
+
type: "object",
|
|
409
|
+
properties: {
|
|
410
|
+
service: { type: "string", description: "Service offering name" },
|
|
411
|
+
plan: { type: "string", description: "Service plan" },
|
|
412
|
+
instance_name: { type: "string", description: "Service instance name" },
|
|
413
|
+
parameters: { type: "string", description: "JSON parameters" },
|
|
414
|
+
},
|
|
415
|
+
required: ["service", "plan", "instance_name"],
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: "ibmcloud_cf_bind_service",
|
|
420
|
+
description: "Bind a service to an application",
|
|
421
|
+
inputSchema: {
|
|
422
|
+
type: "object",
|
|
423
|
+
properties: {
|
|
424
|
+
app_name: { type: "string", description: "Application name" },
|
|
425
|
+
service_instance: { type: "string", description: "Service instance name" },
|
|
426
|
+
parameters: { type: "string", description: "JSON binding parameters" },
|
|
427
|
+
},
|
|
428
|
+
required: ["app_name", "service_instance"],
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
name: "ibmcloud_cf_unbind_service",
|
|
433
|
+
description: "Unbind a service from an application",
|
|
434
|
+
inputSchema: {
|
|
435
|
+
type: "object",
|
|
436
|
+
properties: {
|
|
437
|
+
app_name: { type: "string", description: "Application name" },
|
|
438
|
+
service_instance: { type: "string", description: "Service instance name" },
|
|
439
|
+
},
|
|
440
|
+
required: ["app_name", "service_instance"],
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
];
|
|
444
|
+
|
|
445
|
+
// Kubernetes & Container Registry Tools
|
|
446
|
+
const ksTools: Tool[] = [
|
|
447
|
+
{
|
|
448
|
+
name: "ibmcloud_ks_clusters",
|
|
449
|
+
description: "List Kubernetes clusters",
|
|
450
|
+
inputSchema: {
|
|
451
|
+
type: "object",
|
|
452
|
+
properties: {
|
|
453
|
+
provider: { type: "string", description: "Filter by provider (vpc-gen2, classic)" },
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: "ibmcloud_ks_cluster",
|
|
459
|
+
description: "Get cluster details",
|
|
460
|
+
inputSchema: {
|
|
461
|
+
type: "object",
|
|
462
|
+
properties: {
|
|
463
|
+
cluster: { type: "string", description: "Cluster name or ID" },
|
|
464
|
+
},
|
|
465
|
+
required: ["cluster"],
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
name: "ibmcloud_ks_cluster_config",
|
|
470
|
+
description: "Configure kubectl for a cluster",
|
|
471
|
+
inputSchema: {
|
|
472
|
+
type: "object",
|
|
473
|
+
properties: {
|
|
474
|
+
cluster: { type: "string", description: "Cluster name or ID" },
|
|
475
|
+
admin: { type: "boolean", description: "Download admin certificates" },
|
|
476
|
+
},
|
|
477
|
+
required: ["cluster"],
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
name: "ibmcloud_ks_cluster_create",
|
|
482
|
+
description: "Create a Kubernetes cluster",
|
|
483
|
+
inputSchema: {
|
|
484
|
+
type: "object",
|
|
485
|
+
properties: {
|
|
486
|
+
name: { type: "string", description: "Cluster name" },
|
|
487
|
+
zone: { type: "string", description: "Zone (e.g., dal10)" },
|
|
488
|
+
flavor: { type: "string", description: "Worker node flavor" },
|
|
489
|
+
workers: { type: "number", description: "Number of workers" },
|
|
490
|
+
version: { type: "string", description: "Kubernetes version" },
|
|
491
|
+
vpc_id: { type: "string", description: "VPC ID for VPC clusters" },
|
|
492
|
+
subnet_id: { type: "string", description: "Subnet ID for VPC clusters" },
|
|
493
|
+
},
|
|
494
|
+
required: ["name", "zone"],
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
name: "ibmcloud_ks_cluster_delete",
|
|
499
|
+
description: "Delete a Kubernetes cluster",
|
|
500
|
+
inputSchema: {
|
|
501
|
+
type: "object",
|
|
502
|
+
properties: {
|
|
503
|
+
cluster: { type: "string", description: "Cluster name or ID" },
|
|
504
|
+
force: { type: "boolean", description: "Force deletion" },
|
|
505
|
+
},
|
|
506
|
+
required: ["cluster"],
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
name: "ibmcloud_ks_workers",
|
|
511
|
+
description: "List worker nodes in a cluster",
|
|
512
|
+
inputSchema: {
|
|
513
|
+
type: "object",
|
|
514
|
+
properties: {
|
|
515
|
+
cluster: { type: "string", description: "Cluster name or ID" },
|
|
516
|
+
},
|
|
517
|
+
required: ["cluster"],
|
|
518
|
+
},
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: "ibmcloud_ks_worker_pools",
|
|
522
|
+
description: "List worker pools in a cluster",
|
|
523
|
+
inputSchema: {
|
|
524
|
+
type: "object",
|
|
525
|
+
properties: {
|
|
526
|
+
cluster: { type: "string", description: "Cluster name or ID" },
|
|
527
|
+
},
|
|
528
|
+
required: ["cluster"],
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
name: "ibmcloud_ks_worker_pool_create",
|
|
533
|
+
description: "Create a worker pool",
|
|
534
|
+
inputSchema: {
|
|
535
|
+
type: "object",
|
|
536
|
+
properties: {
|
|
537
|
+
cluster: { type: "string", description: "Cluster name or ID" },
|
|
538
|
+
name: { type: "string", description: "Worker pool name" },
|
|
539
|
+
flavor: { type: "string", description: "Worker node flavor" },
|
|
540
|
+
size_per_zone: { type: "number", description: "Workers per zone" },
|
|
541
|
+
},
|
|
542
|
+
required: ["cluster", "name", "flavor"],
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
name: "ibmcloud_ks_worker_pool_resize",
|
|
547
|
+
description: "Resize a worker pool",
|
|
548
|
+
inputSchema: {
|
|
549
|
+
type: "object",
|
|
550
|
+
properties: {
|
|
551
|
+
cluster: { type: "string", description: "Cluster name or ID" },
|
|
552
|
+
pool: { type: "string", description: "Worker pool name" },
|
|
553
|
+
size_per_zone: { type: "number", description: "New workers per zone" },
|
|
554
|
+
},
|
|
555
|
+
required: ["cluster", "pool", "size_per_zone"],
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
name: "ibmcloud_ks_zones",
|
|
560
|
+
description: "List available zones",
|
|
561
|
+
inputSchema: {
|
|
562
|
+
type: "object",
|
|
563
|
+
properties: {
|
|
564
|
+
provider: { type: "string", description: "Filter by provider" },
|
|
565
|
+
location: { type: "string", description: "Filter by location" },
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
name: "ibmcloud_ks_versions",
|
|
571
|
+
description: "List available Kubernetes versions",
|
|
572
|
+
inputSchema: { type: "object", properties: {} },
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
name: "ibmcloud_ks_flavors",
|
|
576
|
+
description: "List available machine types/flavors",
|
|
577
|
+
inputSchema: {
|
|
578
|
+
type: "object",
|
|
579
|
+
properties: {
|
|
580
|
+
zone: { type: "string", description: "Zone to list flavors for" },
|
|
581
|
+
provider: { type: "string", description: "Provider (vpc-gen2, classic)" },
|
|
582
|
+
},
|
|
583
|
+
required: ["zone"],
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
name: "ibmcloud_cr_namespaces",
|
|
588
|
+
description: "List Container Registry namespaces",
|
|
589
|
+
inputSchema: { type: "object", properties: {} },
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
name: "ibmcloud_cr_namespace_add",
|
|
593
|
+
description: "Create a Container Registry namespace",
|
|
594
|
+
inputSchema: {
|
|
595
|
+
type: "object",
|
|
596
|
+
properties: {
|
|
597
|
+
name: { type: "string", description: "Namespace name" },
|
|
598
|
+
resource_group: { type: "string", description: "Resource group" },
|
|
599
|
+
},
|
|
600
|
+
required: ["name"],
|
|
601
|
+
},
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
name: "ibmcloud_cr_images",
|
|
605
|
+
description: "List container images",
|
|
606
|
+
inputSchema: {
|
|
607
|
+
type: "object",
|
|
608
|
+
properties: {
|
|
609
|
+
repository: { type: "string", description: "Filter by repository" },
|
|
610
|
+
include_ibm: { type: "boolean", description: "Include IBM images" },
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
name: "ibmcloud_cr_image_rm",
|
|
616
|
+
description: "Remove a container image",
|
|
617
|
+
inputSchema: {
|
|
618
|
+
type: "object",
|
|
619
|
+
properties: {
|
|
620
|
+
image: { type: "string", description: "Image name with tag" },
|
|
621
|
+
force: { type: "boolean", description: "Force deletion" },
|
|
622
|
+
},
|
|
623
|
+
required: ["image"],
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
name: "ibmcloud_cr_quota",
|
|
628
|
+
description: "Get Container Registry quota information",
|
|
629
|
+
inputSchema: { type: "object", properties: {} },
|
|
630
|
+
},
|
|
631
|
+
];
|
|
632
|
+
|
|
633
|
+
// IAM Tools
|
|
634
|
+
const iamTools: Tool[] = [
|
|
635
|
+
{
|
|
636
|
+
name: "ibmcloud_iam_users",
|
|
637
|
+
description: "List users in the account",
|
|
638
|
+
inputSchema: { type: "object", properties: {} },
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
name: "ibmcloud_iam_user_invite",
|
|
642
|
+
description: "Invite a user to the account",
|
|
643
|
+
inputSchema: {
|
|
644
|
+
type: "object",
|
|
645
|
+
properties: {
|
|
646
|
+
email: { type: "string", description: "User email address" },
|
|
647
|
+
access_groups: { type: "string", description: "Comma-separated access group names" },
|
|
648
|
+
},
|
|
649
|
+
required: ["email"],
|
|
650
|
+
},
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
name: "ibmcloud_iam_api_keys",
|
|
654
|
+
description: "List API keys",
|
|
655
|
+
inputSchema: { type: "object", properties: {} },
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
name: "ibmcloud_iam_api_key_create",
|
|
659
|
+
description: "Create an API key",
|
|
660
|
+
inputSchema: {
|
|
661
|
+
type: "object",
|
|
662
|
+
properties: {
|
|
663
|
+
name: { type: "string", description: "API key name" },
|
|
664
|
+
description: { type: "string", description: "API key description" },
|
|
665
|
+
file: { type: "string", description: "File path to save the key" },
|
|
666
|
+
},
|
|
667
|
+
required: ["name"],
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
name: "ibmcloud_iam_api_key_delete",
|
|
672
|
+
description: "Delete an API key",
|
|
673
|
+
inputSchema: {
|
|
674
|
+
type: "object",
|
|
675
|
+
properties: {
|
|
676
|
+
name: { type: "string", description: "API key name or ID" },
|
|
677
|
+
force: { type: "boolean", description: "Force deletion" },
|
|
678
|
+
},
|
|
679
|
+
required: ["name"],
|
|
680
|
+
},
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
name: "ibmcloud_iam_service_ids",
|
|
684
|
+
description: "List service IDs",
|
|
685
|
+
inputSchema: { type: "object", properties: {} },
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
name: "ibmcloud_iam_service_id",
|
|
689
|
+
description: "Get service ID details",
|
|
690
|
+
inputSchema: {
|
|
691
|
+
type: "object",
|
|
692
|
+
properties: {
|
|
693
|
+
name: { type: "string", description: "Service ID name or UUID" },
|
|
694
|
+
},
|
|
695
|
+
required: ["name"],
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
name: "ibmcloud_iam_service_id_create",
|
|
700
|
+
description: "Create a service ID",
|
|
701
|
+
inputSchema: {
|
|
702
|
+
type: "object",
|
|
703
|
+
properties: {
|
|
704
|
+
name: { type: "string", description: "Service ID name" },
|
|
705
|
+
description: { type: "string", description: "Description" },
|
|
706
|
+
},
|
|
707
|
+
required: ["name"],
|
|
708
|
+
},
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
name: "ibmcloud_iam_service_id_delete",
|
|
712
|
+
description: "Delete a service ID",
|
|
713
|
+
inputSchema: {
|
|
714
|
+
type: "object",
|
|
715
|
+
properties: {
|
|
716
|
+
name: { type: "string", description: "Service ID name or UUID" },
|
|
717
|
+
force: { type: "boolean", description: "Force deletion" },
|
|
718
|
+
},
|
|
719
|
+
required: ["name"],
|
|
720
|
+
},
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
name: "ibmcloud_iam_service_api_keys",
|
|
724
|
+
description: "List API keys for a service ID",
|
|
725
|
+
inputSchema: {
|
|
726
|
+
type: "object",
|
|
727
|
+
properties: {
|
|
728
|
+
service_id: { type: "string", description: "Service ID name or UUID" },
|
|
729
|
+
},
|
|
730
|
+
required: ["service_id"],
|
|
731
|
+
},
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
name: "ibmcloud_iam_service_api_key_create",
|
|
735
|
+
description: "Create an API key for a service ID",
|
|
736
|
+
inputSchema: {
|
|
737
|
+
type: "object",
|
|
738
|
+
properties: {
|
|
739
|
+
name: { type: "string", description: "API key name" },
|
|
740
|
+
service_id: { type: "string", description: "Service ID name or UUID" },
|
|
741
|
+
description: { type: "string", description: "Description" },
|
|
742
|
+
file: { type: "string", description: "File path to save the key" },
|
|
743
|
+
},
|
|
744
|
+
required: ["name", "service_id"],
|
|
745
|
+
},
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
name: "ibmcloud_iam_access_groups",
|
|
749
|
+
description: "List access groups",
|
|
750
|
+
inputSchema: { type: "object", properties: {} },
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
name: "ibmcloud_iam_access_group",
|
|
754
|
+
description: "Get access group details",
|
|
755
|
+
inputSchema: {
|
|
756
|
+
type: "object",
|
|
757
|
+
properties: {
|
|
758
|
+
name: { type: "string", description: "Access group name" },
|
|
759
|
+
},
|
|
760
|
+
required: ["name"],
|
|
761
|
+
},
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
name: "ibmcloud_iam_access_group_create",
|
|
765
|
+
description: "Create an access group",
|
|
766
|
+
inputSchema: {
|
|
767
|
+
type: "object",
|
|
768
|
+
properties: {
|
|
769
|
+
name: { type: "string", description: "Access group name" },
|
|
770
|
+
description: { type: "string", description: "Description" },
|
|
771
|
+
},
|
|
772
|
+
required: ["name"],
|
|
773
|
+
},
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
name: "ibmcloud_iam_access_group_users",
|
|
777
|
+
description: "List users in an access group",
|
|
778
|
+
inputSchema: {
|
|
779
|
+
type: "object",
|
|
780
|
+
properties: {
|
|
781
|
+
group: { type: "string", description: "Access group name" },
|
|
782
|
+
},
|
|
783
|
+
required: ["group"],
|
|
784
|
+
},
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
name: "ibmcloud_iam_access_group_user_add",
|
|
788
|
+
description: "Add users to an access group",
|
|
789
|
+
inputSchema: {
|
|
790
|
+
type: "object",
|
|
791
|
+
properties: {
|
|
792
|
+
group: { type: "string", description: "Access group name" },
|
|
793
|
+
users: { type: "string", description: "Comma-separated user IDs" },
|
|
794
|
+
},
|
|
795
|
+
required: ["group", "users"],
|
|
796
|
+
},
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
name: "ibmcloud_iam_access_group_policies",
|
|
800
|
+
description: "List policies for an access group",
|
|
801
|
+
inputSchema: {
|
|
802
|
+
type: "object",
|
|
803
|
+
properties: {
|
|
804
|
+
group: { type: "string", description: "Access group name" },
|
|
805
|
+
},
|
|
806
|
+
required: ["group"],
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
name: "ibmcloud_iam_access_group_policy_create",
|
|
811
|
+
description: "Create a policy for an access group",
|
|
812
|
+
inputSchema: {
|
|
813
|
+
type: "object",
|
|
814
|
+
properties: {
|
|
815
|
+
group: { type: "string", description: "Access group name" },
|
|
816
|
+
roles: { type: "string", description: "Comma-separated roles" },
|
|
817
|
+
service_name: { type: "string", description: "Service name" },
|
|
818
|
+
resource_group: { type: "string", description: "Resource group name" },
|
|
819
|
+
resource_type: { type: "string", description: "Resource type" },
|
|
820
|
+
resource: { type: "string", description: "Resource name" },
|
|
821
|
+
},
|
|
822
|
+
required: ["group", "roles"],
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
name: "ibmcloud_iam_roles",
|
|
827
|
+
description: "List IAM roles",
|
|
828
|
+
inputSchema: {
|
|
829
|
+
type: "object",
|
|
830
|
+
properties: {
|
|
831
|
+
service: { type: "string", description: "Filter by service name" },
|
|
832
|
+
},
|
|
833
|
+
},
|
|
834
|
+
},
|
|
835
|
+
];
|
|
836
|
+
|
|
837
|
+
// Catalog & Billing Tools
|
|
838
|
+
const catalogBillingTools: Tool[] = [
|
|
839
|
+
{
|
|
840
|
+
name: "ibmcloud_catalog_search",
|
|
841
|
+
description: "Search the service catalog",
|
|
842
|
+
inputSchema: {
|
|
843
|
+
type: "object",
|
|
844
|
+
properties: {
|
|
845
|
+
query: { type: "string", description: "Search query" },
|
|
846
|
+
},
|
|
847
|
+
required: ["query"],
|
|
848
|
+
},
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
name: "ibmcloud_catalog_service",
|
|
852
|
+
description: "Get details about a catalog service",
|
|
853
|
+
inputSchema: {
|
|
854
|
+
type: "object",
|
|
855
|
+
properties: {
|
|
856
|
+
service: { type: "string", description: "Service name" },
|
|
857
|
+
},
|
|
858
|
+
required: ["service"],
|
|
859
|
+
},
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
name: "ibmcloud_catalog_service_plans",
|
|
863
|
+
description: "List plans for a catalog service",
|
|
864
|
+
inputSchema: {
|
|
865
|
+
type: "object",
|
|
866
|
+
properties: {
|
|
867
|
+
service: { type: "string", description: "Service name" },
|
|
868
|
+
},
|
|
869
|
+
required: ["service"],
|
|
870
|
+
},
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
name: "ibmcloud_billing_account_usage",
|
|
874
|
+
description: "Get account usage for a billing period",
|
|
875
|
+
inputSchema: {
|
|
876
|
+
type: "object",
|
|
877
|
+
properties: {
|
|
878
|
+
month: { type: "string", description: "Month (YYYY-MM)" },
|
|
879
|
+
},
|
|
880
|
+
},
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
name: "ibmcloud_billing_resource_group_usage",
|
|
884
|
+
description: "Get resource group usage",
|
|
885
|
+
inputSchema: {
|
|
886
|
+
type: "object",
|
|
887
|
+
properties: {
|
|
888
|
+
resource_group: { type: "string", description: "Resource group name" },
|
|
889
|
+
month: { type: "string", description: "Month (YYYY-MM)" },
|
|
890
|
+
},
|
|
891
|
+
required: ["resource_group"],
|
|
892
|
+
},
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
name: "ibmcloud_billing_resource_instances_usage",
|
|
896
|
+
description: "Get usage for resource instances",
|
|
897
|
+
inputSchema: {
|
|
898
|
+
type: "object",
|
|
899
|
+
properties: {
|
|
900
|
+
month: { type: "string", description: "Month (YYYY-MM)" },
|
|
901
|
+
resource_group: { type: "string", description: "Filter by resource group" },
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
name: "ibmcloud_billing_org_usage",
|
|
907
|
+
description: "Get Cloud Foundry org usage",
|
|
908
|
+
inputSchema: {
|
|
909
|
+
type: "object",
|
|
910
|
+
properties: {
|
|
911
|
+
org: { type: "string", description: "Organization name" },
|
|
912
|
+
month: { type: "string", description: "Month (YYYY-MM)" },
|
|
913
|
+
},
|
|
914
|
+
required: ["org"],
|
|
915
|
+
},
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
name: "ibmcloud_plugin_list",
|
|
919
|
+
description: "List installed CLI plugins",
|
|
920
|
+
inputSchema: { type: "object", properties: {} },
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
name: "ibmcloud_plugin_repo_plugins",
|
|
924
|
+
description: "List available plugins from repository",
|
|
925
|
+
inputSchema: { type: "object", properties: {} },
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
name: "ibmcloud_plugin_install",
|
|
929
|
+
description: "Install a CLI plugin",
|
|
930
|
+
inputSchema: {
|
|
931
|
+
type: "object",
|
|
932
|
+
properties: {
|
|
933
|
+
plugin: { type: "string", description: "Plugin name" },
|
|
934
|
+
force: { type: "boolean", description: "Force reinstall if exists" },
|
|
935
|
+
},
|
|
936
|
+
required: ["plugin"],
|
|
937
|
+
},
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
name: "ibmcloud_version",
|
|
941
|
+
description: "Show IBM Cloud CLI version",
|
|
942
|
+
inputSchema: { type: "object", properties: {} },
|
|
943
|
+
},
|
|
944
|
+
];
|
|
945
|
+
|
|
946
|
+
// All tools combined
|
|
947
|
+
const allTools = [
|
|
948
|
+
...authTools,
|
|
949
|
+
...resourceTools,
|
|
950
|
+
...cfTools,
|
|
951
|
+
...ksTools,
|
|
952
|
+
...iamTools,
|
|
953
|
+
...catalogBillingTools,
|
|
954
|
+
];
|
|
955
|
+
|
|
956
|
+
// Tool handlers
|
|
957
|
+
async function handleAuthTool(name: string, args: Record<string, unknown>): Promise<string> {
|
|
958
|
+
switch (name) {
|
|
959
|
+
case "ibmcloud_login": {
|
|
960
|
+
const cmdArgs = ["login"];
|
|
961
|
+
if (args.apikey) cmdArgs.push("--apikey", args.apikey as string);
|
|
962
|
+
if (args.sso) cmdArgs.push("--sso");
|
|
963
|
+
if (args.region) cmdArgs.push("-r", args.region as string);
|
|
964
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
965
|
+
}
|
|
966
|
+
case "ibmcloud_logout":
|
|
967
|
+
return formatResult(await executeIBMCloud(["logout"]));
|
|
968
|
+
case "ibmcloud_target": {
|
|
969
|
+
const cmdArgs = ["target"];
|
|
970
|
+
if (args.region) cmdArgs.push("-r", args.region as string);
|
|
971
|
+
if (args.resource_group) cmdArgs.push("-g", args.resource_group as string);
|
|
972
|
+
if (args.org) cmdArgs.push("-o", args.org as string);
|
|
973
|
+
if (args.space) cmdArgs.push("-s", args.space as string);
|
|
974
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
975
|
+
}
|
|
976
|
+
case "ibmcloud_api": {
|
|
977
|
+
const cmdArgs = ["api"];
|
|
978
|
+
if (args.endpoint) cmdArgs.push(args.endpoint as string);
|
|
979
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
980
|
+
}
|
|
981
|
+
case "ibmcloud_regions":
|
|
982
|
+
return formatResult(await executeIBMCloud(["regions"]));
|
|
983
|
+
case "ibmcloud_account_show":
|
|
984
|
+
return formatResult(await executeIBMCloud(["account", "show"]));
|
|
985
|
+
case "ibmcloud_account_list":
|
|
986
|
+
return formatResult(await executeIBMCloud(["account", "list"]));
|
|
987
|
+
case "ibmcloud_config_list":
|
|
988
|
+
return formatResult(await executeIBMCloud(["config", "list"]));
|
|
989
|
+
default:
|
|
990
|
+
throw new Error(`Unknown auth tool: ${name}`);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
async function handleResourceTool(name: string, args: Record<string, unknown>): Promise<string> {
|
|
995
|
+
switch (name) {
|
|
996
|
+
case "ibmcloud_resource_groups":
|
|
997
|
+
return formatResult(await executeIBMCloud(["resource", "groups"]));
|
|
998
|
+
case "ibmcloud_resource_group_create":
|
|
999
|
+
return formatResult(await executeIBMCloud(["resource", "group-create", args.name as string]));
|
|
1000
|
+
case "ibmcloud_resource_service_instances": {
|
|
1001
|
+
const cmdArgs = ["resource", "service-instances"];
|
|
1002
|
+
if (args.service_name) cmdArgs.push("--service-name", args.service_name as string);
|
|
1003
|
+
if (args.resource_group) cmdArgs.push("-g", args.resource_group as string);
|
|
1004
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1005
|
+
}
|
|
1006
|
+
case "ibmcloud_resource_service_instance":
|
|
1007
|
+
return formatResult(await executeIBMCloud(["resource", "service-instance", args.name as string]));
|
|
1008
|
+
case "ibmcloud_resource_service_instance_create": {
|
|
1009
|
+
const cmdArgs = ["resource", "service-instance-create", args.name as string, args.service as string, args.plan as string];
|
|
1010
|
+
if (args.location) cmdArgs.push("-l", args.location as string);
|
|
1011
|
+
if (args.resource_group) cmdArgs.push("-g", args.resource_group as string);
|
|
1012
|
+
if (args.parameters) cmdArgs.push("-p", args.parameters as string);
|
|
1013
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1014
|
+
}
|
|
1015
|
+
case "ibmcloud_resource_service_instance_delete": {
|
|
1016
|
+
const cmdArgs = ["resource", "service-instance-delete", args.name as string];
|
|
1017
|
+
if (args.force) cmdArgs.push("-f");
|
|
1018
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1019
|
+
}
|
|
1020
|
+
case "ibmcloud_resource_service_instance_update": {
|
|
1021
|
+
const cmdArgs = ["resource", "service-instance-update", args.name as string];
|
|
1022
|
+
if (args.new_name) cmdArgs.push("-n", args.new_name as string);
|
|
1023
|
+
if (args.plan) cmdArgs.push("--service-plan-id", args.plan as string);
|
|
1024
|
+
if (args.parameters) cmdArgs.push("-p", args.parameters as string);
|
|
1025
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1026
|
+
}
|
|
1027
|
+
case "ibmcloud_resource_service_keys": {
|
|
1028
|
+
const cmdArgs = ["resource", "service-keys"];
|
|
1029
|
+
if (args.instance) cmdArgs.push("--instance-name", args.instance as string);
|
|
1030
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1031
|
+
}
|
|
1032
|
+
case "ibmcloud_resource_service_key":
|
|
1033
|
+
return formatResult(await executeIBMCloud(["resource", "service-key", args.name as string]));
|
|
1034
|
+
case "ibmcloud_resource_service_key_create": {
|
|
1035
|
+
const cmdArgs = ["resource", "service-key-create", args.name as string, "--instance-name", args.instance as string];
|
|
1036
|
+
if (args.role) cmdArgs.push("--service-endpoint", args.role as string);
|
|
1037
|
+
if (args.parameters) cmdArgs.push("-p", args.parameters as string);
|
|
1038
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1039
|
+
}
|
|
1040
|
+
case "ibmcloud_resource_service_key_delete": {
|
|
1041
|
+
const cmdArgs = ["resource", "service-key-delete", args.name as string];
|
|
1042
|
+
if (args.force) cmdArgs.push("-f");
|
|
1043
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1044
|
+
}
|
|
1045
|
+
case "ibmcloud_resource_search":
|
|
1046
|
+
return formatResult(await executeIBMCloud(["resource", "search", args.query as string]));
|
|
1047
|
+
case "ibmcloud_resource_tags": {
|
|
1048
|
+
const cmdArgs = ["resource", "tags"];
|
|
1049
|
+
if (args.resource_id) cmdArgs.push("--tag-type", "user");
|
|
1050
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1051
|
+
}
|
|
1052
|
+
case "ibmcloud_resource_tag_attach":
|
|
1053
|
+
return formatResult(await executeIBMCloud(["resource", "tag-attach", "--tag-names", args.tags as string, "--resource-id", args.resource_id as string]));
|
|
1054
|
+
default:
|
|
1055
|
+
throw new Error(`Unknown resource tool: ${name}`);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
async function handleCFTool(name: string, args: Record<string, unknown>): Promise<string> {
|
|
1060
|
+
switch (name) {
|
|
1061
|
+
case "ibmcloud_cf_orgs":
|
|
1062
|
+
return formatResult(await executeIBMCloud(["cf", "orgs"]));
|
|
1063
|
+
case "ibmcloud_cf_spaces": {
|
|
1064
|
+
const cmdArgs = ["cf", "spaces"];
|
|
1065
|
+
if (args.org) cmdArgs.push("-o", args.org as string);
|
|
1066
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1067
|
+
}
|
|
1068
|
+
case "ibmcloud_cf_apps":
|
|
1069
|
+
return formatResult(await executeIBMCloud(["cf", "apps"]));
|
|
1070
|
+
case "ibmcloud_cf_app":
|
|
1071
|
+
return formatResult(await executeIBMCloud(["cf", "app", args.name as string]));
|
|
1072
|
+
case "ibmcloud_cf_push": {
|
|
1073
|
+
const cmdArgs = ["cf", "push"];
|
|
1074
|
+
if (args.name) cmdArgs.push(args.name as string);
|
|
1075
|
+
if (args.path) cmdArgs.push("-p", args.path as string);
|
|
1076
|
+
if (args.manifest) cmdArgs.push("-f", args.manifest as string);
|
|
1077
|
+
if (args.memory) cmdArgs.push("-m", args.memory as string);
|
|
1078
|
+
if (args.instances) cmdArgs.push("-i", String(args.instances));
|
|
1079
|
+
if (args.buildpack) cmdArgs.push("-b", args.buildpack as string);
|
|
1080
|
+
if (args.docker_image) cmdArgs.push("--docker-image", args.docker_image as string);
|
|
1081
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1082
|
+
}
|
|
1083
|
+
case "ibmcloud_cf_start":
|
|
1084
|
+
return formatResult(await executeIBMCloud(["cf", "start", args.name as string]));
|
|
1085
|
+
case "ibmcloud_cf_stop":
|
|
1086
|
+
return formatResult(await executeIBMCloud(["cf", "stop", args.name as string]));
|
|
1087
|
+
case "ibmcloud_cf_restart":
|
|
1088
|
+
return formatResult(await executeIBMCloud(["cf", "restart", args.name as string]));
|
|
1089
|
+
case "ibmcloud_cf_delete": {
|
|
1090
|
+
const cmdArgs = ["cf", "delete", args.name as string];
|
|
1091
|
+
if (args.force) cmdArgs.push("-f");
|
|
1092
|
+
if (args.delete_routes) cmdArgs.push("-r");
|
|
1093
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1094
|
+
}
|
|
1095
|
+
case "ibmcloud_cf_logs": {
|
|
1096
|
+
const cmdArgs = ["cf", "logs", args.name as string];
|
|
1097
|
+
if (args.recent !== false) cmdArgs.push("--recent");
|
|
1098
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1099
|
+
}
|
|
1100
|
+
case "ibmcloud_cf_env":
|
|
1101
|
+
return formatResult(await executeIBMCloud(["cf", "env", args.name as string]));
|
|
1102
|
+
case "ibmcloud_cf_set_env":
|
|
1103
|
+
return formatResult(await executeIBMCloud(["cf", "set-env", args.name as string, args.var_name as string, args.var_value as string]));
|
|
1104
|
+
case "ibmcloud_cf_scale": {
|
|
1105
|
+
const cmdArgs = ["cf", "scale", args.name as string];
|
|
1106
|
+
if (args.instances) cmdArgs.push("-i", String(args.instances));
|
|
1107
|
+
if (args.memory) cmdArgs.push("-m", args.memory as string);
|
|
1108
|
+
if (args.disk) cmdArgs.push("-k", args.disk as string);
|
|
1109
|
+
cmdArgs.push("-f");
|
|
1110
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1111
|
+
}
|
|
1112
|
+
case "ibmcloud_cf_routes":
|
|
1113
|
+
return formatResult(await executeIBMCloud(["cf", "routes"]));
|
|
1114
|
+
case "ibmcloud_cf_services":
|
|
1115
|
+
return formatResult(await executeIBMCloud(["cf", "services"]));
|
|
1116
|
+
case "ibmcloud_cf_marketplace": {
|
|
1117
|
+
const cmdArgs = ["cf", "marketplace"];
|
|
1118
|
+
if (args.service) cmdArgs.push("-e", args.service as string);
|
|
1119
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1120
|
+
}
|
|
1121
|
+
case "ibmcloud_cf_create_service": {
|
|
1122
|
+
const cmdArgs = ["cf", "create-service", args.service as string, args.plan as string, args.instance_name as string];
|
|
1123
|
+
if (args.parameters) cmdArgs.push("-c", args.parameters as string);
|
|
1124
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1125
|
+
}
|
|
1126
|
+
case "ibmcloud_cf_bind_service": {
|
|
1127
|
+
const cmdArgs = ["cf", "bind-service", args.app_name as string, args.service_instance as string];
|
|
1128
|
+
if (args.parameters) cmdArgs.push("-c", args.parameters as string);
|
|
1129
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1130
|
+
}
|
|
1131
|
+
case "ibmcloud_cf_unbind_service":
|
|
1132
|
+
return formatResult(await executeIBMCloud(["cf", "unbind-service", args.app_name as string, args.service_instance as string]));
|
|
1133
|
+
default:
|
|
1134
|
+
throw new Error(`Unknown CF tool: ${name}`);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
async function handleKSTool(name: string, args: Record<string, unknown>): Promise<string> {
|
|
1139
|
+
switch (name) {
|
|
1140
|
+
case "ibmcloud_ks_clusters": {
|
|
1141
|
+
const cmdArgs = ["ks", "clusters"];
|
|
1142
|
+
if (args.provider) cmdArgs.push("--provider", args.provider as string);
|
|
1143
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1144
|
+
}
|
|
1145
|
+
case "ibmcloud_ks_cluster":
|
|
1146
|
+
return formatResult(await executeIBMCloud(["ks", "cluster", "get", "--cluster", args.cluster as string]));
|
|
1147
|
+
case "ibmcloud_ks_cluster_config": {
|
|
1148
|
+
const cmdArgs = ["ks", "cluster", "config", "--cluster", args.cluster as string];
|
|
1149
|
+
if (args.admin) cmdArgs.push("--admin");
|
|
1150
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1151
|
+
}
|
|
1152
|
+
case "ibmcloud_ks_cluster_create": {
|
|
1153
|
+
const cmdArgs = ["ks", "cluster", "create", "classic", "--name", args.name as string, "--zone", args.zone as string];
|
|
1154
|
+
if (args.flavor) cmdArgs.push("--flavor", args.flavor as string);
|
|
1155
|
+
if (args.workers) cmdArgs.push("--workers", String(args.workers));
|
|
1156
|
+
if (args.version) cmdArgs.push("--version", args.version as string);
|
|
1157
|
+
if (args.vpc_id) {
|
|
1158
|
+
cmdArgs[4] = "vpc-gen2";
|
|
1159
|
+
cmdArgs.push("--vpc-id", args.vpc_id as string);
|
|
1160
|
+
}
|
|
1161
|
+
if (args.subnet_id) cmdArgs.push("--subnet-id", args.subnet_id as string);
|
|
1162
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1163
|
+
}
|
|
1164
|
+
case "ibmcloud_ks_cluster_delete": {
|
|
1165
|
+
const cmdArgs = ["ks", "cluster", "rm", "--cluster", args.cluster as string];
|
|
1166
|
+
if (args.force) cmdArgs.push("-f");
|
|
1167
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1168
|
+
}
|
|
1169
|
+
case "ibmcloud_ks_workers":
|
|
1170
|
+
return formatResult(await executeIBMCloud(["ks", "workers", "--cluster", args.cluster as string]));
|
|
1171
|
+
case "ibmcloud_ks_worker_pools":
|
|
1172
|
+
return formatResult(await executeIBMCloud(["ks", "worker-pools", "--cluster", args.cluster as string]));
|
|
1173
|
+
case "ibmcloud_ks_worker_pool_create": {
|
|
1174
|
+
const cmdArgs = ["ks", "worker-pool", "create", "classic", "--cluster", args.cluster as string, "--name", args.name as string, "--flavor", args.flavor as string];
|
|
1175
|
+
if (args.size_per_zone) cmdArgs.push("--size-per-zone", String(args.size_per_zone));
|
|
1176
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1177
|
+
}
|
|
1178
|
+
case "ibmcloud_ks_worker_pool_resize":
|
|
1179
|
+
return formatResult(await executeIBMCloud(["ks", "worker-pool", "resize", "--cluster", args.cluster as string, "--worker-pool", args.pool as string, "--size-per-zone", String(args.size_per_zone)]));
|
|
1180
|
+
case "ibmcloud_ks_zones": {
|
|
1181
|
+
const cmdArgs = ["ks", "zones"];
|
|
1182
|
+
if (args.provider) cmdArgs.push("--provider", args.provider as string);
|
|
1183
|
+
if (args.location) cmdArgs.push("--location", args.location as string);
|
|
1184
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1185
|
+
}
|
|
1186
|
+
case "ibmcloud_ks_versions":
|
|
1187
|
+
return formatResult(await executeIBMCloud(["ks", "versions"]));
|
|
1188
|
+
case "ibmcloud_ks_flavors": {
|
|
1189
|
+
const cmdArgs = ["ks", "flavors", "--zone", args.zone as string];
|
|
1190
|
+
if (args.provider) cmdArgs.push("--provider", args.provider as string);
|
|
1191
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1192
|
+
}
|
|
1193
|
+
case "ibmcloud_cr_namespaces":
|
|
1194
|
+
return formatResult(await executeIBMCloud(["cr", "namespaces"]));
|
|
1195
|
+
case "ibmcloud_cr_namespace_add": {
|
|
1196
|
+
const cmdArgs = ["cr", "namespace-add", args.name as string];
|
|
1197
|
+
if (args.resource_group) cmdArgs.push("-g", args.resource_group as string);
|
|
1198
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1199
|
+
}
|
|
1200
|
+
case "ibmcloud_cr_images": {
|
|
1201
|
+
const cmdArgs = ["cr", "images"];
|
|
1202
|
+
if (args.repository) cmdArgs.push("--repository", args.repository as string);
|
|
1203
|
+
if (args.include_ibm) cmdArgs.push("--include-ibm");
|
|
1204
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1205
|
+
}
|
|
1206
|
+
case "ibmcloud_cr_image_rm": {
|
|
1207
|
+
const cmdArgs = ["cr", "image-rm", args.image as string];
|
|
1208
|
+
if (args.force) cmdArgs.push("-f");
|
|
1209
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1210
|
+
}
|
|
1211
|
+
case "ibmcloud_cr_quota":
|
|
1212
|
+
return formatResult(await executeIBMCloud(["cr", "quota"]));
|
|
1213
|
+
default:
|
|
1214
|
+
throw new Error(`Unknown KS tool: ${name}`);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
async function handleIAMTool(name: string, args: Record<string, unknown>): Promise<string> {
|
|
1219
|
+
switch (name) {
|
|
1220
|
+
case "ibmcloud_iam_users":
|
|
1221
|
+
return formatResult(await executeIBMCloud(["iam", "users"]));
|
|
1222
|
+
case "ibmcloud_iam_user_invite": {
|
|
1223
|
+
const cmdArgs = ["iam", "user-invite", args.email as string];
|
|
1224
|
+
if (args.access_groups) cmdArgs.push("--access-groups", args.access_groups as string);
|
|
1225
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1226
|
+
}
|
|
1227
|
+
case "ibmcloud_iam_api_keys":
|
|
1228
|
+
return formatResult(await executeIBMCloud(["iam", "api-keys"]));
|
|
1229
|
+
case "ibmcloud_iam_api_key_create": {
|
|
1230
|
+
const cmdArgs = ["iam", "api-key-create", args.name as string];
|
|
1231
|
+
if (args.description) cmdArgs.push("-d", args.description as string);
|
|
1232
|
+
if (args.file) cmdArgs.push("--file", args.file as string);
|
|
1233
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1234
|
+
}
|
|
1235
|
+
case "ibmcloud_iam_api_key_delete": {
|
|
1236
|
+
const cmdArgs = ["iam", "api-key-delete", args.name as string];
|
|
1237
|
+
if (args.force) cmdArgs.push("-f");
|
|
1238
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1239
|
+
}
|
|
1240
|
+
case "ibmcloud_iam_service_ids":
|
|
1241
|
+
return formatResult(await executeIBMCloud(["iam", "service-ids"]));
|
|
1242
|
+
case "ibmcloud_iam_service_id":
|
|
1243
|
+
return formatResult(await executeIBMCloud(["iam", "service-id", args.name as string]));
|
|
1244
|
+
case "ibmcloud_iam_service_id_create": {
|
|
1245
|
+
const cmdArgs = ["iam", "service-id-create", args.name as string];
|
|
1246
|
+
if (args.description) cmdArgs.push("-d", args.description as string);
|
|
1247
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1248
|
+
}
|
|
1249
|
+
case "ibmcloud_iam_service_id_delete": {
|
|
1250
|
+
const cmdArgs = ["iam", "service-id-delete", args.name as string];
|
|
1251
|
+
if (args.force) cmdArgs.push("-f");
|
|
1252
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1253
|
+
}
|
|
1254
|
+
case "ibmcloud_iam_service_api_keys":
|
|
1255
|
+
return formatResult(await executeIBMCloud(["iam", "service-api-keys", args.service_id as string]));
|
|
1256
|
+
case "ibmcloud_iam_service_api_key_create": {
|
|
1257
|
+
const cmdArgs = ["iam", "service-api-key-create", args.name as string, args.service_id as string];
|
|
1258
|
+
if (args.description) cmdArgs.push("-d", args.description as string);
|
|
1259
|
+
if (args.file) cmdArgs.push("--file", args.file as string);
|
|
1260
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1261
|
+
}
|
|
1262
|
+
case "ibmcloud_iam_access_groups":
|
|
1263
|
+
return formatResult(await executeIBMCloud(["iam", "access-groups"]));
|
|
1264
|
+
case "ibmcloud_iam_access_group":
|
|
1265
|
+
return formatResult(await executeIBMCloud(["iam", "access-group", args.name as string]));
|
|
1266
|
+
case "ibmcloud_iam_access_group_create": {
|
|
1267
|
+
const cmdArgs = ["iam", "access-group-create", args.name as string];
|
|
1268
|
+
if (args.description) cmdArgs.push("-d", args.description as string);
|
|
1269
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1270
|
+
}
|
|
1271
|
+
case "ibmcloud_iam_access_group_users":
|
|
1272
|
+
return formatResult(await executeIBMCloud(["iam", "access-group-users", args.group as string]));
|
|
1273
|
+
case "ibmcloud_iam_access_group_user_add":
|
|
1274
|
+
return formatResult(await executeIBMCloud(["iam", "access-group-user-add", args.group as string, "--users", args.users as string]));
|
|
1275
|
+
case "ibmcloud_iam_access_group_policies":
|
|
1276
|
+
return formatResult(await executeIBMCloud(["iam", "access-group-policies", args.group as string]));
|
|
1277
|
+
case "ibmcloud_iam_access_group_policy_create": {
|
|
1278
|
+
const cmdArgs = ["iam", "access-group-policy-create", args.group as string, "--roles", args.roles as string];
|
|
1279
|
+
if (args.service_name) cmdArgs.push("--service-name", args.service_name as string);
|
|
1280
|
+
if (args.resource_group) cmdArgs.push("--resource-group-name", args.resource_group as string);
|
|
1281
|
+
if (args.resource_type) cmdArgs.push("--resource-type", args.resource_type as string);
|
|
1282
|
+
if (args.resource) cmdArgs.push("--resource", args.resource as string);
|
|
1283
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1284
|
+
}
|
|
1285
|
+
case "ibmcloud_iam_roles": {
|
|
1286
|
+
const cmdArgs = ["iam", "roles"];
|
|
1287
|
+
if (args.service) cmdArgs.push("--service", args.service as string);
|
|
1288
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1289
|
+
}
|
|
1290
|
+
default:
|
|
1291
|
+
throw new Error(`Unknown IAM tool: ${name}`);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
async function handleCatalogBillingTool(name: string, args: Record<string, unknown>): Promise<string> {
|
|
1296
|
+
switch (name) {
|
|
1297
|
+
case "ibmcloud_catalog_search":
|
|
1298
|
+
return formatResult(await executeIBMCloud(["catalog", "search", args.query as string]));
|
|
1299
|
+
case "ibmcloud_catalog_service":
|
|
1300
|
+
return formatResult(await executeIBMCloud(["catalog", "service", args.service as string]));
|
|
1301
|
+
case "ibmcloud_catalog_service_plans":
|
|
1302
|
+
return formatResult(await executeIBMCloud(["catalog", "service", args.service as string]));
|
|
1303
|
+
case "ibmcloud_billing_account_usage": {
|
|
1304
|
+
const cmdArgs = ["billing", "account-usage"];
|
|
1305
|
+
if (args.month) cmdArgs.push("-d", args.month as string);
|
|
1306
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1307
|
+
}
|
|
1308
|
+
case "ibmcloud_billing_resource_group_usage": {
|
|
1309
|
+
const cmdArgs = ["billing", "resource-group-usage", args.resource_group as string];
|
|
1310
|
+
if (args.month) cmdArgs.push("-d", args.month as string);
|
|
1311
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1312
|
+
}
|
|
1313
|
+
case "ibmcloud_billing_resource_instances_usage": {
|
|
1314
|
+
const cmdArgs = ["billing", "resource-instances-usage"];
|
|
1315
|
+
if (args.month) cmdArgs.push("-d", args.month as string);
|
|
1316
|
+
if (args.resource_group) cmdArgs.push("-g", args.resource_group as string);
|
|
1317
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1318
|
+
}
|
|
1319
|
+
case "ibmcloud_billing_org_usage": {
|
|
1320
|
+
const cmdArgs = ["billing", "org-usage", args.org as string];
|
|
1321
|
+
if (args.month) cmdArgs.push("-d", args.month as string);
|
|
1322
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1323
|
+
}
|
|
1324
|
+
case "ibmcloud_plugin_list":
|
|
1325
|
+
return formatResult(await executeIBMCloud(["plugin", "list"]));
|
|
1326
|
+
case "ibmcloud_plugin_repo_plugins":
|
|
1327
|
+
return formatResult(await executeIBMCloud(["plugin", "repo-plugins"]));
|
|
1328
|
+
case "ibmcloud_plugin_install": {
|
|
1329
|
+
const cmdArgs = ["plugin", "install", args.plugin as string];
|
|
1330
|
+
if (args.force) cmdArgs.push("-f");
|
|
1331
|
+
return formatResult(await executeIBMCloud(cmdArgs));
|
|
1332
|
+
}
|
|
1333
|
+
case "ibmcloud_version":
|
|
1334
|
+
return formatResult(await executeIBMCloud(["version"]));
|
|
1335
|
+
default:
|
|
1336
|
+
throw new Error(`Unknown catalog/billing tool: ${name}`);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
// Main server setup
|
|
1341
|
+
const server = new Server(
|
|
1342
|
+
{
|
|
1343
|
+
name: "ibmcloud-mcp",
|
|
1344
|
+
version: "1.0.0",
|
|
1345
|
+
},
|
|
1346
|
+
{
|
|
1347
|
+
capabilities: {
|
|
1348
|
+
tools: {},
|
|
1349
|
+
},
|
|
1350
|
+
}
|
|
1351
|
+
);
|
|
1352
|
+
|
|
1353
|
+
// Register tool list handler
|
|
1354
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
1355
|
+
tools: allTools,
|
|
1356
|
+
}));
|
|
1357
|
+
|
|
1358
|
+
// Register tool call handler
|
|
1359
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
1360
|
+
const { name, arguments: args } = request.params;
|
|
1361
|
+
const typedArgs = (args ?? {}) as Record<string, unknown>;
|
|
1362
|
+
|
|
1363
|
+
try {
|
|
1364
|
+
let result: string;
|
|
1365
|
+
|
|
1366
|
+
if (authTools.find((t) => t.name === name)) {
|
|
1367
|
+
result = await handleAuthTool(name, typedArgs);
|
|
1368
|
+
} else if (resourceTools.find((t) => t.name === name)) {
|
|
1369
|
+
result = await handleResourceTool(name, typedArgs);
|
|
1370
|
+
} else if (cfTools.find((t) => t.name === name)) {
|
|
1371
|
+
result = await handleCFTool(name, typedArgs);
|
|
1372
|
+
} else if (ksTools.find((t) => t.name === name)) {
|
|
1373
|
+
result = await handleKSTool(name, typedArgs);
|
|
1374
|
+
} else if (iamTools.find((t) => t.name === name)) {
|
|
1375
|
+
result = await handleIAMTool(name, typedArgs);
|
|
1376
|
+
} else if (catalogBillingTools.find((t) => t.name === name)) {
|
|
1377
|
+
result = await handleCatalogBillingTool(name, typedArgs);
|
|
1378
|
+
} else {
|
|
1379
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
return {
|
|
1383
|
+
content: [{ type: "text", text: result }],
|
|
1384
|
+
};
|
|
1385
|
+
} catch (error) {
|
|
1386
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1387
|
+
return {
|
|
1388
|
+
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
1389
|
+
isError: true,
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
|
|
1394
|
+
// Start server
|
|
1395
|
+
async function main() {
|
|
1396
|
+
const transport = new StdioServerTransport();
|
|
1397
|
+
await server.connect(transport);
|
|
1398
|
+
console.error("IBM Cloud MCP Server running on stdio");
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
main().catch(console.error);
|