alibaba-cloud-ops-mcp-server 0.8.5__py3-none-any.whl → 0.9.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.
@@ -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)
@@ -46,9 +47,16 @@ class ApiMetaClient:
46
47
  @classmethod
47
48
  def get_service_version(cls, service):
48
49
  data = cls.get_response_from_pop_api(cls.GET_PRODUCT_LIST)
49
- version = next((item.get(DEFAULT_VERSION) for item in data if item.get(CODE).lower() == service), None)
50
+ version = next((item.get(DEFAULT_VERSION) for item in data if item.get(CODE).lower() == service.lower()), None)
50
51
  return version
51
52
 
53
+ @classmethod
54
+ def get_all_service_info(cls):
55
+ data = cls.get_response_from_pop_api(cls.GET_PRODUCT_LIST)
56
+ filtered_data = [{"code": item["code"], "name": item["name"]} for item in data]
57
+
58
+ return filtered_data
59
+
52
60
  @classmethod
53
61
  def get_service_style(cls, service):
54
62
  data = cls.get_response_from_pop_api(cls.GET_PRODUCT_LIST)
@@ -146,7 +154,8 @@ class ApiMetaClient:
146
154
  return combined_params
147
155
 
148
156
  @classmethod
149
- def get_apis_in_service(cls, service, version):
157
+ def get_apis_in_service(cls, service):
158
+ version = cls.get_service_version(service)
150
159
  data = cls.get_response_from_pop_api(cls.GET_API_OVERVIEW, service=service, version=version)
151
160
  apis = list(data[APIS].keys())
152
161
  return apis
