zsvirt-mcp-server
OfficialClick on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@zsvirt-mcp-serverSearch ZStack APIs for listing VM instances and show me the parameters."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ZSvirt MCP Server
An MCP Server that enables AI to dynamically query and call ZSvirt's 2000+ APIs.
Features
API Search: Search ZStack APIs by keyword, with fuzzy matching support
API Description: Get detailed parameter descriptions for an API
API Execution: Execute ZStack APIs and return results
Metric Search: Search available monitoring metrics
Metric Data Retrieval: Get monitoring data for specified metrics
Related MCP server: CloudStack MCP Server
Installation
# 从 PyPI 安装
pip install zsvirt-mcp-server
# 或者使用 uv
uv pip install zsvirt-mcp-server💡 You can also skip installation and run it directly with
uvxorpipx run(see Usage below).
Configuration
Set the following environment variables:
export ZSTACK_API_URL="http://localhost:8080" # ZStack API 地址
export ZSTACK_ALLOW_ALL_API="false" # 是否允许写操作(可选,默认 false)
# 认证方式一:用户名密码(会自动登录获取 Session)
export ZSTACK_ACCOUNT="admin" # 账户名
export ZSTACK_PASSWORD="your-password" # 密码(明文)
# 认证方式二:直接传入 SessionID(优先级更高,设置后忽略用户名密码)
export ZSTACK_SESSION_ID="your-session-uuid" # 已有的 Session UUID
# 查询响应控制(可选)
export ZSTACK_QUERY_DEFAULT_LIMIT="50" # Query API 默认 limit(设 0 禁用)
export ZSTACK_RESPONSE_SIZE_LIMIT="65536" # 响应大小上限,字节(设 0 禁用)Authentication Methods
Method | Environment Variables | Description |
Username/Password |
| Automatically log in to obtain a Session |
Session ID |
| Use an existing Session directly (higher priority) |
💡 If both
ZSTACK_SESSION_IDand username/password are set, the Session ID takes precedence.
Security Notes
By default, only read-only APIs are allowed, including:
Query*- Query operationsGet*- Get operationsList*- List operationsDescribe*- Describe operationsCheck*- Check operationsCount*- Count operationsOther read-only operations...
To call write-operation APIs (such as CreateVmInstance, DeleteVolume, etc.), you need to set:
export ZSTACK_ALLOW_ALL_API="true"⚠️ Warning: Once write operations are enabled, the AI can perform dangerous actions such as creating, deleting, and modifying resources. Use with caution!
Query Response Control
Query APIs inject limit=50 by default to prevent pulling all data at once and overflowing the model context window. When the response exceeds 64KB, the inventories list is automatically truncated to ensure valid JSON is returned.
Environment Variable | Default | Description |
|
| Default value injected when a Query API does not specify |
|
| Response size limit (bytes); truncates when exceeded; set to |
An explicitly passed
limitwill not be overriddenWhen truncation occurs, the response includes a
_truncationfield, suggesting usinglimit/startfor pagination orfieldsto reduce returned fields
Usage
Run as an MCP Server
# 使用 uvx 直接运行(无需安装)
uvx zsvirt-mcp-server
# 或使用 pipx
pipx run zsvirt-mcp-server
# 如果已安装,直接运行
zsvirt-mcp-serverRun in SSE Mode
stdio transport is used by default. To use SSE mode, switch via command line or environment variables:
# 命令行方式
uvx zsvirt-mcp-server --transport sse --host 0.0.0.0 --port 8000
# 环境变量方式
export MCP_TRANSPORT="sse"
export MCP_HOST="0.0.0.0"
export MCP_PORT="8000"
export MCP_PATH="/sse" # 可选
uvx zsvirt-mcp-serverNote: Also compatible with
FASTMCP_HOST/FASTMCP_PORT/FASTMCP_MOUNT_PATH(FastMCP native environment variables)
Run in Streamable HTTP Mode
# 命令行方式
uvx zsvirt-mcp-server --transport streamable-http --host 0.0.0.0 --port 8000 --streamable-path /mcp
# 环境变量方式
export MCP_TRANSPORT="streamable-http"
export MCP_HOST="0.0.0.0"
export MCP_PORT="8000"
export MCP_STREAMABLE_PATH="/mcp" # 可选
uvx zsvirt-mcp-serverNote: Also compatible with
FASTMCP_STREAMABLE_HTTP_PATH
HTTP Header Authentication (Multi-Tenant Mode)
In SSE or streamable-http mode, an administrator can start a shared MCP Server, and multiple users can pass their own credentials via HTTP headers to achieve multi-tenant isolation.
Supported HTTP headers:
HTTP Header | Corresponding Environment Variable | Description |
|
| Account name |
|
| Password |
|
| Existing Session (higher priority than account/password) |
|
| ZStack management node address (can proxy multiple environments) |
Credential priority: HTTP headers > environment variables
Typical usage:
# 管理员启动共享 MCP Server
ZSTACK_ALLOW_ALL_API=false uvx zsvirt-mcp-server --transport streamable-http --host 0.0.0.0 --port 8000Users can use their own accounts by adding HTTP headers in the MCP client configuration:
{
"mcpServers": {
"zstack": {
"transport": "streamable-http",
"url": "http://mcp-server:8000/mcp",
"headers": {
"X-ZStack-Account": "user-a",
"X-ZStack-Password": "password-a",
"X-ZStack-API-URL": "http://zstack-env-1:8080"
}
}
}
}Features:
Sessions for the same account are automatically cached and reused; a new Session is not created for every request
Requests with different
X-ZStack-API-URLvalues are routed to different ZStack environmentsIn stdio mode there are no HTTP headers, so it automatically falls back to environment variable authentication, with unchanged behavior
Configure in Claude Desktop
Add the following to claude_desktop_config.json:
Option 1: Use username/password
{
"mcpServers": {
"zstack": {
"command": "uvx",
"args": ["zsvirt-mcp-server"],
"env": {
"ZSTACK_API_URL": "http://your-zstack-server:8080",
"ZSTACK_ACCOUNT": "admin",
"ZSTACK_PASSWORD": "your-password",
"ZSTACK_ALLOW_ALL_API": "false"
}
}
}
}Option 2: Use Session ID
{
"mcpServers": {
"zstack": {
"command": "uvx",
"args": ["zsvirt-mcp-server"],
"env": {
"ZSTACK_API_URL": "http://your-zstack-server:8080",
"ZSTACK_SESSION_ID": "your-session-uuid",
"ZSTACK_ALLOW_ALL_API": "false"
}
}
}
}💡 Set
ZSTACK_ALLOW_ALL_APIto"true"to enable write operations (create/delete/modify, etc.)
Available Tools
1. search_api
Search ZStack APIs by keyword.
Parameters:
keywords(list[str]): Search keywords, e.g.,["Query", "Vm"]category(str, optional): Filter by categorylimit(int, default 15): Maximum number of results
2. describe_api
Get detailed parameter descriptions for a specified API.
Parameters:
api_name(str): API name, e.g.,"QueryVmInstance"
3. execute_api
Execute a ZStack API.
Parameters:
api_name(str): API nameparameters(dict): API parameters
4. search_metric
Search available monitoring metrics.
Parameters:
keywords(list[str]): Search keywordsnamespace(str, optional): Filter by namespace (supports fuzzy matching, e.g.,vm/host)limit(int, default 20): Maximum number of resultsmatch_mode(str, defaultor): Keyword matching mode (and/or)prefer_namespaces(list[str], optional): List of namespaces to prioritize in sorting (default["ZStack/VM","ZStack/Host"])
💡 Tip: If you are unsure about the namespace, you can omit it for now; the returned results will include namespace values for you to choose from. 💡 The default
match_mode=or(union of multiple keywords); for intersection, explicitly passand. 💡 Metric names may be duplicated across namespaces; it is recommended to specifynamespaceorprefer_namespacesto ensure sorting priority.
5. get_metric_data
Get monitoring data.
Parameters:
namespace(str): Namespacemetric_name(str): Metric namestart_time(str|int, optional): Start time (ISO or Unix timestamp in seconds)end_time(str|int, optional): End time (ISO or Unix timestamp in seconds)period(int, default 60): Sampling period (seconds)labels(list[str]|dict, optional): Label filter, e.g.,["VMUuid=xxx"]or{"VMUuid":"xxx"}summary_only(bool, optional): Return only summary statistics (point count/max/min/avg/variance/stddev)
Data Volume Notes:
Estimated returned data points:
ceil((end_time - start_time) / period) * series_countseries_countis the number of distinct label combinations; multiple series may be returned iflabelsis not providedIt is recommended to shorten the time range, increase
period, or addlabelsfilters to avoid overly large output
6. get_metric_summary
Get aggregated TopN of monitoring metrics (grouped by label_key).
Parameters:
namespace(str): Namespacemetric_name(str): Metric namelabel_key(str): Label key, e.g.,VMUuid/HostUuidmetric_names(list[str], optional): Combine multiple metrics (e.g., in/out)start_time(str|int, optional): Start time (ISO or Unix timestamp in seconds)end_time(str|int, optional): End time (ISO or Unix timestamp in seconds)period(int, default 60): Sampling period (seconds)aggregate(str, default max): Aggregation method for a single metric (max/avg/sum/min)combine(str, default sum): Combination method for multiple metrics (sum/avg/max/min)threshold_op(str, optional): Threshold comparison operator (>,>=,<,<=,==,!=)threshold_value(number, optional): Threshold valuetop_n(int, default 10): Number of results to returnresolve_resource(str, optional):vmorhost, used to resolve names
Query API Condition Syntax
For Query-type APIs, the conditions parameter supports the following operators:
Operator | Meaning | Example |
| Equals |
|
| Not equals |
|
| Greater than |
|
| Greater than or equal to |
|
| Less than |
|
| Less than or equal to | |
| Fuzzy match (LIKE; |
|
| Fuzzy not match | |
| Regex match |
|
| Regex not match | |
| Is null |
|
| Is not null | |
| In list |
|
| Not in list |
|
conditions format:
{
"conditions": [
{"name": "uuid", "op": "=", "value": "xxx"},
{"name": "state", "op": "in", "value": "Running,Stopped"}
]
}Example Interaction
User asks: "Help me look up the details of the VM whose UUID starts with ae6e57a0"
The AI will:
Call
search_api(keywords=["Query", "Vm", "Instance"])Call
describe_api(api_name="QueryVmInstance")Call
execute_api(api_name="QueryVmInstance", parameters={"conditions": [{"name": "uuid", "op": "?=", "value": "ae6e57a0%"}]})
Development
# 克隆仓库
git clone https://github.com/ZSvirt/zsvirt-mcp-server/zsvirt-mcp-server.git
cd zsvirt-mcp-server
# 安装开发依赖
pip install -e ".[dev]"
# 运行测试
pytestLicense
MIT
Available Tools
6 toolsdescribe_apiA
获取指定 ZStack API 的详细参数说明
Args: api_name: API 名称,如 "QueryVmInstance"
Returns: API 的精简信息。对于 Query API,仅返回核心参数和 queryableFields。
| Name | Required | Description | Default |
|---|---|---|---|
| api_name | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
execute_apiA
执行 ZStack API
注意: 默认只允许调用只读 API(Query/Get/List 等)。 如需调用写操作 API,请设置环境变量 ZSTACK_ALLOW_ALL_API=true
Args: api_name: API 名称,如 "QueryVmInstance" parameters: API 参数字典 对于 Query API,conditions 格式为: [{"name": "字段名", "op": "操作符", "value": "值"}, ...] 分页: limit(默认 50)、start(偏移量) 字段选择: fields(减少返回数据量)
Returns: API 执行结果 (JSON 格式)
Example: execute_api( api_name="QueryVmInstance", parameters={ "conditions": [ {"name": "uuid", "op": "like", "value": "ae6e57a0%"} ] } )
| Name | Required | Description | Default |
|---|---|---|---|
| api_name | Yes | ||
| parameters | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
get_metric_dataA
获取 ZStack 监控数据
Args: namespace: 命名空间,如 "ZStack/VM", "ZStack/Host" metric_name: 指标名称,如 "CPUUsedUtilization" start_time: 开始时间(ISO 或秒级时间戳) end_time: 结束时间(ISO 或秒级时间戳) period: 采样周期(秒),默认 60 labels: 标签过滤,如 ["VMUuid=xxx"] 或 {"VMUuid":"xxx"} summary_only: 仅返回统计信息(点数/最大/最小/平均/方差/标准差)
注意: 返回数据量与时间跨度和 period 成正比。可用估算公式: 点数 ≈ ceil((end_time - start_time) / period) * series_count series_count 为不同 label 组合数量;若不传 labels,可能返回多组系列 (例如指标包含 CPUNum/VMUuid 等 label 时每个组合都会产出一组序列)。 为避免输出过大:缩短时间范围、增大 period 或增加 labels 过滤。
Returns: 监控数据点列表
| Name | Required | Description | Default |
|---|---|---|---|
| labels | No | ||
| period | No | ||
| end_time | No | ||
| namespace | Yes | ||
| start_time | No | ||
| metric_name | Yes | ||
| summary_only | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
get_metric_summaryB
获取监控指标的聚合 TopN(按 label_key 分组)
Args: namespace: 命名空间,如 "ZStack/VM", "ZStack/Host" metric_name: 指标名称,如 "CPUOccupiedByVm" label_key: 标签键,如 "VMUuid", "HostUuid" metric_names: 可选,多指标合并(如 in/out) start_time: 开始时间(ISO 或秒级时间戳) end_time: 结束时间(ISO 或秒级时间戳) period: 采样周期(秒),默认 60 aggregate: 单指标聚合方式,可选 "max"|"avg"|"sum"|"min" combine: 多指标合并方式,可选 "sum"|"avg"|"max"|"min" threshold_op: 阈值比较符,如 >,>=,<,<=,==,!= threshold_value: 阈值数值 top_n: 返回条数,默认 10 resolve_resource: 可选 "vm" 或 "host",用于解析名称
Returns: 聚合后的 TopN 列表
| Name | Required | Description | Default |
|---|---|---|---|
| top_n | No | ||
| period | No | ||
| combine | No | sum | |
| end_time | No | ||
| aggregate | No | max | |
| label_key | Yes | ||
| namespace | Yes | ||
| start_time | No | ||
| metric_name | Yes | ||
| metric_names | No | ||
| threshold_op | No | ||
| threshold_value | No | ||
| resolve_resource | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
search_apiA
根据关键词搜索 ZStack API
Args: keywords: 搜索关键词列表,如 ["Query", "Vm"] 或 ["Create", "Volume"] 支持驼峰拆分匹配,如搜索 "vm" 可以匹配 "QueryVmInstance" category: 可选,按分类过滤,如 "vm", "volume", "network" limit: 最多返回数量,默认 15
Returns: 匹配的 API 列表,包含名称、描述、分类、调用类型
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| category | No | ||
| keywords | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
search_metricA
搜索可用的 ZStack 监控指标
Args: keywords: 搜索关键词,如 ["CPU", "Usage"] 或 ["Memory"] 支持驼峰拆分匹配 namespace: 可选,按命名空间过滤(支持模糊匹配),如 "ZStack/VM", "vm", "host" limit: 最多返回数量,默认 20 match_mode: 关键词匹配模式,"and" 或 "or",默认 "or" prefer_namespaces: 优先排序的命名空间列表(默认 ["ZStack/VM","ZStack/Host"])
Returns: 匹配的监控指标列表,包含名称、描述、命名空间、可用标签
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| keywords | Yes | ||
| namespace | No | ||
| match_mode | No | or | |
| prefer_namespaces | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
v0.1.6- First observed
describe_api - First observed
execute_api - First observed
get_metric_data - First observed
get_metric_summary - First observed
search_api - First observed
search_metric
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose: search_api/describe_api/execute_api form an API discovery-to-execution pipeline, while search_metric/get_metric_data/get_metric_summary form a metrics retrieval pipeline. Even the two 'search' tools are unambiguously separated by their targets (APIs vs metrics).
All tool names follow a consistent verb_noun snake_case pattern: search_, describe_, execute_, get_. The repetition of 'search' and 'get' is intentional and predictable, with the noun disambiguating the target.
Six tools is a well-scoped count for a server focused on two complementary workflows: API introspection/execution and metric querying. Each tool earns its place without redundancy or bloat.
The API workflow is complete with search, describe, and execute, covering discovery through invocation. The metrics workflow is also complete with search, raw data retrieval, and aggregated summary, with no obvious dead ends or missing operations.
Maintenance
Related MCP Connectors
Deploy, monitor, and manage your OpenClaw AI assistants via natural language.
Query OneLens cloud-cost data in natural language: breakdowns, trends, cost centers. Read-only.
Interact with the Stitch API using natural language commands.
Search 16,000+ API operations and 95 built tools by need, then call any of them by name
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables AI assistants to manage multi-cloud resources (AWS, Azure, GCP) including resource operations, cost analysis, monitoring metrics, and security compliance checks through natural language commands.267 npm2MIT
- AlicenseNot gradedqualityDmaintenanceEnables comprehensive management of CloudStack infrastructure through natural language, providing access to over 735 API methods for virtual machines, networking, and storage. It features enterprise-grade security with a safety confirmation system for destructive operations and extensive API coverage.Creative Commons Attribution Non Commercial Share Alike 4.0 International

PlugLayer MCP Serverofficial
AlicenseCqualityBmaintenanceEnables deploying and managing infrastructure via natural language, including project/domain management, compute nodes, image deployment, and CI/CD integration.70MIT
ZStack MCP Serverofficial
AlicenseAqualityDmaintenanceEnables AI to dynamically search, describe, and execute 2000+ ZStack Cloud APIs, plus query monitoring metrics and data.611MIT