Problem
The current implementation in assets/utils/hwc_tools.py (create_api_client function) hardcodes the endpoint domain to myhuaweicloud.com based on the x-host field from OpenAPI JSON files:
def create_api_client(ak, sk, x_host, region="cn-north-4"):
endpoint = x_host
if x_host.find("com") != -1:
endpoint = f"https://{x_host}"
if endpoint.find("{region}") != -1:
endpoint = endpoint.replace("{region}", region)
This works for the public Huawei Cloud, but does not work for Huawei Cloud Stack Online (HCSO) on-premise deployments, where the API endpoints use a different domain (e.g., {service}.{region}.customer-domain.com instead of {service}.{region}.myhuaweicloud.com).
Use Case
We are running HCSO on-premise with:
- Region:
la-south-6001
- Console:
https://console.hcso.customer-domain.com
- API endpoints follow a different domain pattern than
myhuaweicloud.com
When we try to use the MCP server, it constructs URLs like https://ecs.la-south-6001.myhuaweicloud.com which are unreachable from our on-premise environment.
Proposed Solution
Add support for a custom endpoint domain via:
-
Environment variable HUAWEI_ENDPOINT_DOMAIN (highest priority):
export HUAWEI_ENDPOINT_DOMAIN="hcso.customer-domain.com"
# Result: https://ecs.la-south-6001.hcso.customer-domain.com
-
Config YAML endpoint_domain field:
service_code: ecs
transport: stdio
endpoint_domain: hcso.customer-domain.com
-
Full endpoint override HUAWEI_ENDPOINT_OVERRIDE for cases where the URL pattern is completely different:
export HUAWEI_ENDPOINT_OVERRIDE="https://ecs.custom-endpoint.com"
Implementation Sketch
In hwc_tools.py:
def create_api_client(ak, sk, x_host, region="cn-north-4"):
# Check for full endpoint override
endpoint_override = os.environ.get("HUAWEI_ENDPOINT_OVERRIDE")
if endpoint_override:
endpoint = endpoint_override
else:
endpoint = x_host
# Check for custom domain
custom_domain = os.environ.get("HUAWEI_ENDPOINT_DOMAIN")
if custom_domain and "myhuaweicloud.com" in endpoint:
endpoint = endpoint.replace("myhuaweicloud.com", custom_domain)
if endpoint.find("com") != -1 or endpoint.find(custom_domain or "") != -1:
endpoint = f"https://{endpoint}"
if endpoint.find("{region}") != -1:
endpoint = endpoint.replace("{region}", region)
# ...
In model.py, add endpoint_domain to MCPConfig:
@dataclass
class MCPConfig:
port: int
service_code: str
transport: TransportType
ak: Optional[str] = None
sk: Optional[str] = None
endpoint_domain: Optional[str] = None
Additional Context
- The
huaweicloudsdkcore SDK supports custom regions/endpoints via Region(id=region, endpoint=endpoint), so the SDK itself is compatible
- SSL verification may need to be configurable for on-premise deployments with self-signed certificates (currently hardcoded to
ignore_ssl_verification = True, which is fine)
- This would also benefit users in restricted network environments or those using Huawei Cloud through proxies
Environment
- huaweicloud-mcp-server v0.3.0
- Python 3.10+
- HCSO on-premise deployment
Problem
The current implementation in
assets/utils/hwc_tools.py(create_api_clientfunction) hardcodes the endpoint domain tomyhuaweicloud.combased on thex-hostfield from OpenAPI JSON files:This works for the public Huawei Cloud, but does not work for Huawei Cloud Stack Online (HCSO) on-premise deployments, where the API endpoints use a different domain (e.g.,
{service}.{region}.customer-domain.cominstead of{service}.{region}.myhuaweicloud.com).Use Case
We are running HCSO on-premise with:
la-south-6001https://console.hcso.customer-domain.commyhuaweicloud.comWhen we try to use the MCP server, it constructs URLs like
https://ecs.la-south-6001.myhuaweicloud.comwhich are unreachable from our on-premise environment.Proposed Solution
Add support for a custom endpoint domain via:
Environment variable
HUAWEI_ENDPOINT_DOMAIN(highest priority):Config YAML
endpoint_domainfield:Full endpoint override
HUAWEI_ENDPOINT_OVERRIDEfor cases where the URL pattern is completely different:Implementation Sketch
In
hwc_tools.py:In
model.py, addendpoint_domaintoMCPConfig:Additional Context
huaweicloudsdkcoreSDK supports custom regions/endpoints viaRegion(id=region, endpoint=endpoint), so the SDK itself is compatibleignore_ssl_verification = True, which is fine)Environment