alibaba-cloud-ops-mcp-server 0.8.7__py3-none-any.whl → 0.8.8__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.
@@ -30,12 +30,13 @@ class ApiMetaClient:
30
30
 
31
31
  @classmethod
32
32
  def get_response_from_pop_api(cls, pop_api_name, service=None, api=None, version=None):
33
+ url = None # 提前定义,防止 except 中引用未定义变量
33
34
  try:
34
35
  api_config = cls.config.get(pop_api_name)
35
36
  try:
36
37
  formatted_path = api_config[cls.PATH].format(service=service, api=api, version=version)
37
38
  except KeyError as e:
38
- raise Exception(f'Failed to format path, path: {api_config[cls.PATH]}, error: {e}')
39
+ raise Exception(f'Failed to format path, path: {api_config.get(cls.PATH)}, error: {e}')
39
40
 
40
41
  url = f'{cls.BASE_URL}/{formatted_path}'
41
42
  response = requests.get(url)
@@ -2,6 +2,7 @@ import os
2
2
  from mcp.server.fastmcp import FastMCP, Context
3
3
  from pydantic import Field
4
4
  import logging
5
+ import json
5
6
 
6
7
  import inspect
7
8
  import types
@@ -32,6 +33,15 @@ def create_client(service: str, region_id: str) -> OpenApiClient:
32
33
  return OpenApiClient(config)
33
34
 
34
35
 
36
+ # 类型为String的JSON数组参数
37
+ ECS_LIST_PARAMETERS = {
38
+ 'HpcClusterIds', 'DedicatedHostClusterIds', 'DedicatedHostIds',
39
+ 'InstanceIds', 'DeploymentSetIds', 'KeyPairNames', 'SecurityGroupIds',
40
+ 'diskIds', 'repeatWeekdays', 'timePoints', 'DiskIds', 'SnapshotLinkIds',
41
+ 'EipAddresses', 'PublicIpAddresses', 'PrivateIpAddresses'
42
+ }
43
+
44
+
35
45
  def _tools_api_call(service: str, api: str, parameters: dict, ctx: Context):
36
46
  service = service.lower()
37
47
  api_meta, _ = ApiMetaClient.get_api_meta(service, api)
@@ -39,8 +49,16 @@ def _tools_api_call(service: str, api: str, parameters: dict, ctx: Context):
39
49
  method = 'POST' if api_meta.get('methods', [])[0] == 'post' else 'GET'
40
50
  path = api_meta.get('path', '/')
41
51
  style = ApiMetaClient.get_service_style(service)
52
+
53
+ # 处理特殊参数格式
54
+ processed_parameters = parameters.copy()
55
+ if service == 'ecs':
56
+ for param_name, param_value in parameters.items():
57
+ if param_name in ECS_LIST_PARAMETERS and isinstance(param_value, list):
58
+ processed_parameters[param_name] = json.dumps(param_value)
59
+
42
60
  req = open_api_models.OpenApiRequest(
43
- query=OpenApiUtilClient.query(parameters)
61
+ query=OpenApiUtilClient.query(processed_parameters)
44
62
  )
45
63
  params = open_api_models.Params(
46
64
  action=api,
@@ -53,7 +71,7 @@ def _tools_api_call(service: str, api: str, parameters: dict, ctx: Context):
53
71
  req_body_type='formData',
54
72
  body_type='json'
55
73
  )
56
- client = create_client(service, parameters.get('RegionId', 'cn-hangzhou'))
74
+ client = create_client(service, processed_parameters.get('RegionId', 'cn-hangzhou'))
57
75
  runtime = util_models.RuntimeOptions()
58
76
  return client.call_api(params, req, runtime)
59
77
 
@@ -75,9 +93,15 @@ def _create_function_schemas(service, api, api_meta):
75
93
  description = schema.get('description', '')
76
94
  example = schema.get('example', '')
77
95
  type_ = schema.get('type', '')
78
- description = f'{description} 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: {type_},参数示例:{example}'
96
+ description = f'{description} 参数类型: {type_},参数示例:{example}'
79
97
  required = schema.get('required', False)
