mcp-server
mcp-server copied to clipboard
feat: unified server mode — single process for multiple services
Closes #142
Summary
Adds a unified server mode where a single process loads multiple Huawei Cloud service OpenAPI specs, drastically reducing resource usage.
Motivation
| Approach | Processes | RAM | Startup |
|---|---|---|---|
| Current (1 per service) | 13+ | ~2GB+ | Slow |
| Unified | 1 | ~200MB | Fast |
Usage
export HUAWEI_SERVICES="ecs,vpc,cce,elb,nat,evs,iam"
mcp-server-unified -t stdio
Changes
- assets/utils/unified_server.py: New
UnifiedMCPServerclass- Loads multiple OpenAPI specs based on
HUAWEI_SERVICESenv var - Prefixes tool names with service code (
ecs_ListServers,vpc_ListVpcs) - Routes
call_toolto correct OpenAPI spec based on prefix - Compatible with multi-tenant (#141)
- Graceful handling of invalid OpenAPI JSONs (skip with warning)
- Loads multiple OpenAPI specs based on
- New entry point:
mcp-server-unified - Fix: CCE OpenAPI JSON trailing comma
Backward Compatibility
Existing per-service entry points (mcp-server-ecs, etc.) are unchanged. The unified server is an additional option.
Testing
Tested with 10 services (ecs, vpc, cce, elb, nat, evs, iam, dns, lts, ces): 898 tools loaded in a single process.