Skip to main content
Glama
ssotoa70

VASTOps MCP Server

by ssotoa70

VASTOps MCP 服务器

PyPI Version Python Version License

VASTOps MCP 服务器是一个用于 VAST Data 管理任务的模型上下文协议 (MCP) 服务器。它为 AI 助手提供了与 VAST 集群交互的工具,以进行监控、列表查询和管理操作。它同时支持集群管理员和租户管理员。

功能特性

  • MCP 集成:完整的 MCP 服务器实现,用于 AI 助手集成

  • 集群管理:列出并监控 VAST 集群

  • 性能指标:检索集群对象的性能数据并生成图表

  • 动态列表函数:根据 YAML 模板自动生成 MCP 函数,供最终用户修改

  • 安全凭据:使用 keyring 进行安全密码存储

  • 只读和读写模式:控制访问级别(读写模式用于创建操作)

Related MCP server: MCP Server Kubernetes

快速入门

1. 安装

安装 vastops-mcp:

# If installed via pip
pip install vastops-mcp

2. 初始设置

配置您的 VAST 集群连接:

# If installed via pip
vastops-mcp setup


This will prompt you for:
- Cluster address (IP, FQDN, or URL like `https://host:port`)
- Username and password
- Tenant (for tenant admins)
- Tenant (for super admins - which tenant context to use)

3. 在您的 AI 助手中配置 MCP 服务器

使用 mcpsetup 获取常用 AI 助手工具的配置说明:

# create the syntax for popular ai assistances (currently has builtin support for cursor,claude-desktop,windsurf,vscode)
vastops-mcp mcpsetup vscode
🔧 Configuring MCP server for: vscode
   Detected command: vastops-mcp
   Detected args: ['mcp']

📋 VSCode Configuration Instructions
   Config file location: /Users/user/.vscode/mcp.json

    Create a new file if not exists, or add the VASTOps MCP entry to the existing 'servers' section:
    {
        "servers": {
            "VASTOps MCP": {
                "command": "vastops-mcp",
                "args": [
                    "mcp"
                ]
            }
        }
    }

📝 Next steps:
   1. Edit or create the config file at the location shown above
   2. Restart VSCode
   3. The MCP server should be available in VSCode's MCP tools
   4. Test by asking VSCode to list VAST clusters

** 添加 --read-write 标志作为第二个参数,以便能够在 VAST 集群中进行更新

提示词示例

只读模式

List all VAST clusters 
List all views on cluster cluster1
Show me all tenants across all clusters
Create bandwidth and iops graph for cluster1 over the last hour
create dataflow diagram for cluster1 for /path view on the tenant3 tenant for the last hour 
show me dataflow diagram for 172.21.224.139 on cluster1
Show me the hardware topology for cluster cluster1 
Are there any issues with my configured data protection relationships ? 
Create mini support bundle on cluster1 and name it bundle1. Timeframe should be yesterday at midnight for 4m. Generate it only for cnodes prefixed by cnode-128 and upload it to support without private data.
Find all users prefixed with "s3" on cluster cluster1 tenant tenant1
Are there any critical alerts on my clusters that were not acknoledged ?
List all snapshots for view path /data/app1 on cluster cluster1 tenant tenant1
Show me all quotas configured for tenant tenant1 on cluster cluster1
Get performance metrics for cnodes on cluster cluster1 over the last 7 day
Show me all view policies on cluster cluster1 that support S3 
First, get all available clusters. Then compare views with path "/" across all clusters, showing capcity information
Show me all tenants on cluster cluster1, for each tenant show me the 5 views with the highest used capacity
Get performance metrics for cluster cluster1, then get metrics for all cnodes, and finally get metrics for top 3 views. Show me a summary of IOPS and bandwidth for each object type
Find all views where logical used capacity is greater than 1TB. For each of these views, get their performance metrics over the last 24 hours and show which views have the highest IOPS

读写模式

Create a new NFS view on cluster cluster1 with path /data/newview in tenant tenant1
Create a view on cluster cluster1 with path /shared/data in tenant tenant1 that supports both NFS and S3 protocols
Create a snapshot named "backup-2024-01-15" for view path /data/app1 on cluster cluster1, tenant tenant1 and keep it for 24h
Create a clone from snapshot "backup-2024-01-15" of view /data/app1. The clone should be at path /data/app1-clone in tenant tenant1 on cluster cluster1
Set a hard quota of 10TB for view path /data/app1 on cluster cluster1, tenant tenant1
Create 3 new views for vmware based on template. 
Create a indestructible snapshot named resrote-point_<view name> for all vmware views on cluster1 
Refresh a clone from most recent snapshot of view /data/app1 at path /data/app1-clone in tenant tenant1 on cluster cluster1

安装

先决条件

  • Python 3.10+

  • jq:命令行 JSON 处理器(YAML 模板中的字段转换所必需)

安装 jq

macOS:

brew install jq

Linux (Ubuntu/Debian):

sudo apt-get install jq

Linux (RHEL/CentOS):

sudo yum install jq

基础安装

pip install vastops-mcp