80
- python_type = type_map.get(type_, str)
98
+
99
+ # 只有在service为ecs时,才对特定参数进行特殊处理
100
+ if service.lower() == 'ecs' and name in ECS_LIST_PARAMETERS and type_ == 'string':
101
+ python_type = list
102
+ else:
103
+ python_type = type_map.get(type_, str)
104
+
81
105
  field_info = (
82
106
  python_type,
83
107
  field(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alibaba-cloud-ops-mcp-server
3
- Version: 0.8.7
3
+ Version: 0.8.8
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
@@ -58,16 +58,19 @@ To use `alibaba-cloud-ops-mcp-server` MCP Server with any other MCP Client, you
58
58
  ## MCP Maketplace Integration
59
59
 
60
60
  * [Cline](https://cline.bot/mcp-marketplace)
61
+ * [Cursor](https://docs.cursor.com/tools) [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=alibaba-cloud-ops-mcp-server&config=eyJ0aW1lb3V0Ijo2MDAsImNvbW1hbmQiOiJ1dnggYWxpYmFiYS1jbG91ZC1vcHMtbWNwLXNlcnZlckBsYXRlc3QiLCJlbnYiOnsiQUxJQkFCQV9DTE9VRF9BQ0NFU1NfS0VZX0lEIjoiWW91ciBBY2Nlc3MgS2V5IElEIiwiQUxJQkFCQV9DTE9VRF9BQ0NFU1NfS0VZX1NFQ1JFVCI6IllvdXIgQWNjZXNzIEtleSBTRUNSRVQifX0%3D)
61
62
  * [ModelScope](https://www.modelscope.cn/mcp/servers/@aliyun/alibaba-cloud-ops-mcp-server?lang=en_US)
62
63
  * [Lingma](https://lingma.aliyun.com/)
63
64
  * [Smithery AI](https://smithery.ai/server/@aliyun/alibaba-cloud-ops-mcp-server)
64
65
  * [FC-Function AI](https://cap.console.aliyun.com/template-detail?template=237)
66
+ * [Alibaba Cloud Model Studio](https://bailian.console.aliyun.com/?tab=mcp#/mcp-market/detail/alibaba-cloud-ops)
65
67
 
66
68
  ## Know More
67
69
 
68
- * [Alibaba Cloud MCP Server is ready to use out of the box!!](https://developer.aliyun.com/article/1661348)
69
- * [Setup Alibaba Cloud MCP Server on Bailian](https://developer.aliyun.com/article/1662120)
70
+ * [Alibaba Cloud Ops MCP Server is ready to use out of the box!!](https://developer.aliyun.com/article/1661348)
71
+ * [Setup Alibaba Cloud Ops MCP Server on Bailian](https://developer.aliyun.com/article/1662120)
70
72
  * [Build your own Alibaba Cloud OpenAPI MCP Server with 10 lines of code](https://developer.aliyun.com/article/1662202)
73
+ * [Alibaba Cloud Ops MCP Server is officially available on the Alibaba Cloud Model Studio Platform MCP Marketplace](https://developer.aliyun.com/article/1665019)
71
74
 
72
75
  ## Tools
73
76
 
@@ -2,16 +2,16 @@ alibaba_cloud_ops_mcp_server/__init__.py,sha256=BaluUNyRz8Qw-X7Y0ywDezwbkqiSvWlS
2
2
  alibaba_cloud_ops_mcp_server/config.py,sha256=Nq6AT8bqSVa6zu9xjInaSjFcxA-GC7MLlCsV1q53yO0,514
3
3
  alibaba_cloud_ops_mcp_server/server.py,sha256=WGaSZqKFKudqrHfpdBYyAx90dApoWADOwmFy_jgQmCQ,1051
4
4
  alibaba_cloud_ops_mcp_server/alibabacloud/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- alibaba_cloud_ops_mcp_server/alibabacloud/api_meta_client.py,sha256=inOmW1no1YsR6_ezOZfgJtzGKo5nRTDufkf2qUTuNOs,7605
5
+ alibaba_cloud_ops_mcp_server/alibabacloud/api_meta_client.py,sha256=VOyOLuo_WC8uaJSlh5pLxaMb2z90HWHVtCMhb2hddRE,7685
6
6
  alibaba_cloud_ops_mcp_server/alibabacloud/exception.py,sha256=7PdhgqgXEGrTPL1cj98h9EH-RrM6-2TT89PDtcmlpmU,1230
7
7
  alibaba_cloud_ops_mcp_server/alibabacloud/utils.py,sha256=jWQtP59P4ejh7N6xiYSDq1WgCd3Les0aSZr2pLGzkls,299
8
8
  alibaba_cloud_ops_mcp_server/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- alibaba_cloud_ops_mcp_server/tools/api_tools.py,sha256=uQ7dXGovPlw8FvUgIRAErsu4fySbM8bzf_8eQH8G7fM,5899
9
+ alibaba_cloud_ops_mcp_server/tools/api_tools.py,sha256=gXIZnQrCeS8SHWxFl4DlaKfHAaQAcA8K4s_G2YmOgQM,6523
10
10
  alibaba_cloud_ops_mcp_server/tools/cms_tools.py,sha256=GFSBDTddvQ7M9fDGm69jvH6Yt4nui5uOVjwD61CZKT4,4191
11
11
  alibaba_cloud_ops_mcp_server/tools/oos_tools.py,sha256=l228yl_SGg_rNdrBSDeqWYI8ZE1XUAHhsPLArvfE4A8,10116
12
12
  alibaba_cloud_ops_mcp_server/tools/oss_tools.py,sha256=c7D1fAjFBqHl0oMy0O6i7onoXeAN9cpdBdLtXKrxVQE,4615
13
- alibaba_cloud_ops_mcp_server-0.8.7.dist-info/METADATA,sha256=lQLG53I8ePS2A5oSkpxOIgqbIBWxAtGzvzOTn1Y5aVI,5147
14
- alibaba_cloud_ops_mcp_server-0.8.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- alibaba_cloud_ops_mcp_server-0.8.7.dist-info/entry_points.txt,sha256=ESGAWXKEp184forhs7VzTD4P1AUdZz6vCW6hRUKITGw,83
16
- alibaba_cloud_ops_mcp_server-0.8.7.dist-info/licenses/LICENSE,sha256=gQgVkp2ttRCjodiPpXZZR-d7JnrYIYNiHk1YDUYgpa4,11331
17
- alibaba_cloud_ops_mcp_server-0.8.7.dist-info/RECORD,,
13
+ alibaba_cloud_ops_mcp_server-0.8.8.dist-info/METADATA,sha256=WZrATOzyuQ5i_ui5BumysOshIezmLCRlTBsWHlaXw8w,5870
14
+ alibaba_cloud_ops_mcp_server-0.8.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ alibaba_cloud_ops_mcp_server-0.8.8.dist-info/entry_points.txt,sha256=ESGAWXKEp184forhs7VzTD4P1AUdZz6vCW6hRUKITGw,83
16
+ alibaba_cloud_ops_mcp_server-0.8.8.dist-info/licenses/LICENSE,sha256=gQgVkp2ttRCjodiPpXZZR-d7JnrYIYNiHk1YDUYgpa4,11331
17
+ alibaba_cloud_ops_mcp_server-0.8.8.dist-info/RECORD,,