@@ -0,0 +1,134 @@
1
+ ## Optimized Prompt
2
+
3
+ When a user submits a request, analyze their needs and check if matching tools exist. If yes, use them directly. If not, proceed to the retrieval phase.
4
+
5
+ ---
6
+
7
+ ## Request Flow
8
+
9
+ 1. **Analysis & Selection**
10
+ - Analyze user intent
11
+ - Choose between specific tools or common API flow
12
+ - Verify service support
13
+
14
+ 2. **API Flow** (if no specific tool)
15
+ - Identify service
16
+ - Select API via `ListAPIs`
17
+ - Get params via `GetAPIInfo`
18
+ - Execute via `CommonAPICaller`
19
+
20
+ 3. **Error Handling**
21
+ - Service not supported: "Unfortunately, we currently do not support this service"
22
+ - API failures: Check error code, params, permissions
23
+ - Param validation: Verify types and formats
24
+
25
+ ---
26
+
27
+ ### Retrieval Phase
28
+
29
+ 1. **Service Selection**
30
+
31
+ Supported Services:
32
+ - ecs: Elastic Compute Service (ECS)
33
+ - oos: Operations Orchestration Service (OOS)
34
+ - rds: Relational Database Service (RDS)
35
+ - vpc: Virtual Private Cloud (VPC)
36
+ - slb: Server Load Balancer (SLB)
37
+ - ess: Elastic Scaling (ESS)
38
+ - ros: Resource Orchestration Service (ROS)
39
+ - cbn: Cloud Enterprise Network (CBN)
40
+ - dds: MongoDB Database Service (DDS)
41
+ - r-kvstore: Cloud database Tair (compatible with Redis) (R-KVStore)
42
+
43
+ 2. **API Process**
44
+ - Use `ListAPIs` for available APIs
45
+ - Use `GetAPIInfo` for API details
46
+ - Use `CommonAPICaller` to execute
47
+
48
+ ---
49
+
50
+ ### Notes
51
+ - Filter for most appropriate result
52
+ - Choose based on user context and common usage
53
+ - Validate parameters before calls
54
+ - Handle errors gracefully
55
+
56
+ ---
57
+
58
+ ### Common Scenarios
59
+
60
+ 1. **Instance Management**
61
+ ```
62
+ User: "Start ECS instance i-1234567890abcdef0"
63
+ Action: Use OOS_StartInstances
64
+ ```
65
+
66
+ 2. **Monitoring**
67
+ ```
68
+ User: "Check ECS CPU usage"
69
+ Action: Use CMS_GetCpuUsageData
70
+ ```
71
+
72
+ 3. **Custom API**
73
+ ```
74
+ User: "Create VPC in cn-hangzhou"
75
+ Action: ListAPIs → GetAPIInfo → CommonAPICaller
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Available Tools
81
+
82
+ ### ECS (OOS/API)
83
+ - RunCommand: Execute commands on instances
84
+ - StartInstances: Start ECS instances
85
+ - StopInstances: Stop ECS instances
86
+ - RebootInstances: Reboot ECS instances
87
+ - DescribeInstances: List instance details
88
+ - DescribeRegions: List available regions
89
+ - DescribeZones: List available zones
90
+ - DescribeAvailableResource: Check resource inventory
91
+ - DescribeImages: List available images
92
+ - DescribeSecurityGroups: List security groups
93
+ - RunInstances: Create new instances
94
+ - DeleteInstances: Delete instances
95
+ - ResetPassword: Change instance password
96
+ - ReplaceSystemDisk: Change instance OS
97
+
98
+ ### VPC (API)
99
+ - DescribeVpcs: List VPCs
100
+ - DescribeVSwitches: List VSwitches
101
+
102
+ ### RDS (OOS/API)
103
+ - DescribeDBInstances: List database instances
104
+ - StartDBInstances: Start RDS instances
105
+ - StopDBInstances: Stop RDS instances
106
+ - RestartDBInstances: Restart RDS instances
107
+
108
+ ### OSS (API)
109
+ - ListBuckets: List OSS buckets
110
+ - PutBucket: Create bucket
111
+ - DeleteBucket: Delete bucket
112
+ - ListObjects: List bucket contents
113
+
114
+ ### CloudMonitor (API)
115
+ - GetCpuUsageData: Get instance CPU usage
116
+ - GetCpuLoadavgData: Get 1m CPU load
117
+ - GetCpuloadavg5mData: Get 5m CPU load
118
+ - GetCpuloadavg15mData: Get 15m CPU load
119
+ - GetMemUsedData: Get memory usage
120
+ - GetMemUsageData: Get memory utilization
121
+ - GetDiskUsageData: Get disk utilization
122
+ - GetDiskTotalData: Get total disk space
123
+ - GetDiskUsedData: Get used disk space
124
+
125
+ Note: (OOS) = Operations Orchestration Service, (API) = Direct API call
126
+
127
+ ---
128
+
129
+ ### Best Practices
130
+ - Use pre-defined tools when possible
131
+ - Follow API rate limits
132
+ - Implement proper error handling
133
+ - Validate all parameters
134
+ - Use appropriate endpoints
@@ -0,0 +1,8 @@
1
+ from importlib import resources
2
+
3
+ with (
4
+ resources.files('alibaba_cloud_ops_mcp_server.alibabacloud.static')
5
+ .joinpath('PROMPT_UNDERSTANDING.md')
6
+ .open('r', encoding='utf-8') as f
7
+ ):
8
+ PROMPT_UNDERSTANDING = f.read()
@@ -2,16 +2,30 @@ from mcp.server.fastmcp import FastMCP
2
2
  import click
3
3
  import logging
4
4
 
5
+ from alibaba_cloud_ops_mcp_server.tools.common_api_tools import set_custom_service_list
5
6
  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
+ from alibaba_cloud_ops_mcp_server.tools import cms_tools, oos_tools, oss_tools, api_tools, common_api_tools
7
8
 
8
9
  logger = logging.getLogger(__name__)
9
10
 
11
+ SUPPORTED_SERVICES_MAP = {
12
+ "ecs": "Elastic Compute Service (ECS)",
13
+ "oos": "Operations Orchestration Service (OOS)",
14
+ "rds": "Relational Database Service (RDS)",
15
+ "vpc": "Virtual Private Cloud (VPC)",
16
+ "slb": "Server Load Balancer (SLB)",
17
+ "ess": "Elastic Scaling (ESS)",
18
+ "ros": "Resource Orchestration Service (ROS)",
19
+ "cbn": "Cloud Enterprise Network (CBN)",
20
+ "dds": "MongoDB Database Service (DDS)",
21
+ "r-kvstore": "Cloud database Tair (compatible with Redis) (R-KVStore)"
22
+ }
23
+
10
24
 
11
25
  @click.command()
12
26
  @click.option(
13
27
  "--transport",
14
- type=click.Choice(["stdio", "sse"]),
28
+ type=click.Choice(["stdio", "sse", "streamable-http"]),
15
29
  default="stdio",
16
30
  help="Transport type",
17
31
  )
@@ -21,12 +35,32 @@ logger = logging.getLogger(__name__)
21
35
  default=8000,
22
36
  help="Port number",
23
37
  )
24
- def main(transport: str, port: int):
38
+ @click.option(
39
+ "--host",
40
+ type=str,
41
+ default="127.0.0.1",
42
+ help="Host",
43
+ )
44
+ @click.option(
45
+ "--services",
46
+ type=str,
47
+ default=None,
48
+ help="Comma-separated list of supported services, e.g., 'ecs,vpc,rds'",
49
+ )
50
+ def main(transport: str, port: int, host: str, services: str):
25
51
  # Create an MCP server
26
52
  mcp = FastMCP(
27
53
  name="alibaba-cloud-ops-mcp-server",
28
- port=port
54
+ port=port,
55
+ host=host
29
56
  )
57
+
58
+ if services:
59
+ service_keys = [s.strip().lower() for s in services.split(",")]
60
+ service_list = [(key, SUPPORTED_SERVICES_MAP.get(key, key)) for key in service_keys]
61
+ set_custom_service_list(service_list)
62
+ for tool in common_api_tools.tools:
63
+ mcp.add_tool(tool)
30
64
  for tool in oos_tools.tools:
31
65
  mcp.add_tool(tool)
32
66
  for tool in cms_tools.tools:
@@ -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
@@ -23,15 +24,50 @@ type_map = {
23
24
  'number': float
24
25
  }
25
26
 
27
+ REGION_ENDPOINT_SERVICE = ['ecs', 'oos', 'vpc', 'slb']
28
+
29
+ DOUBLE_ENDPOINT_SERVICE = {
30
+ 'rds': ['cn-qingdao', 'cn-beijing', 'cn-hangzhou', 'cn-shanghai', 'cn-shenzhen', 'cn-heyuan', 'cn-guangzhou', 'cn-hongkong'],
31
+ 'ess': ['cn-qingdao', 'cn-beijing', 'cn-hangzhou', 'cn-shanghai', 'cn-nanjing', 'cn-shenzhen'],
32
+ 'ros': ['cn-qingdao'],
33
+ 'dds': ['cn-qingdao', 'cn-beijing', 'cn-wulanchabu', 'cn-hangzhou', 'cn-shanghai', 'cn-shenzhen', 'cn-heyuan', 'cn-guangzhou'],
34
+ 'r-kvstore': ['cn-qingdao', 'cn-beijing', 'cn-wulanchabu', 'cn-hangzhou', 'cn-shanghai', 'cn-shenzhen', 'cn-heyuan']
35
+ }
36
+
37
+ CENTRAL_ENDPOINTS_SERVICE = ['cbn']
38
+
39
+
40
+ def _get_service_endpoint(service: str, region_id: str):
41
+ region_id = region_id.lower()
42
+ use_region_endpoint = service in REGION_ENDPOINT_SERVICE or (
43
+ service in DOUBLE_ENDPOINT_SERVICE and region_id in DOUBLE_ENDPOINT_SERVICE[service]
44
+ )
45
+
46
+ if use_region_endpoint:
47
+ return f'{service}.{region_id}.aliyuncs.com'
48
+ elif service in CENTRAL_ENDPOINTS_SERVICE or service in DOUBLE_ENDPOINT_SERVICE:
49
+ return f'{service}.aliyuncs.com'
50
+ else:
51
+ return f'{service}.{region_id}.aliyuncs.com'
52
+
26
53
 
27
54
  def create_client(service: str, region_id: str) -> OpenApiClient:
28
55
  config = create_config()
29
56
  if isinstance(service, str):
30
57
  service = service.lower()
31
- config.endpoint = f'{service}.{region_id}.aliyuncs.com'
58
+ config.endpoint = _get_service_endpoint(service, region_id.lower())
32
59
  return OpenApiClient(config)
33
60
 
34
61
 
62
+ # 类型为String的JSON数组参数
63
+ ECS_LIST_PARAMETERS = {
64
+ 'HpcClusterIds', 'DedicatedHostClusterIds', 'DedicatedHostIds',
65
+ 'InstanceIds', 'DeploymentSetIds', 'KeyPairNames', 'SecurityGroupIds',
66
+ 'diskIds', 'repeatWeekdays', 'timePoints', 'DiskIds', 'SnapshotLinkIds',
67
+ 'EipAddresses', 'PublicIpAddresses', 'PrivateIpAddresses'
68
+ }
69
+
70
+
35
71
  def _tools_api_call(service: str, api: str, parameters: dict, ctx: Context):
36
72
  service = service.lower()
37
73
  api_meta, _ = ApiMetaClient.get_api_meta(service, api)
@@ -39,8 +75,16 @@ def _tools_api_call(service: str, api: str, parameters: dict, ctx: Context):
39
75
  method = 'POST' if api_meta.get('methods', [])[0] == 'post' else 'GET'
40
76
  path = api_meta.get('path', '/')
41
77
  style = ApiMetaClient.get_service_style(service)
78
+
79
+ # 处理特殊参数格式
80
+ processed_parameters = parameters.copy()
81
+ if service == 'ecs':
82
+ for param_name, param_value in parameters.items():
83
+ if param_name in ECS_LIST_PARAMETERS and isinstance(param_value, list):
84
+ processed_parameters[param_name] = json.dumps(param_value)
85
+
42
86
  req = open_api_models.OpenApiRequest(
43
- query=OpenApiUtilClient.query(parameters)
87
+ query=OpenApiUtilClient.query(processed_parameters)
44
88
  )
45
89
  params = open_api_models.Params(
46
90
  action=api,
@@ -53,7 +97,7 @@ def _tools_api_call(service: str, api: str, parameters: dict, ctx: Context):
53
97
  req_body_type='formData',
54
98
  body_type='json'
55
99
  )
56
- client = create_client(service, parameters.get('RegionId', 'cn-hangzhou'))
100
+ client = create_client(service, processed_parameters.get('RegionId', 'cn-hangzhou'))
57
101
  runtime = util_models.RuntimeOptions()
58
102
  return client.call_api(params, req, runtime)
59
103
 
@@ -75,9 +119,15 @@ def _create_function_schemas(service, api, api_meta):
75
119
  description = schema.get('description', '')
76
120
  example = schema.get('example', '')
77
121
  type_ = schema.get('type', '')
78
- description = f'{description} 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: {type_},参数示例:{example}'
122
+ description = f'{description} 参数类型: {type_},参数示例:{example}'
79
123
  required = schema.get('required', False)
80
- python_type = type_map.get(type_, str)
124
+
125
+ # 只有在service为ecs时,才对特定参数进行特殊处理
126
+ if service.lower() == 'ecs' and name in ECS_LIST_PARAMETERS and type_ == 'string':
127
+ python_type = list
128
+ else:
129
+ python_type = type_map.get(type_, str)
130
+
81
131
  field_info = (
82
132
  python_type,
83
133
  field(
@@ -90,14 +140,14 @@ def _create_function_schemas(service, api, api_meta):
90
140
  schemas[api]['RegionId'] = (
91
141
  str,
92
142
  field(
93
- default=None,
143
+ default='cn-hangzhou',
94
144
  metadata={'description': '地域ID', 'required': False}
95
145
  )
96
146
  )
97
147
  return schemas
98
148
 
99
149
 
100
- def _create_tool_function_with_signature(service: str, function_name: str, fields: dict, description: str):
150
+ def _create_tool_function_with_signature(service: str, api: str, fields: dict, description: str):
101
151
  """
102
152
  Dynamically creates a lambda function with a custom signature based on the provided fields.
103
153
  """
@@ -121,14 +171,14 @@ def _create_tool_function_with_signature(service: str, function_name: str, field
121
171
  defaults[name] = field_default
122
172
 
123
173
  signature = inspect.Signature(parameters)
124
-
174
+ function_name = f'{service.upper()}_{api}'
125
175
  def func_code(*args, **kwargs):
126
176
  bound_args = signature.bind(*args, **kwargs)
127
177
  bound_args.apply_defaults()
128
178
 
129
179
  return _tools_api_call(
130
180
  service=service,
131
- api=function_name,
181
+ api=api,
132
182
  parameters=bound_args.arguments,
133
183
  ctx=None
134
184
  )
@@ -154,7 +204,8 @@ def _create_and_decorate_tool(mcp: FastMCP, service: str, api: str):
154
204
  fields = _create_function_schemas(service, api, api_meta).get(api, {})
155
205
  description = api_meta.get('summary', '')
156
206
  dynamic_lambda = _create_tool_function_with_signature(service, api, fields, description)
157
- decorated_function = mcp.tool(name=api)(dynamic_lambda)
207
+ function_name = f'{service.upper()}_{api}'
208
+ decorated_function = mcp.tool(name=function_name)(dynamic_lambda)
158
209
 
159
210
  return decorated_function
160
211
 
@@ -36,7 +36,7 @@ def _get_cms_metric_data(region_id: str, instance_ids: List[str], metric_name: s
36
36
  return describe_metric_last_resp.body.datapoints
37
37
 
38
38
  @tools.append
39
- def GetCpuUsageData(
39
+ def CMS_GetCpuUsageData(
40
40
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
41
41
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
42
42
  ):
@@ -45,7 +45,7 @@ def GetCpuUsageData(
45
45
 
46
46
 
47
47
  @tools.append
48
- def GetCpuLoadavgData(
48
+ def CMS_GetCpuLoadavgData(
49
49
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
50
50
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
51
51
  ):
@@ -54,7 +54,7 @@ def GetCpuLoadavgData(
54
54
 
55
55
 
56
56
  @tools.append
57
- def GetCpuloadavg5mData(
57
+ def CMS_GetCpuloadavg5mData(
58
58
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
59
59
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
60
60
  ):
@@ -63,7 +63,7 @@ def GetCpuloadavg5mData(
63
63
 
64
64
 
65
65
  @tools.append
66
- def GetCpuloadavg15mData(
66
+ def CMS_GetCpuloadavg15mData(
67
67
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
68
68
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
69
69
  ):
@@ -71,7 +71,7 @@ def GetCpuloadavg15mData(
71
71
  return _get_cms_metric_data(RegionId, InstanceIds, 'load_15m')
72
72
 
73
73
  @tools.append
74
- def GetMemUsedData(
74
+ def CMS_GetMemUsedData(
75
75
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
76
76
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
77
77
  ):
@@ -80,7 +80,7 @@ def GetMemUsedData(
80
80
 
81
81
 
82
82
  @tools.append
83
- def GetMemUsageData(
83
+ def CMS_GetMemUsageData(
84
84
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
85
85
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
86
86
  ):
@@ -89,7 +89,7 @@ def GetMemUsageData(
89
89
 
90
90
 
91
91
  @tools.append
92
- def GetDiskUsageData(
92
+ def CMS_GetDiskUsageData(
93
93
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
94
94
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
95
95
  ):
@@ -98,7 +98,7 @@ def GetDiskUsageData(
98
98
 
99
99
 
100
100
  @tools.append
101
- def GetDiskTotalData(
101
+ def CMS_GetDiskTotalData(
102
102
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
103
103
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
104
104
  ):
@@ -107,7 +107,7 @@ def GetDiskTotalData(
107
107
 
108
108
 
109
109
  @tools.append
110
- def GetDiskUsedData(
110
+ def CMS_GetDiskUsedData(
111
111
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
112
112
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
113
113
  ):
@@ -0,0 +1,74 @@
1
+ import logging
2
+ import os
3
+ from pydantic import Field
4
+ from alibabacloud_tea_openapi import models as open_api_models
5
+ from alibabacloud_tea_util import models as util_models
6
+ from alibabacloud_tea_openapi.client import Client as OpenApiClient
7
+ from alibabacloud_openapi_util.client import Client as OpenApiUtilClient
8
+ from alibaba_cloud_ops_mcp_server.alibabacloud.api_meta_client import ApiMetaClient
9
+ from alibaba_cloud_ops_mcp_server.alibabacloud.static import PROMPT_UNDERSTANDING
10
+ from alibaba_cloud_ops_mcp_server.tools.api_tools import create_client, _tools_api_call
11
+
12
+ END_STATUSES = ['Success', 'Failed', 'Cancelled']
13
+
14
+ tools = []
15
+
16
+ _CUSTOM_SERVICE_LIST = None
17
+
18
+ logger = logging.getLogger(__name__)
19
+
20
+
21
+ def set_custom_service_list(service_list):
22
+ global _CUSTOM_SERVICE_LIST
23
+ _CUSTOM_SERVICE_LIST = service_list
24
+
25
+
26
+ @tools.append
27
+ def PromptUnderstanding() -> str:
28
+ """
29
+ Always use this tool first to understand the user's query and convert it into suggestions from Alibaba Cloud experts.
30
+ """
31
+ global _CUSTOM_SERVICE_LIST
32
+
33
+ content = PROMPT_UNDERSTANDING
34
+ if _CUSTOM_SERVICE_LIST:
35
+ import re
36
+ pattern = r'Supported Services\s*:\s*\n(?:\s{3}- .+?\n)+'
37
+ replacement = f"Supported Services:\n - " + "\n - ".join([f"{k}: {v}" for k, v in _CUSTOM_SERVICE_LIST])
38
+ content = re.sub(pattern, replacement, content, flags=re.DOTALL)
39
+
40
+ return content
41
+
42
+
43
+ @tools.append
44
+ def ListAPIs(
45
+ service: str = Field(description='AlibabaCloud service code')
46
+ ):
47
+ """
48
+ Use PromptUnderstanding tool first to understand the user's query, Get the corresponding API list information through the service name to prepare for the subsequent selection of the appropriate API to call
49
+ """
50
+ return ApiMetaClient.get_apis_in_service(service)
51
+
52
+
53
+ @tools.append
54
+ def GetAPIInfo(
55
+ service: str = Field(description='AlibabaCloud service code'),
56
+ api: str = Field(description='AlibabaCloud api name'),
57
+ ):
58
+ """
59
+ Use PromptUnderstanding tool first to understand the user's query, After specifying the service name and API name, get the detailed API META of the corresponding API
60
+ """
61
+ data, version = ApiMetaClient.get_api_meta(service, api)
62
+ return data.get('parameters')
63
+
64
+
65
+ @tools.append
66
+ def CommonAPICaller(
67
+ service: str = Field(description='AlibabaCloud service code'),
68
+ api: str = Field(description='AlibabaCloud api name'),
69
+ parameters: dict = Field(description='AlibabaCloud ECS instance ID List', default={}),
70
+ ):
71
+ """
72
+ Use PromptUnderstanding tool first to understand the user's query, Perform the actual call by specifying the Service, API, and Parameters
73
+ """
74
+ return _tools_api_call(service, api, parameters, None)
@@ -46,7 +46,7 @@ def _start_execution_sync(region_id: str, template_name: str, parameters: dict):
46
46
  return list_executions_resp.body
47
47
  time.sleep(1)
48
48
  @tools.append
49
- def RunCommand(
49
+ def OOS_RunCommand(
50
50
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
51
51
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
52
52
  CommandType: str = Field(description='The type of command executed on the ECS instance, optional value:RunShellScript,RunPythonScript,RunPerlScript,RunBatScript,RunPowerShellScript', default='RunShellScript'),
@@ -73,7 +73,7 @@ def RunCommand(
73
73
 
74
74
 
75
75
  @tools.append
76
- def StartInstances(
76
+ def OOS_StartInstances(
77
77
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
78
78
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
79
79
  ):
@@ -92,7 +92,7 @@ def StartInstances(
92
92
 
93
93
 
94
94
  @tools.append
95
- def StopInstances(
95
+ def OOS_StopInstances(
96
96
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
97
97
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
98
98
  ForeceStop: bool = Field(description='Is forced shutdown required', default=False),
@@ -113,7 +113,7 @@ def StopInstances(
113
113
 
114
114
 
115
115
  @tools.append
116
- def RebootInstances(
116
+ def OOS_RebootInstances(
117
117
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
118
118
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
119
119
  ForeceStop: bool = Field(description='Is forced shutdown required', default=False),
@@ -134,7 +134,7 @@ def RebootInstances(
134
134
 
135
135
 
136
136
  @tools.append
137
- def RunInstances(
137
+ def OOS_RunInstances(
138
138
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
139
139
  ImageId: str = Field(description='Image ID'),
140
140
  InstanceType: str = Field(description='Instance Type'),
@@ -157,7 +157,7 @@ def RunInstances(
157
157
 
158
158
 
159
159
  @tools.append
160
- def ResetPassword(
160
+ def OOS_ResetPassword(
161
161
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
162
162
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
163
163
  Password: str = Field(description='The password of the ECS instance must be 8-30 characters and must contain only the following characters: lowercase letters, uppercase letters, numbers, and special characters only.()~!@#$%^&*-_+=(40:<>,?/'),
@@ -176,7 +176,7 @@ def ResetPassword(
176
176
  return _start_execution_sync(region_id=RegionId, template_name='ACS-ECS-BulkyResetPassword', parameters=parameters)
177
177
 
178
178
  @tools.append
179
- def ReplaceSystemDisk(
179
+ def OOS_ReplaceSystemDisk(
180
180
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
181
181
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
182
182
  ImageId: str = Field(description='Image ID')
@@ -196,7 +196,7 @@ def ReplaceSystemDisk(
196
196
 
197
197
 
198
198
  @tools.append
199
- def StartRDSInstances(
199
+ def OOS_StartRDSInstances(
200
200
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
201
201
  InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
202
202
  ):
@@ -215,7 +215,7 @@ def StartRDSInstances(
215
215
 
216
216
 
217
217
  @tools.append
218
- def StopRDSInstances(
218
+ def OOS_StopRDSInstances(
219
219
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
220
220
  InstanceIds: List[str] = Field(description='AlibabaCloud RDS instance ID List')
221
221
  ):
@@ -234,7 +234,7 @@ def StopRDSInstances(
234
234
 
235
235
 
236
236
  @tools.append
237
- def RebootRDSInstances(
237
+ def OOS_RebootRDSInstances(
238
238
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
239
239
  InstanceIds: List[str] = Field(description='AlibabaCloud RDS instance ID List')
240
240
  ):
@@ -35,7 +35,7 @@ def create_client(region_id: str) -> oss.Client:
35
35
 
36
36
 
37
37
  @tools.append
38
- def ListBuckets(
38
+ def OSS_ListBuckets(
39
39
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
40
40
  Prefix: str = Field(description='AlibabaCloud OSS Bucket Name prefix', default=None)
41
41
  ):
@@ -50,7 +50,7 @@ def ListBuckets(
50
50
 
51
51
 
52
52
  @tools.append
53
- def ListObjects(
53
+ def OSS_ListObjects(
54
54
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
55
55
  BucketName: str = Field(description='AlibabaCloud OSS Bucket Name'),
56
56
  Prefix: str = Field(description='AlibabaCloud OSS Bucket Name prefix', default=None)
@@ -71,7 +71,7 @@ def ListObjects(
71
71
 
72
72
 
73
73
  @tools.append
74
- def PutBucket(
74
+ def OSS_PutBucket(
75
75
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
76
76
  BucketName: str = Field(description='AlibabaCloud OSS Bucket Name'),
77
77
  StorageClass: str = Field(description='The Storage Type of AlibabaCloud OSS Bucket, The value range is as follows: '
@@ -99,7 +99,7 @@ def PutBucket(
99
99
 
100
100
 
101
101
  @tools.append
102
- def DeleteBucket(
102
+ def OSS_DeleteBucket(
103
103
  RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
104
104
  BucketName: str = Field(description='AlibabaCloud OSS Bucket Name')
105
105
  ):
@@ -1,16 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alibaba-cloud-ops-mcp-server
3
- Version: 0.8.5
3
+ Version: 0.9.0
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
7
7
  Requires-Python: >=3.10
8
8
  Requires-Dist: alibabacloud-cms20190101>=3.1.4
9
+ Requires-Dist: alibabacloud-credentials>=1.0.0
9
10
  Requires-Dist: alibabacloud-ecs20140526>=6.1.0
10
11
  Requires-Dist: alibabacloud-oos20190601>=3.4.1
11
12
  Requires-Dist: alibabacloud-oss-v2>=1.1.0
12
13
  Requires-Dist: click>=8.1.8
13
- Requires-Dist: mcp[cli]>=1.6.0
14
+ Requires-Dist: mcp[cli]>=1.9.0
14
15
  Description-Content-Type: text/markdown
15
16
 
16
17
  # Alibaba Cloud Ops MCP Server
@@ -54,19 +55,24 @@ To use `alibaba-cloud-ops-mcp-server` MCP Server with any other MCP Client, you
54
55
  }
55
56
  ```
