alibaba-cloud-ops-mcp-server 0.8.2__py3-none-any.whl → 0.8.4__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,46 @@
1
+ import sys
2
+ import json
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+
8
+ class AcsException(Exception):
9
+ msg_fmt = 'An unknown exception occurred.'
10
+ status = 500
11
+ code = 'InternalError'
12
+
13
+ def __init__(self, **kwargs):
14
+ self.kwargs = kwargs
15
+
16
+ try:
17
+ self.message = self.msg_fmt.format(**kwargs) if kwargs else self.msg_fmt
18
+ if isinstance(self.message, str):
19
+ self.message = self.message.rstrip('.') + '.'
20
+ except KeyError:
21
+ logger.exception(f'Exception in string format operation: {self.code}, {self.msg_fmt}, {kwargs}')
22
+ for name, value in kwargs.items():
23
+ logger.error(f'{name}: {value}')
24
+
25
+ def __str__(self):
26
+ body = {
27
+ 'Message': self.message,
28
+ 'Code': self.code
29
+ }
30
+ return json.dumps(body)
31
+
32
+ def __deepcopy__(self, memo):
33
+ return self.__class__(**self.kwargs)
34
+
35
+ def __unicode__(self):
36
+ body = {
37
+ 'Message': self.message,
38
+ 'Code': self.code
39
+ }
40
+ return json.dumps(body)
41
+
42
+
43
+ class OOSExecutionFailed(AcsException):
44
+ msg_fmt = 'OOS Execution Failed, reason: {reason}.'
45
+ status = 400
46
+ code = 'Execution.Failed'
@@ -7,9 +7,10 @@ import time
7
7
  from alibabacloud_oos20190601.client import Client as oos20190601Client
8
8
  from alibabacloud_oos20190601 import models as oos_20190601_models
9
9
  from alibaba_cloud_ops_mcp_server.alibabacloud.utils import create_config
10
+ from alibaba_cloud_ops_mcp_server.alibabacloud import exception
10
11
 
11
12
 
12
- END_STATUSES = ['Success', 'Failed', 'Cancelled']
13
+ END_STATUSES = [SUCCESS, FAILED, CANCELLED] = ['Success', 'Failed', 'Cancelled']
13
14
 
14
15
 
15
16
  tools = []
@@ -38,7 +39,10 @@ def _start_execution_sync(region_id: str, template_name: str, parameters: dict):
38
39
  )
39
40
  list_executions_resp = client.list_executions(list_executions_request)
40
41
  status = list_executions_resp.body.executions[0].status
41
- if status in END_STATUSES:
42
+ if status == FAILED:
43
+ status_message = list_executions_resp.body.executions[0].status_message
44
+ raise exception.OOSExecutionFailed(reason=status_message)
45
+ elif status in END_STATUSES:
42
46
  return list_executions_resp.body
43
47
  time.sleep(1)
44
48
  @tools.append
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alibaba-cloud-ops-mcp-server
3
- Version: 0.8.2
3
+ Version: 0.8.4
4
4
  Summary: A MCP server for Alibaba Cloud
5
5
  Author-email: Zheng Dayu <dayu.zdy@alibaba-inc.com>
6
6
  License-File: LICENSE