有关完整的逐步演练(先决条件、vastops-mcp setup、集成到 Claude Desktop / Claude Code、冒烟测试),请参阅 docs/user-guide/installation.md。

CLI

您可以测试函数:

列出可用命令

vastops-mcp list
# Or
./vastops-mcp.sh list

执行动态命令

# List views
vastops-mcp list views --cluster vast3115-var

# List tenants with JSON output
vastops-mcp list tenants --format json

# List views with filters
vastops-mcp list views --cluster cluster1 --tenant mytenant

# Save output to file
vastops-mcp list views --cluster cluster1 --output views.csv --format csv

静态命令

# List clusters
vastops-mcp clusters

# List performance metrics
vastops-mcp performance --object-name tenant --cluster vast3115-var

# Query users
vastops-mcp query-users --cluster vast3115-var --prefix user

创建命令

# Create a view
vastops-mcp create view --cluster cluster1 --path /myview --protocols NFS

# Create a view from template
vastops-mcp create view-from-template --cluster cluster1 --template-name mytemplate

# Create a snapshot
vastops-mcp create snapshot --cluster cluster1 --path /myview --name mysnapshot

# Create a clone
vastops-mcp create clone --cluster cluster1 --source-path /myview --source-snapshot mysnapshot --destination-path /myclone

# Create or update quota
vastops-mcp create quota --cluster cluster1 --path /myview --hard-limit 10GB

输出格式

  • table(默认):人类可读的表格格式

  • json:JSON 输出

  • csv:CSV 格式

MCP 工具

静态列表工具

  • list_clusters_vast:检索有关 VAST 集群的信息、其状态、容量和使用情况

  • list_performance_vast:检索 VAST 集群对象的性能指标

  • query_users_vast:从 VAST 集群查询用户名

动态列表工具

额外的列表工具会自动从位于 ~/.vastops-mcp/mcp_list_cmds_template.yaml 的 YAML 模板文件中注册。这些工具遵循 list_{command_name}_vast 的命名模式。

注意:在 YAML 模板中设置了 create_mcp_tool: false 的命令将不会被注册为独立的 MCP 工具。它们仍然可以在合并命令和通过 CLI 使用,但不会出现在 MCP 工具列表中。

创建工具

当 MCP 服务器以 --read-write 启动时,可以使用以下创建工具:

  • create_view_vast:创建一个新的 VAST 视图

  • create_view_from_template_vast:从预定义模板创建视图

  • create_snapshot_vast:为 VAST 视图创建快照

  • create_clone_vast:从快照创建克隆

  • create_quota_vast:为特定路径和租户创建或更新配额

注意:创建工具始终会被注册(对 LLM 可见),但如果服务器未处于读写模式下调用,则会引发错误。

配置

  • 配置文件:~/.vastops-mcp/config.json(集群配置,无环境变量覆盖)

  • 默认模板文件:项目根目录下的 mcp_list_cmds_template.yaml(随附模板)

  • 模板修改文件:~/.vastops-mcp/mcp_list_template_modifications.yaml(用户自定义)

  • 视图模板文件:~/.vastops-mcp/view_templates.json(用于基于视图模板的创建)。此文件可以根据项目根目录下的模板示例 view_templates_example.yaml(随附模板)进行修改

  • 日志文件:~/.vastops-mcp/vastops_mcp.log

环境变量

模板文件路径

模板文件路径可以使用环境变量覆盖:

  • VASTOPS_MCP_DEFAULT_TEMPLATE_FILE:覆盖默认模板文件路径

  • VASTOPS_MCP_TEMPLATE_MODIFICATIONS_FILE:覆盖模板修改文件路径

  • VASTOPS_MCP_VIEW_TEMPLATE_FILE:覆盖视图模板文件路径

示例:

export VASTOPS_MCP_DEFAULT_TEMPLATE_FILE=/custom/path/default_template.yaml
export VASTOPS_MCP_TEMPLATE_MODIFICATIONS_FILE=/custom/path/modifications.yaml
export VASTOPS_MCP_VIEW_TEMPLATE_FILE=/custom/path/view_templates.json
vastops-mcp list views

代理配置

服务器支持 HTTP/HTTPS 和 SOCKS 代理,以便通过企业网络环境访问 VAST 集群。代理通过标准环境变量进行配置:

  • HTTPS_PROXY 或 https_proxy — 优先级最高(推荐用于 VAST,因为 API 使用 HTTPS)

  • HTTP_PROXY 或 http_proxy — 后备

  • ALL_PROXY 或 all_proxy — 全局代理,推荐用于 SOCKS 代理

绕过代理 (NO_PROXY):

使用 NO_PROXY(或 no_proxy)列出应直接连接而不通过代理的主机。用逗号分隔多个条目。通配符 * 可绕过所有主机的代理。

# Skip proxy for internal VAST clusters
export NO_PROXY=vast-cluster1.internal,10.0.0.5

HTTP/HTTPS 代理示例:

# Basic HTTP proxy
export HTTPS_PROXY=http://proxy.example.com:8080