56
57
 
58
+ [For detailed parameter description, see MCP startup parameter document](./README_mcp_args.md)
59
+
57
60
  ## MCP Maketplace Integration
58
61
 
59
62
  * [Cline](https://cline.bot/mcp-marketplace)
63
+ * [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)
60
64
  * [ModelScope](https://www.modelscope.cn/mcp/servers/@aliyun/alibaba-cloud-ops-mcp-server?lang=en_US)
61
65
  * [Lingma](https://lingma.aliyun.com/)
62
66
  * [Smithery AI](https://smithery.ai/server/@aliyun/alibaba-cloud-ops-mcp-server)
63
67
  * [FC-Function AI](https://cap.console.aliyun.com/template-detail?template=237)
68
+ * [Alibaba Cloud Model Studio](https://bailian.console.aliyun.com/?tab=mcp#/mcp-market/detail/alibaba-cloud-ops)
64
69
 
65
70
  ## Know More
66
71
 
67
- * [Alibaba Cloud MCP Server is ready to use out of the box!!](https://developer.aliyun.com/article/1661348)
68
- * [Setup Alibaba Cloud MCP Server on Bailian](https://developer.aliyun.com/article/1662120)
72
+ * [Alibaba Cloud Ops MCP Server is ready to use out of the box!!](https://developer.aliyun.com/article/1661348)
73
+ * [Setup Alibaba Cloud Ops MCP Server on Bailian](https://developer.aliyun.com/article/1662120)
69
74
  * [Build your own Alibaba Cloud OpenAPI MCP Server with 10 lines of code](https://developer.aliyun.com/article/1662202)
75
+ * [Alibaba Cloud Ops MCP Server is officially available on the Alibaba Cloud Model Studio Platform MCP Marketplace](https://developer.aliyun.com/article/1665019)
70
76
 
71
77
  ## Tools
72
78
 
@@ -0,0 +1,20 @@
1
+ alibaba_cloud_ops_mcp_server/__init__.py,sha256=BaluUNyRz8Qw-X7Y0ywDezwbkqiSvWlSYn2452XeGcA,213
2
+ alibaba_cloud_ops_mcp_server/config.py,sha256=Nq6AT8bqSVa6zu9xjInaSjFcxA-GC7MLlCsV1q53yO0,514
3
+ alibaba_cloud_ops_mcp_server/server.py,sha256=tvRVQi1d7oPc-OsBHf6Za1Qht_bhNm2nf4B2aQ84Fyw,2246
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=t2TSc0Gzcy_uEcaCgiHHuLoMiEGu3-NCtYmwYjyPWsY,7973
6
+ alibaba_cloud_ops_mcp_server/alibabacloud/exception.py,sha256=7PdhgqgXEGrTPL1cj98h9EH-RrM6-2TT89PDtcmlpmU,1230
7
+ alibaba_cloud_ops_mcp_server/alibabacloud/utils.py,sha256=jWQtP59P4ejh7N6xiYSDq1WgCd3Les0aSZr2pLGzkls,299
8
+ alibaba_cloud_ops_mcp_server/alibabacloud/static/PROMPT_UNDERSTANDING.md,sha256=494HcCQQCc_iqDrRKhk7eWXB4I0dMtqCseT78KphDHg,3553
9
+ alibaba_cloud_ops_mcp_server/alibabacloud/static/__init__.py,sha256=wJrYamaIb7e_kA4ILZpdP1f1TUUTXMGqEhA4IbSZ2Ts,230
10
+ alibaba_cloud_ops_mcp_server/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ alibaba_cloud_ops_mcp_server/tools/api_tools.py,sha256=G3IsVOuvOGFupteJmESJowlbGGj2po2uJpcx53gzvRA,7702
12
+ alibaba_cloud_ops_mcp_server/tools/cms_tools.py,sha256=GFSBDTddvQ7M9fDGm69jvH6Yt4nui5uOVjwD61CZKT4,4191
13
+ alibaba_cloud_ops_mcp_server/tools/common_api_tools.py,sha256=ccQAWqS1I9F-fdOdjLcXN-dIhNqSbZV8T5ODuGXlfXM,2711
14
+ alibaba_cloud_ops_mcp_server/tools/oos_tools.py,sha256=l228yl_SGg_rNdrBSDeqWYI8ZE1XUAHhsPLArvfE4A8,10116
15
+ alibaba_cloud_ops_mcp_server/tools/oss_tools.py,sha256=c7D1fAjFBqHl0oMy0O6i7onoXeAN9cpdBdLtXKrxVQE,4615
16
+ alibaba_cloud_ops_mcp_server-0.9.0.dist-info/METADATA,sha256=uDR__noYnkGhBgvSiLicUYGUAdUOwshyTKlCz5WNenM,5966
17
+ alibaba_cloud_ops_mcp_server-0.9.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ alibaba_cloud_ops_mcp_server-0.9.0.dist-info/entry_points.txt,sha256=ESGAWXKEp184forhs7VzTD4P1AUdZz6vCW6hRUKITGw,83
19
+ alibaba_cloud_ops_mcp_server-0.9.0.dist-info/licenses/LICENSE,sha256=gQgVkp2ttRCjodiPpXZZR-d7JnrYIYNiHk1YDUYgpa4,11331
20
+ alibaba_cloud_ops_mcp_server-0.9.0.dist-info/RECORD,,
@@ -1,17 +0,0 @@
1
- alibaba_cloud_ops_mcp_server/__init__.py,sha256=BaluUNyRz8Qw-X7Y0ywDezwbkqiSvWlSYn2452XeGcA,213
2
- alibaba_cloud_ops_mcp_server/config.py,sha256=Nq6AT8bqSVa6zu9xjInaSjFcxA-GC7MLlCsV1q53yO0,514
3
- alibaba_cloud_ops_mcp_server/server.py,sha256=23NqZsE8JFQm9xffK-w2aScRXAZNnhgLs1wPG9fzHyI,1032
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
6
- alibaba_cloud_ops_mcp_server/alibabacloud/exception.py,sha256=7PdhgqgXEGrTPL1cj98h9EH-RrM6-2TT89PDtcmlpmU,1230
7
- alibaba_cloud_ops_mcp_server/alibabacloud/utils.py,sha256=jWQtP59P4ejh7N6xiYSDq1WgCd3Les0aSZr2pLGzkls,299
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=lydogpHEYgqzLAgUP4szBy-67z7lWXiqwUaTvt_IQVM,5807
10
- alibaba_cloud_ops_mcp_server/tools/cms_tools.py,sha256=t70H7MnYo0cuIY00_6V3cGz2btSRtJFm8qW8WWwzyCc,4155
11
- alibaba_cloud_ops_mcp_server/tools/oos_tools.py,sha256=-e7ikaf708vAueOUFoWp3xMbpaj6JUGaB1KbK-YniV8,10076
12
- alibaba_cloud_ops_mcp_server/tools/oss_tools.py,sha256=IJDcs4BvPgF5A85oBZJ5xrJDSim_fCzRaxnCHjd0hvw,4599
13
- alibaba_cloud_ops_mcp_server-0.8.5.dist-info/METADATA,sha256=OXzSM42BSBX5eh0BjtYhO7fCq9V0pbhLSR52WyS7BFE,5100
14
- alibaba_cloud_ops_mcp_server-0.8.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- alibaba_cloud_ops_mcp_server-0.8.5.dist-info/entry_points.txt,sha256=ESGAWXKEp184forhs7VzTD4P1AUdZz6vCW6hRUKITGw,83
16
- alibaba_cloud_ops_mcp_server-0.8.5.dist-info/licenses/LICENSE,sha256=gQgVkp2ttRCjodiPpXZZR-d7JnrYIYNiHk1YDUYgpa4,11331
17
- alibaba_cloud_ops_mcp_server-0.8.5.dist-info/RECORD,,