@@ -60,6 +60,7 @@ To use `alibaba-cloud-ops-mcp-server` MCP Server with any other MCP Client, you
60
60
  * [ModelScope](https://www.modelscope.cn/mcp/servers/@aliyun/alibaba-cloud-ops-mcp-server?lang=en_US)
61
61
  * [Lingma](https://lingma.aliyun.com/)
62
62
  * [Smithery AI](https://smithery.ai/server/@aliyun/alibaba-cloud-ops-mcp-server)
63
+ * [FC-Function AI](https://cap.console.aliyun.com/template-detail?template=237)
63
64
 
64
65
  ## Know More
65
66
 
@@ -1,16 +1,16 @@
1
1
  alibaba_cloud_ops_mcp_server/__init__.py,sha256=BaluUNyRz8Qw-X7Y0ywDezwbkqiSvWlSYn2452XeGcA,213
2
2
  alibaba_cloud_ops_mcp_server/config.py,sha256=Nq6AT8bqSVa6zu9xjInaSjFcxA-GC7MLlCsV1q53yO0,514
3
- alibaba_cloud_ops_mcp_server/server.py,sha256=nwn04rpm68GI3UJ_hQ0E3pny86dJ47Lw1LncQiBIfW8,896
4
3
  alibaba_cloud_ops_mcp_server/alibabacloud/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
4
  alibaba_cloud_ops_mcp_server/alibabacloud/api_meta_client.py,sha256=inOmW1no1YsR6_ezOZfgJtzGKo5nRTDufkf2qUTuNOs,7605
5
+ alibaba_cloud_ops_mcp_server/alibabacloud/exception.py,sha256=7PdhgqgXEGrTPL1cj98h9EH-RrM6-2TT89PDtcmlpmU,1230
6
6
  alibaba_cloud_ops_mcp_server/alibabacloud/utils.py,sha256=jWQtP59P4ejh7N6xiYSDq1WgCd3Les0aSZr2pLGzkls,299
7
7
  alibaba_cloud_ops_mcp_server/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  alibaba_cloud_ops_mcp_server/tools/api_tools.py,sha256=lydogpHEYgqzLAgUP4szBy-67z7lWXiqwUaTvt_IQVM,5807
9
9
  alibaba_cloud_ops_mcp_server/tools/cms_tools.py,sha256=t70H7MnYo0cuIY00_6V3cGz2btSRtJFm8qW8WWwzyCc,4155
10
- alibaba_cloud_ops_mcp_server/tools/oos_tools.py,sha256=rbi3oR3CIbafA9hDHqGN6jLUyUQ6oCj-aReFQCZkHfE,9796
10
+ alibaba_cloud_ops_mcp_server/tools/oos_tools.py,sha256=-e7ikaf708vAueOUFoWp3xMbpaj6JUGaB1KbK-YniV8,10076
11
11
  alibaba_cloud_ops_mcp_server/tools/oss_tools.py,sha256=IJDcs4BvPgF5A85oBZJ5xrJDSim_fCzRaxnCHjd0hvw,4599
12
- alibaba_cloud_ops_mcp_server-0.8.2.dist-info/METADATA,sha256=57rILn-1UaWlfxT9NySPL1sf52Bbu3qsLbdRlFNpFaE,5020
13
- alibaba_cloud_ops_mcp_server-0.8.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
- alibaba_cloud_ops_mcp_server-0.8.2.dist-info/entry_points.txt,sha256=ESGAWXKEp184forhs7VzTD4P1AUdZz6vCW6hRUKITGw,83
15
- alibaba_cloud_ops_mcp_server-0.8.2.dist-info/licenses/LICENSE,sha256=gQgVkp2ttRCjodiPpXZZR-d7JnrYIYNiHk1YDUYgpa4,11331
16
- alibaba_cloud_ops_mcp_server-0.8.2.dist-info/RECORD,,
12
+ alibaba_cloud_ops_mcp_server-0.8.4.dist-info/METADATA,sha256=5v3MNr2aPdNhZvx3PcYtE7eC6Z6GJ1-Ri0ydj4VBYlU,5100
13
+ alibaba_cloud_ops_mcp_server-0.8.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ alibaba_cloud_ops_mcp_server-0.8.4.dist-info/entry_points.txt,sha256=ESGAWXKEp184forhs7VzTD4P1AUdZz6vCW6hRUKITGw,83
15
+ alibaba_cloud_ops_mcp_server-0.8.4.dist-info/licenses/LICENSE,sha256=gQgVkp2ttRCjodiPpXZZR-d7JnrYIYNiHk1YDUYgpa4,11331
16
+ alibaba_cloud_ops_mcp_server-0.8.4.dist-info/RECORD,,
@@ -1,35 +0,0 @@
1
- from mcp.server.fastmcp import FastMCP
2
- import click
3
- import logging
4
-
5
- from alibaba_cloud_ops_mcp_server.config import config
6
- from alibaba_cloud_ops_mcp_server.tools import cms_tools, oos_tools, oss_tools, api_tools
7
-
8
- logger = logging.getLogger(__name__)
9
-
10
-
11
- @click.command()
12
- @click.option(
13
- "--transport",
14
- type=click.Choice(["stdio", "sse"]),
15
- default="stdio",
16
- help="Transport type",
17
- )
18
- def main(transport: str):
19
- # Create an MCP server
20
- mcp = FastMCP("alibaba-cloud-ops-mcp-server")
21
- for tool in oos_tools.tools:
22
- mcp.add_tool(tool)
23
- for tool in cms_tools.tools:
24
- mcp.add_tool(tool)
25
- for tool in oss_tools.tools:
26
- mcp.add_tool(tool)
27
- api_tools.create_api_tools(mcp, config)
28
-
29
- # Initialize and run the server
30
- logger.debug(f'mcp server is running on {transport} mode.')
31
- mcp.run(transport=transport)
32
-
33
-
34
- if __name__ == "__main__":
35
- main()