# Proxy with authentication
export HTTPS_PROXY=http://username:password@proxy.example.com:8080

# Run commands as normal — proxy is picked up automatically
vastops-mcp clusters
vastops-mcp list views --cluster cluster1

SOCKS 代理支持:

支持 SOCKS 代理(SOCKS4、SOCKS4a、SOCKS5、SOCKS5h),但需要可选的 PySocks 库:

# Install PySocks for SOCKS proxy support
pip install 'vastops-mcp[socks]'
# — or directly —
pip install pysocks

# SOCKS5 proxy (client-side DNS resolution)
export ALL_PROXY=socks5://proxy.example.com:1080

# SOCKS5h proxy (remote DNS resolution — recommended for internal hostnames)
export ALL_PROXY=socks5h://proxy.example.com:1080

# SOCKS5 with authentication
export ALL_PROXY=socks5h://username:password@proxy.example.com:1080

# SOCKS4 proxy
export ALL_PROXY=socks4://proxy.example.com:1080

代理类型概览:

类型

描述

环境变量

依赖

HTTP/HTTPS

标准企业代理

HTTPS_PROXY / HTTP_PROXY

内置

SOCKS5

带有客户端 DNS 的 SOCKS5

ALL_PROXY

PySocks

SOCKS5h

带有远程 DNS 的 SOCKS5(推荐用于隐私)

ALL_PROXY

PySocks

SOCKS4

旧版 SOCKS4 协议

ALL_PROXY

PySocks

SOCKS4a

带有远程 DNS 的 SOCKS4

ALL_PROXY

PySocks

注意: 任何代理环境变量都适用于任何代理类型,但对 SOCKS 代理使用 ALL_PROXY 符合标准惯例,并使您的配置保持清晰。

API 白名单

API 白名单通过限制可访问的 VAST API 端点和 HTTP 方法来提供安全性。它在 YAML 模板文件的 api_whitelist 部分进行配置。

默认行为

  • 简单格式 (- views):默认为 仅 GET

  • 带方法 (- views: [post]):允许 GET + 指定方法

    • 示例:- views: [post] 为 views 端点启用 GET 和 POST

    • 示例:- quotas: [post, patch] 为 quotas 端点启用 GET、POST 和 PATCH

配置

白名单在 YAML 模板文件中定义:

api_whitelist:
  # Simple format - GET only
  - clusters
  - tenants
  
  # With methods - GET + specified methods
  - views: [post]  # GET + POST for create operations
  - snapshots: [post]  # GET + POST for create operations
  - quotas: [post, patch]  # GET + POST + PATCH for create/update operations

安全模型

  • 默认限制:如果端点不在白名单中,则会被拒绝

  • 方法验证:仅允许指定的 HTTP 方法

  • 子端点支持:如果父端点在白名单中(例如 monitors),则所有子端点均被允许(例如 monitors.ad_hoc_query)

为什么这很重要

所有 API 调用都会根据白名单进行验证。这确保了:

  • 只能访问已批准的端点

  • 只能使用已批准的 HTTP 方法

  • 创建操作需要明确的白名单配置(例如 - views: [post])

YAML 模板结构

YAML 模板文件定义了动态列表函数。有关完整文档,请参阅 TEMPLATE_STRUCTURE.md。

YAML 文件中的每个命令定义了:

  • api_endpoints:要调用的 VAST API 端点

  • per_row_endpoints(可选):为基础数据集中的每一行调用的端点,查询参数使用 $field_name 语法从行数据中派生

  • fields:带有转换(jq、单位转换、摘要)的输出字段

  • arguments:带有验证的 MCP 工具参数

  • description:MCP 上下文的工具描述

有关详细示例和最佳实践,请参阅 TEMPLATE_STRUCTURE.md。

架构

服务器使用:

  • fastmcp:MCP 服务器框架

  • vastpy:VAST API 客户端

  • template_parser:YAML 模板解析

  • command_executor:动态命令执行

  • jq:用于 JSON 转换的系统命令行工具(YAML 模板中的 jq 表达式所必需)

创建函数

服务器包含用于创建 VAST 对象的创建函数。当 MCP 服务器以 --read-write 标志启动时,这些函数可用:

  • create_view_vast:创建一个新的 VAST 视图

  • create_view_from_template_vast:从预定义模板创建视图

  • create_snapshot_vast:为 VAST 视图创建快照

  • create_clone_vast:从快照创建克隆

  • create_quota_vast:为特定路径和租户创建或更新配额

重要:创建函数要求 MCP 服务器以 --read-write 标志启动。如果在只读模式下调用,LLM 用户将收到需要读写模式的通知。

安全性:所有创建函数都使用 API 白名单,以确保只能访问允许的端点和 HTTP 方法。有关详细信息,请参阅 API 白名单 部分。

社区与支持

VASTOps MCP 服务器欢迎提问、反馈和功能请求。加入 https://community.vastdata.com/ 参与讨论。

许可证

Apache License 2.0

有关详细信息,请参阅 LICENSE 文件。

作者

Haim Marko haim.marko@vastdata.com

Related MCP Connectors

Related MCP Servers