mcp-server-ecs-lifecycle 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,4 @@
1
+ # Copyright (c) 2026 Huawei Technologies Co., Ltd.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """ecs-lifecycle MCP Server package."""
File without changes
@@ -0,0 +1,571 @@
1
+ # Copyright (c) 2026 Huawei Technologies Co., Ltd.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Thin SDK wrapper for ECS lifecycle plus read-only IMS/VPC discovery calls.
5
+
6
+ No business logic here: every method maps one API call to plain JSON data.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import os
12
+ from typing import Any
13
+
14
+ from huaweicloud_mcp_core.config import McpSettings
15
+ from huaweicloud_mcp_core.credentials import CredentialScope, build_credentials
16
+
17
+ from mcp_server_ecs_common import call_sdk, paginate, sdk_to_dict
18
+
19
+
20
+ class EcsLifecycleClient:
21
+ """Async wrapper around the synchronous Huawei Cloud SDK clients.
22
+
23
+ The primary service is ECS; IMS (images) and VPC (subnets) are secondary
24
+ clients built lazily from the same credentials. Endpoint derivation: an
25
+ explicit ``ecs.*`` host swaps its first DNS label per service; any other
26
+ explicit host (gateway style) is reused verbatim; without an endpoint each
27
+ service synthesizes ``https://<service>.<region>.myhuaweicloud.com``.
28
+ """
29
+
30
+ MAX_PAGE_SIZE = 1000
31
+ _IMAGE_PAGE_SIZE = 100
32
+ _MAX_IMAGE_PAGES = 30
33
+ _MAX_FLAVOR_PAGES = 10
34
+ _MAX_SUBNET_PAGES = 10
35
+
36
+ def __init__(
37
+ self,
38
+ settings: McpSettings | None = None,
39
+ sdk_client: Any = None,
40
+ ) -> None:
41
+ self._settings = settings or McpSettings.from_env()
42
+ self._sdk_client = sdk_client
43
+ self._service_clients: dict[str, Any] = {}
44
+ endpoint = self._settings.endpoint
45
+ if endpoint and not endpoint.startswith(("http://", "https://")):
46
+ endpoint = f"https://{endpoint}"
47
+ self._endpoint = endpoint
48
+ # Internal test regions (e.g. cn-southwest-242) present a self-signed
49
+ # certificate over the VPN tunnel. Only skip TLS validation when the
50
+ # operator explicitly lists this region; off by default and never applied
51
+ # to unlisted regions, so public regions stay strictly verified. Applies
52
+ # to every service client (ecs/ims/vpc) built below.
53
+ self._skip_ssl_verify_regions = {
54
+ r.strip()
55
+ for r in os.getenv("HUAWEICLOUD_MCP_SKIP_SSL_VERIFY_REGIONS", "").split(",")
56
+ if r.strip()
57
+ }
58
+ if sdk_client is not None:
59
+ # Test seam: every service routes to the injected stub, so no real
60
+ # SDK client (and no IAM round trip for credentials) is constructed.
61
+ self._credentials = None
62
+ else:
63
+ # Built once: resolving the project id can hit IAM, and building a
64
+ # client per service must not repeat that round trip.
65
+ self._credentials = build_credentials(CredentialScope.PROJECT, self._settings)
66
+ self._client = self._service_client("ecs")
67
+
68
+ def _service_client(self, service: str) -> Any:
69
+ if self._sdk_client is not None:
70
+ return self._sdk_client
71
+ if service not in self._service_clients:
72
+ self._service_clients[service] = self._build_service_client(service)
73
+ return self._service_clients[service]
74
+
75
+ def _build_service_client(self, service: str) -> Any:
76
+ from huaweicloudsdkcore.region.region import Region
77
+
78
+ if service == "ecs":
79
+ from huaweicloudsdkecs.v2 import EcsClient as client_cls
80
+ from huaweicloudsdkecs.v2.region.ecs_region import EcsRegion as region_cls
81
+ elif service == "ims":
82
+ from huaweicloudsdkims.v2 import ImsClient as client_cls
83
+ from huaweicloudsdkims.v2.region.ims_region import ImsRegion as region_cls
84
+ elif service == "vpc":
85
+ from huaweicloudsdkvpc.v2 import VpcClient as client_cls
86
+ from huaweicloudsdkvpc.v2.region.vpc_region import VpcRegion as region_cls
87
+ else:
88
+ raise ValueError(f"Unsupported service: {service}")
89
+
90
+ region_id = self._settings.region
91
+ if self._endpoint:
92
+ # Explicit endpoint override wins over the SDK's static region map.
93
+ sdk_region = Region(region_id, self._service_endpoint(service))
94
+ else:
95
+ try:
96
+ sdk_region = region_cls.value_of(region_id)
97
+ except KeyError:
98
+ # Internal/beta regions are absent from the SDK's static map; every
99
+ # map entry follows https://<service>.<region>.myhuaweicloud.com, so
100
+ # synthesize on that pattern instead of failing at construction.
101
+ sdk_region = Region(region_id, self._service_endpoint(service))
102
+ from huaweicloudsdkcore.http.http_config import HttpConfig
103
+
104
+ http_config = HttpConfig.get_default_config()
105
+ if region_id in self._skip_ssl_verify_regions:
106
+ http_config.ignore_ssl_verification = True
107
+ return (
108
+ client_cls.new_builder()
109
+ .with_credentials(self._credentials)
110
+ .with_region(sdk_region)
111
+ .with_http_config(http_config)
112
+ .build()
113
+ )
114
+
115
+ def _service_endpoint(self, service: str) -> str:
116
+ """Derive one service's endpoint from the configured endpoint."""
117
+ if not self._endpoint:
118
+ return f"https://{service}.{self._settings.region}.myhuaweicloud.com"
119
+ scheme, _, host = self._endpoint.partition("//")
120
+ first, _, rest = host.partition(".")
121
+ if first == "ecs" and rest:
122
+ return f"{scheme}//{service}.{rest}"
123
+ # Gateway-style override: all services share the same host.
124
+ return self._endpoint
125
+
126
+ # ------------------------------------------------------------------ servers
127
+
128
+ async def list_all_servers(self) -> list[dict[str, Any]]:
129
+ """Fetch every server in the region by paging through list-servers-details."""
130
+
131
+ def _call() -> list[dict[str, Any]]:
132
+ from huaweicloudsdkecs.v2.model.list_servers_details_request import (
133
+ ListServersDetailsRequest,
134
+ )
135
+
136
+ offset = 1
137
+
138
+ def fetch() -> Any:
139
+ nonlocal offset
140
+ request = ListServersDetailsRequest(limit=self.MAX_PAGE_SIZE, offset=offset)
141
+ # Let SDK/transport exceptions surface raw to call_sdk so its retry
142
+ # layer sees ServiceResponseException(429/5xx) and transport blips —
143
+ # wrap_sdk_error in the client would pre-wrap them as McpToolError
144
+ # and defeat the retry (it only re-wraps at the call_sdk boundary).
145
+ response = self._client.list_servers_details(request)
146
+ return response
147
+
148
+ def advance(_batch: list[dict[str, Any]], _page: dict[str, Any]) -> str | None:
149
+ nonlocal offset
150
+ offset += 1
151
+ # offset-style paging: return the next offset as the sentinel so the
152
+ # dedupe guard sees a fresh value each page; the loop stops on an
153
+ # empty/short page in paginate itself.
154
+ return str(offset)
155
+
156
+ return paginate(
157
+ fetch,
158
+ result_key="servers",
159
+ page_size=self.MAX_PAGE_SIZE,
160
+ advance=advance,
161
+ )
162
+
163
+ return await call_sdk(_call)
164
+
165
+ async def show_server(self, server_id: str) -> dict[str, Any]:
166
+ """Fetch a single server detail."""
167
+
168
+ def _call() -> dict[str, Any]:
169
+ from huaweicloudsdkecs.v2.model.show_server_request import ShowServerRequest
170
+
171
+ request = ShowServerRequest(server_id=server_id)
172
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
173
+ response = self._client.show_server(request)
174
+ return sdk_to_dict(response) or {}
175
+
176
+ return await call_sdk(_call)
177
+
178
+ # ---------------------------------------------------------------- discovery
179
+
180
+ async def list_images(self) -> list[dict[str, Any]]:
181
+ """Fetch all images (public + private) by paging the IMS list-images API.
182
+
183
+ Unlike list_flavors/list_subnets (which page via the shared ``paginate``
184
+ helper, where each page is its own ``call_sdk`` and its own semaphore
185
+ slot), this method's ``_call`` does the whole paging loop inside one
186
+ ``call_sdk`` — so one ``list_images`` call holds a single slot for all
187
+ its pages, not one per page. That is fine in practice (the catalog is a
188
+ few pages), but it means ``MAX_CONCURRENT`` bounds *tool calls* here,
189
+ not *API requests*; a small cap with a large catalog could serialize
190
+ this call behind fewer concurrent tool calls than the cap suggests.
191
+ """
192
+
193
+ def _call() -> list[dict[str, Any]]:
194
+ from huaweicloudsdkims.v2.model.list_images_request import ListImagesRequest
195
+
196
+ images: list[dict[str, Any]] = []
197
+ marker: str | None = None
198
+ for _ in range(self._MAX_IMAGE_PAGES):
199
+ request = ListImagesRequest(limit=self._IMAGE_PAGE_SIZE)
200
+ if marker:
201
+ request.marker = marker
202
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
203
+ response = self._service_client("ims").list_images(request)
204
+ page = sdk_to_dict(response) or {}
205
+ batch = page.get("images") or []
206
+ images.extend(batch)
207
+ marker = (page.get("page_info") or {}).get("next_marker")
208
+ if not batch or not marker:
209
+ break
210
+ return images
211
+
212
+ return await call_sdk(_call)
213
+
214
+ async def list_flavors(self, flavor_id: str | None = None) -> list[dict[str, Any]]:
215
+ """Fetch the flavor catalog paging by marker; flavor_id does an exact lookup.
216
+
217
+ The API caps one page at 1000 flavors, so a large catalog loses its
218
+ alphabetical tail unless paged — the tail is where flavors like
219
+ ``x1.*`` live, which existing servers may still use.
220
+ """
221
+
222
+ def _call() -> list[dict[str, Any]]:
223
+ from huaweicloudsdkecs.v2.model.list_flavors_request import ListFlavorsRequest
224
+
225
+ marker: str | None = None
226
+
227
+ def fetch() -> Any:
228
+ nonlocal marker
229
+ request = ListFlavorsRequest(limit=self.MAX_PAGE_SIZE)
230
+ if flavor_id:
231
+ request.flavor_id = flavor_id
232
+ if marker:
233
+ request.marker = marker
234
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
235
+ response = self._client.list_flavors(request)
236
+ return response
237
+
238
+ def advance(batch: list[dict[str, Any]], _page: dict[str, Any]) -> str | None:
239
+ # ECS list-flavors pages by the last item's id (no page_info.next_marker);
240
+ # the next fetch() reads this via the nonlocal marker.
241
+ nonlocal marker
242
+ marker = str(batch[-1].get("id") or "")
243
+ return marker or None
244
+
245
+ return paginate(
246
+ fetch,
247
+ result_key="flavors",
248
+ page_size=self.MAX_PAGE_SIZE,
249
+ max_pages=self._MAX_FLAVOR_PAGES,
250
+ advance=advance,
251
+ )
252
+
253
+ return await call_sdk(_call)
254
+
255
+ async def list_keypairs(self) -> list[dict[str, Any]]:
256
+ """List SSH key pairs via the Nova keypairs API.
257
+
258
+ nova_list_keypairs is deprecated upstream but remains the only list
259
+ endpoint the SDK exposes; the nested [{keypair: {...}}] shape is kept
260
+ for the service layer to flatten.
261
+ """
262
+
263
+ def _call() -> list[dict[str, Any]]:
264
+ from huaweicloudsdkecs.v2.model.nova_list_keypairs_request import (
265
+ NovaListKeypairsRequest,
266
+ )
267
+
268
+ request = NovaListKeypairsRequest()
269
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
270
+ response = self._client.nova_list_keypairs(request)
271
+ page = sdk_to_dict(response) or {}
272
+ return page.get("keypairs") or []
273
+
274
+ return await call_sdk(_call)
275
+
276
+ async def list_subnets(self) -> list[dict[str, Any]]:
277
+ """Fetch all subnets in the region (internal default-resolution helper)."""
278
+
279
+ def _call() -> list[dict[str, Any]]:
280
+ from huaweicloudsdkvpc.v2.model.list_subnets_request import ListSubnetsRequest
281
+
282
+ marker: str | None = None
283
+
284
+ def fetch() -> Any:
285
+ nonlocal marker
286
+ request = ListSubnetsRequest(limit=self.MAX_PAGE_SIZE)
287
+ if marker:
288
+ request.marker = marker
289
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
290
+ response = self._service_client("vpc").list_subnets(request)
291
+ return response
292
+
293
+ def advance(batch: list[dict[str, Any]], _page: dict[str, Any]) -> str | None:
294
+ # VPC list-subnets pages by the last item's id (no page_info.next_marker);
295
+ # the next fetch() reads this via the nonlocal marker.
296
+ nonlocal marker
297
+ marker = str(batch[-1].get("id") or "")
298
+ return marker or None
299
+
300
+ return paginate(
301
+ fetch,
302
+ result_key="subnets",
303
+ page_size=self.MAX_PAGE_SIZE,
304
+ max_pages=self._MAX_SUBNET_PAGES,
305
+ advance=advance,
306
+ )
307
+
308
+ return await call_sdk(_call)
309
+
310
+ # ------------------------------------------------------------- changing ops
311
+
312
+ async def create_pre_paid_server(
313
+ self,
314
+ *,
315
+ name: str,
316
+ flavor_ref: str,
317
+ image_ref: str,
318
+ vpc_id: str,
319
+ subnet_id: str,
320
+ root_volume_type: str,
321
+ root_volume_size: int | None = None,
322
+ admin_pass: str | None = None,
323
+ key_name: str | None = None,
324
+ count: int = 1,
325
+ availability_zone: str | None = None,
326
+ description: str | None = None,
327
+ user_data: str | None = None,
328
+ security_group_id: str | None = None,
329
+ eip_bandwidth: int | None = None,
330
+ period_type: str = "month",
331
+ period_num: int = 1,
332
+ is_auto_pay: bool = False,
333
+ is_auto_renew: bool = False,
334
+ is_auto_rename: bool = False,
335
+ ) -> dict[str, Any]:
336
+ """Create prepaid (monthly/yearly) servers; returns the async job."""
337
+
338
+ def _call() -> dict[str, Any]:
339
+ from huaweicloudsdkecs.v2.model.create_servers_request import CreateServersRequest
340
+ from huaweicloudsdkecs.v2.model.create_servers_request_body import (
341
+ CreateServersRequestBody,
342
+ )
343
+ from huaweicloudsdkecs.v2.model.pre_paid_server import PrePaidServer
344
+ from huaweicloudsdkecs.v2.model.pre_paid_server_eip import PrePaidServerEip
345
+ from huaweicloudsdkecs.v2.model.pre_paid_server_eip_bandwidth import (
346
+ PrePaidServerEipBandwidth,
347
+ )
348
+ from huaweicloudsdkecs.v2.model.pre_paid_server_extend_param import (
349
+ PrePaidServerExtendParam,
350
+ )
351
+ from huaweicloudsdkecs.v2.model.pre_paid_server_nic import PrePaidServerNic
352
+ from huaweicloudsdkecs.v2.model.pre_paid_server_publicip import (
353
+ PrePaidServerPublicip,
354
+ )
355
+ from huaweicloudsdkecs.v2.model.pre_paid_server_root_volume import (
356
+ PrePaidServerRootVolume,
357
+ )
358
+ from huaweicloudsdkecs.v2.model.pre_paid_server_security_group import (
359
+ PrePaidServerSecurityGroup,
360
+ )
361
+
362
+ kwargs: dict[str, Any] = {}
363
+ if security_group_id:
364
+ kwargs["security_groups"] = [PrePaidServerSecurityGroup(id=security_group_id)]
365
+ if eip_bandwidth:
366
+ # delete_on_termination releases the EIP with the server, so a
367
+ # deleted instance never leaves an orphaned (still billed) IP.
368
+ kwargs["publicip"] = PrePaidServerPublicip(
369
+ eip=PrePaidServerEip(
370
+ iptype="5_bgp",
371
+ bandwidth=PrePaidServerEipBandwidth(
372
+ size=eip_bandwidth, sharetype="PER", chargemode="traffic"
373
+ ),
374
+ ),
375
+ delete_on_termination=True,
376
+ )
377
+ server = PrePaidServer(
378
+ name=name,
379
+ flavor_ref=flavor_ref,
380
+ image_ref=image_ref,
381
+ vpcid=vpc_id,
382
+ nics=[PrePaidServerNic(subnet_id=subnet_id)],
383
+ root_volume=PrePaidServerRootVolume(
384
+ volumetype=root_volume_type, size=root_volume_size
385
+ ),
386
+ admin_pass=admin_pass,
387
+ key_name=key_name,
388
+ count=count,
389
+ availability_zone=availability_zone,
390
+ description=description,
391
+ user_data=user_data,
392
+ is_auto_rename=is_auto_rename,
393
+ extendparam=PrePaidServerExtendParam(
394
+ charging_mode="prePaid",
395
+ period_type=period_type,
396
+ period_num=period_num,
397
+ # The API expects "true"/"false" strings here, not booleans.
398
+ is_auto_pay="true" if is_auto_pay else "false",
399
+ is_auto_renew="true" if is_auto_renew else "false",
400
+ ),
401
+ **kwargs,
402
+ )
403
+ request = CreateServersRequest(body=CreateServersRequestBody(server=server))
404
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
405
+ response = self._client.create_servers(request)
406
+ return sdk_to_dict(response) or {}
407
+
408
+ return await call_sdk(_call)
409
+
410
+ async def create_post_paid_server(
411
+ self,
412
+ *,
413
+ name: str,
414
+ flavor_ref: str,
415
+ image_ref: str,
416
+ vpc_id: str,
417
+ subnet_id: str,
418
+ root_volume_type: str,
419
+ root_volume_size: int | None = None,
420
+ admin_pass: str | None = None,
421
+ key_name: str | None = None,
422
+ count: int = 1,
423
+ availability_zone: str | None = None,
424
+ description: str | None = None,
425
+ user_data: str | None = None,
426
+ security_group_id: str | None = None,
427
+ eip_bandwidth: int | None = None,
428
+ is_auto_rename: bool = False,
429
+ ) -> dict[str, Any]:
430
+ """Create post-paid (pay-per-use) servers; returns the async job."""
431
+
432
+ def _call() -> dict[str, Any]:
433
+ from huaweicloudsdkecs.v2.model.create_post_paid_servers_request import (
434
+ CreatePostPaidServersRequest,
435
+ )
436
+ from huaweicloudsdkecs.v2.model.create_post_paid_servers_request_body import (
437
+ CreatePostPaidServersRequestBody,
438
+ )
439
+ from huaweicloudsdkecs.v2.model.post_paid_server import PostPaidServer
440
+ from huaweicloudsdkecs.v2.model.post_paid_server_eip import PostPaidServerEip
441
+ from huaweicloudsdkecs.v2.model.post_paid_server_eip_bandwidth import (
442
+ PostPaidServerEipBandwidth,
443
+ )
444
+ from huaweicloudsdkecs.v2.model.post_paid_server_extend_param import (
445
+ PostPaidServerExtendParam,
446
+ )
447
+ from huaweicloudsdkecs.v2.model.post_paid_server_nic import PostPaidServerNic
448
+ from huaweicloudsdkecs.v2.model.post_paid_server_publicip import (
449
+ PostPaidServerPublicip,
450
+ )
451
+ from huaweicloudsdkecs.v2.model.post_paid_server_root_volume import (
452
+ PostPaidServerRootVolume,
453
+ )
454
+ from huaweicloudsdkecs.v2.model.post_paid_server_security_group import (
455
+ PostPaidServerSecurityGroup,
456
+ )
457
+
458
+ kwargs: dict[str, Any] = {}
459
+ if security_group_id:
460
+ kwargs["security_groups"] = [PostPaidServerSecurityGroup(id=security_group_id)]
461
+ if eip_bandwidth:
462
+ # delete_on_termination releases the EIP with the server, so a
463
+ # deleted instance never leaves an orphaned (still billed) IP.
464
+ kwargs["publicip"] = PostPaidServerPublicip(
465
+ eip=PostPaidServerEip(
466
+ iptype="5_bgp",
467
+ bandwidth=PostPaidServerEipBandwidth(
468
+ size=eip_bandwidth, sharetype="PER", chargemode="traffic"
469
+ ),
470
+ ),
471
+ delete_on_termination=True,
472
+ )
473
+ server = PostPaidServer(
474
+ name=name,
475
+ flavor_ref=flavor_ref,
476
+ image_ref=image_ref,
477
+ vpcid=vpc_id,
478
+ nics=[PostPaidServerNic(subnet_id=subnet_id)],
479
+ root_volume=PostPaidServerRootVolume(
480
+ volumetype=root_volume_type, size=root_volume_size
481
+ ),
482
+ admin_pass=admin_pass,
483
+ key_name=key_name,
484
+ count=count,
485
+ availability_zone=availability_zone,
486
+ description=description,
487
+ user_data=user_data,
488
+ is_auto_rename=is_auto_rename,
489
+ # extendparam is required for post-paid; charging_mode 0 = pay-per-use.
490
+ extendparam=PostPaidServerExtendParam(charging_mode=0),
491
+ **kwargs,
492
+ )
493
+ request = CreatePostPaidServersRequest(
494
+ body=CreatePostPaidServersRequestBody(server=server)
495
+ )
496
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
497
+ response = self._client.create_post_paid_servers(request)
498
+ return sdk_to_dict(response) or {}
499
+
500
+ return await call_sdk(_call)
501
+
502
+ async def update_server(
503
+ self,
504
+ *,
505
+ server_id: str,
506
+ name: str | None = None,
507
+ description: str | None = None,
508
+ hostname: str | None = None,
509
+ ) -> dict[str, Any]:
510
+ """Rename / re-describe a server; omitted fields stay unchanged."""
511
+
512
+ def _call() -> dict[str, Any]:
513
+ from huaweicloudsdkecs.v2.model.update_server_option import UpdateServerOption
514
+ from huaweicloudsdkecs.v2.model.update_server_request import UpdateServerRequest
515
+ from huaweicloudsdkecs.v2.model.update_server_request_body import (
516
+ UpdateServerRequestBody,
517
+ )
518
+
519
+ request = UpdateServerRequest(
520
+ server_id=server_id,
521
+ body=UpdateServerRequestBody(
522
+ server=UpdateServerOption(name=name, description=description, hostname=hostname)
523
+ ),
524
+ )
525
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
526
+ response = self._client.update_server(request)
527
+ return sdk_to_dict(response) or {}
528
+
529
+ return await call_sdk(_call)
530
+
531
+ async def delete_servers(
532
+ self,
533
+ *,
534
+ server_ids: list[str],
535
+ delete_volume: bool = False,
536
+ delete_publicip: bool = False,
537
+ ) -> dict[str, Any]:
538
+ """Delete servers asynchronously; returns the async job."""
539
+
540
+ def _call() -> dict[str, Any]:
541
+ from huaweicloudsdkecs.v2.model.delete_servers_request import DeleteServersRequest
542
+ from huaweicloudsdkecs.v2.model.delete_servers_request_body import (
543
+ DeleteServersRequestBody,
544
+ )
545
+ from huaweicloudsdkecs.v2.model.server_id import ServerId
546
+
547
+ request = DeleteServersRequest(
548
+ body=DeleteServersRequestBody(
549
+ delete_publicip=delete_publicip,
550
+ delete_volume=delete_volume,
551
+ servers=[ServerId(id=sid) for sid in server_ids],
552
+ )
553
+ )
554
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
555
+ response = self._client.delete_servers(request)
556
+ return sdk_to_dict(response) or {}
557
+
558
+ return await call_sdk(_call)
559
+
560
+ async def show_job(self, job_id: str) -> dict[str, Any]:
561
+ """Fetch the status of an async job (create/delete)."""
562
+
563
+ def _call() -> dict[str, Any]:
564
+ from huaweicloudsdkecs.v2.model.show_job_request import ShowJobRequest
565
+
566
+ request = ShowJobRequest(job_id=job_id)
567
+ # Let SDK/transport exceptions surface raw to call_sdk (see list_all_servers).
568
+ response = self._client.show_job(request)
569
+ return sdk_to_dict(response) or {}
570
+
571
+ return await call_sdk(_call)
@@ -0,0 +1,16 @@
1
+ # Copyright (c) 2026 Huawei Technologies Co., Ltd.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Huawei Cloud ecs-lifecycle MCP Server entrypoint."""
5
+
6
+ from huaweicloud_mcp_core.server import run_standard
7
+
8
+ from mcp_server_ecs_lifecycle.server import mcp
9
+
10
+
11
+ def main() -> None:
12
+ run_standard(mcp, service_name="ecs-lifecycle")
13
+
14
+
15
+ if __name__ == "__main__":
16
+ main()
@@ -0,0 +1,13 @@
1
+ # Copyright (c) 2026 Huawei Technologies Co., Ltd.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """MCPServer instance construction for the ECS lifecycle server (guardrails auto-installed)."""
5
+
6
+ from huaweicloud_mcp_core.server import build_server
7
+
8
+ mcp = build_server("ecs-lifecycle")
9
+
10
+ from mcp_server_ecs_lifecycle.tools import ( # noqa: E402,F401
11
+ discovery,
12
+ lifecycle,
13
+ )
File without changes