Rancher MCP Server 标志

Rancher MCP Server

社区
mrostamii

Model Context Protocol (MCP) server for the Rancher ecosystem: multi-cluster Kubernetes, Harvester HCI (VMs, storage, networks), and Fleet GitOps.

发布者mrostamii
代码仓库rancher-mcp-server
语言Go
复刻数
2
星标数
12
可用工具
0
传输类型stdio
分类
许可协议Apache-2.0
链接
  • 将工具接入 AI 工作流

    Rancher MCP Server 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 12 个星标和 2 个复刻。

rancher-mcp-server

GitHub License npm GitHub release (latest SemVer) Build MCP Badge

rancher-mcp-server banner

Model Context Protocol (MCP) server for the Rancher ecosystem: multi-cluster Kubernetes, Harvester HCI (VMs, storage, networks), and Fleet GitOps.

Demo

A walkthrough of how this MCP server works (example in Cursor).

https://github.com/user-attachments/assets/7d8fb814-e504-47b4-956d-28f43aeea3b8

Features

  • Harvester toolset: List/get VMs, images, volumes, networks, hosts; VM actions; addon list/switch (enable/disable)
  • Rancher toolset: Clusters and projects via Steve (management proxy); Norman management API (/v3) for schemas, users, tokens, auth configs, global role bindings, cluster registration tokens, node drivers, cloud credentials, catalogs, cluster repos, feature flags, settings, audit (when exposed); support bundle and generic actions when writes are enabled
  • Kubernetes toolset: List/get/create/patch/delete resources by apiVersion/kind; describe (resource + events), events, capacity
  • Helm toolset: List/get/history of releases; install, upgrade, rollback, uninstall; repo list
  • Fleet toolset: GitRepo list/get/create; Bundle list; Fleet cluster list; drift detection
  • Rancher APIs: Same Bearer token for Steve (/k8s/clusters/...) and Norman (/v3/...); no CLI wrappers
  • Security: Read-only default, disable-destructive, sensitive data masking (Norman token/credential fields redacted unless --show-sensitive-data)
  • Config: Flags, env (RANCHER_MCP_*), or file (YAML/TOML)

Quick start

Install

bash
npm install -g rancher-mcp-server

Cursor

Add to .cursor/mcp.json (project-level) or ~/.cursor/mcp.json (global):

json
{
  "mcpServers": {
    "rancher": {
      "command": "npx",
      "args": [
        "-y", "rancher-mcp-server",
        "--rancher-server-url", "https://rancher.example.com",
        "--rancher-token", "token-xxxxx:yyyy",
        "--toolsets", "harvester,rancher,kubernetes,fleet"
      ]
    }
  }
}

Restart Cursor after saving. Check Settings → Tools & MCP that rancher is listed and enabled.

Claude Desktop

Add to your Claude Desktop config (claude_desktop_config.json):

json
{
  "mcpServers": {
    "rancher": {
      "command": "npx",
      "args": [
        "-y", "rancher-mcp-server",
        "--rancher-server-url", "https://rancher.example.com",
        "--rancher-token", "token-xxxxx:yyyy",
        "--toolsets", "harvester,rancher,kubernetes,fleet"
      ]
    }
  }
}

With env vars instead of args

If you prefer to keep the token out of the JSON config:

json
{
  "mcpServers": {
    "rancher": {
      "command": "npx",
      "args": ["-y", "rancher-mcp-server"],
      "env": {
        "RANCHER_MCP_RANCHER_SERVER_URL": "https://rancher.example.com",
        "RANCHER_MCP_RANCHER_TOKEN": "token-xxxxx:yyyy",
        "RANCHER_MCP_TOOLSETS": "harvester,rancher,kubernetes"
      }
    }
  }
}

Enable write operations

For VM create, snapshots, backups, image/volume create, addon switch, host maintenance mode, VPC create/update/delete, Kubernetes create/patch/delete, Helm install/upgrade/rollback, Fleet gitrepo create/delete, and Norman writes (tokens, users, auth configs, role bindings, cluster registration tokens, cloud credentials, catalog refresh, feature flags, settings, rancher_norman_action, support bundle), add --read-only=false. Delete operations (Norman tokens/bindings/registration tokens/cloud credentials, plus existing toolset deletes) also require --disable-destructive=false (default).

json
{
  "mcpServers": {
    "rancher": {
      "command": "npx",
      "args": [
        "-y", "rancher-mcp-server",
        "--rancher-server-url", "https://rancher.example.com",
        "--rancher-token", "token-xxxxx:yyyy",
        "--toolsets", "harvester,rancher,kubernetes,helm,fleet",
        "--read-only=false"
      ]
    }
  }
}

Streamable HTTP transport

For web clients or remote access (e.g. Claude Code claude mcp add -t http), add --transport and --port:

json
{
  "mcpServers": {
    "rancher": {
      "command": "npx",
      "args": [
        "-y", "rancher-mcp-server",
        "--rancher-server-url", "https://rancher.example.com",
        "--rancher-token", "token-xxxxx:yyyy",
        "--transport", "http",
        "--port", "8080"
      ]
    }
  }
}

The server uses the MCP Streamable HTTP transport. The default MCP path is /mcp; connect to http://localhost:8080/mcp (or your server base URL + /mcp). Best supported with Claude Code; Cursor support may vary.

Build from source

If you prefer to build the Go binary yourself:

bash
go build -o rancher-mcp-server ./cmd/rancher-mcp-server

Then reference the binary directly in your MCP config:

json
{
  "mcpServers": {
    "rancher": {
      "command": "/absolute/path/to/rancher-mcp-server",
      "args": [
        "--rancher-server-url", "https://rancher.example.com",
        "--rancher-token", "token-xxxxx:yyyy",
        "--toolsets", "harvester,rancher,kubernetes,fleet"
      ]
    }
  }
}

Configuration

OptionEnvDefaultDescription
--rancher-server-urlRANCHER_MCP_RANCHER_SERVER_URL—Rancher server URL (required)
--rancher-tokenRANCHER_MCP_RANCHER_TOKEN—Bearer token (required)
--tls-insecureRANCHER_MCP_TLS_INSECUREfalseSkip TLS verification
--read-onlyRANCHER_MCP_READ_ONLYtrueDisable write operations
--disable-destructiveRANCHER_MCP_DISABLE_DESTRUCTIVEfalseDisable delete operations
--show-sensitive-dataRANCHER_MCP_SHOW_SENSITIVE_DATAfalseShow Norman token/credential fields without redaction (use with care)
--toolsetsRANCHER_MCP_TOOLSETSharvesterToolsets to enable: harvester, rancher, kubernetes, helm, fleet
--transportRANCHER_MCP_TRANSPORTstdioTransport: stdio or http (Streamable HTTP; default path /mcp)
--portRANCHER_MCP_PORT0Port for HTTP (0 = stdio only)

Harvester tools

ToolDescription
harvester_vm_listList VMs with status, namespace, spec/status
harvester_vm_getGet one VM (full spec and status)
harvester_vm_actionstart, stop, restart, pause, unpause, migrate
harvester_vm_createCreate VM (when not read-only). Supports network, interface_type (managedtap/bridge/masquerade), subnet for KubeOVN VPC.
harvester_vm_snapshotCreate/list/restore/delete VM snapshots
harvester_vm_backupCreate/list/restore VM backups (Backup Target)
harvester_image_listList VM images (VirtualMachineImage)
harvester_image_createCreate VM image from URL (when not read-only)
harvester_volume_listList PVCs (Longhorn-backed volumes)
harvester_volume_createCreate volume/PVC (optionally from image)
harvester_network_listList VM networks (NetworkAttachmentDefinition)
harvester_network_createCreate VM network - KubeOVN overlay or VLAN (when not read-only)
harvester_network_updateUpdate VM network config (when not read-only)
harvester_network_deleteDelete VM network (when destructive allowed)
harvester_subnet_listList KubeOVN Subnets (requires kubeovn-operator)
harvester_subnet_createCreate Subnet in VPC for VM network (when not read-only)
harvester_subnet_updateUpdate Subnet namespaces/NAT (when not read-only)
harvester_subnet_deleteDelete Subnet (when destructive allowed)
harvester_host_listList nodes (Harvester hosts)
harvester_host_actionEnable/disable maintenance mode on a host (cordon/uncordon)
harvester_settingsList or get Harvester cluster settings (backup-target, etc.)
harvester_addon_listList Harvester addons (enabled/disabled state)
harvester_addon_switchEnable or disable an addon (when not read-only)
harvester_vpc_listList KubeOVN VPCs (requires kubeovn-operator addon)
harvester_vpc_createCreate a KubeOVN VPC (when not read-only)
harvester_vpc_updateUpdate a KubeOVN VPC namespaces (when not read-only)
harvester_vpc_deleteDelete a KubeOVN VPC (when destructive allowed)

List tools accept cluster (required), namespace, format (json|table), limit (default 100), continue (pagination token for next page). Write tools require read_only: false.

Creating a VM on KubeOVN VPC with external internet

Use harvester_vm_create with:

  1. network: Name of the overlay network (NAD) linked to a KubeOVN subnet. Create via harvester_network_create (type=kubeovn) then harvester_subnet_create with provider={network}.{namespace}.ovn, vpc=<vpc-name>, and nat_outgoing=true.
  2. interface_type: managedtap (recommended for KubeOVN) or bridge. Uses Multus as primary network.
  3. subnet: Optional KubeOVN subnet name for ovn.kubernetes.io/logical_switch annotation.

Example: VM on network vswitch1 in namespace default, managedTap interface, subnet vswitch1-subnet:

harvester_vm_create cluster=<cluster-id> namespace=default name=testvm image=<image> network=vswitch1 interface_type=managedtap subnet=vswitch1-subnet

Rancher tools

Rancher tools use the management cluster (local). There is no cluster parameter on these tools.

Steve API (management resources)

ToolDescription
rancher_cluster_listList Rancher clusters (management)
rancher_cluster_getGet one cluster (health, version, node count)
rancher_project_listList Rancher projects
rancher_overviewOverview: cluster count and project count

Norman API (https://<rancher>/v3/...)

Norman tools call Rancher’s JSON management API. Discover types and collection URLs for your server with rancher_norman_schema_list / rancher_norman_schema_get (schema ids such as user, token, cluster).

Read-only (always registered with the rancher toolset)

ToolDescription
rancher_norman_schema_listList API schemas (/v3/schemas)
rancher_norman_schema_getGet one schema by id
rancher_user_list / rancher_user_getUsers
rancher_auth_config_list / rancher_auth_config_getAuth providers (local, OIDC, etc.)
rancher_token_list / rancher_token_getAPI tokens (values redacted unless --show-sensitive-data)
rancher_global_role_binding_list / rancher_global_role_binding_getGlobal role bindings
rancher_cluster_registration_token_list / rancher_cluster_registration_token_getCluster registration tokens
rancher_node_driver_listNode drivers
rancher_cloud_credential_list / rancher_cloud_credential_getCloud credentials (secrets redacted unless --show-sensitive-data)
rancher_catalog_list / rancher_catalog_getLegacy Norman catalogs (/v3/catalogs)
rancher_cluster_repo_list / rancher_cluster_repo_getApp catalog cluster repos (see note below)
rancher_feature_flag_list / rancher_feature_flag_getFeature flags (/v3/features)
rancher_setting_list / rancher_setting_getGlobal settings (/v3/settings)
rancher_audit_log_listGET /v3/auditlogs when supported (often 404/405; see note below)

When --read-only=false

ToolDescription
rancher_norman_actionPOST a Norman ?action= on a resource path under /v3
rancher_token_createCreate API token
rancher_auth_config_updateReplace an auth config (PUT)
rancher_user_createCreate user
rancher_user_disable / rancher_user_enableUser enable/disable actions
rancher_global_role_binding_createCreate global role binding
rancher_cluster_registration_token_createCreate registration token
rancher_cloud_credential_createCreate cloud credential
rancher_catalog_refreshRefresh legacy catalog (?action=refresh)
rancher_feature_flag_setUpdate feature flag (PUT)
rancher_setting_updateUpdate setting (PUT)
rancher_supportbundle_generateRequest support bundle (generateSupportBundle on a cluster)

When --read-only=false and --disable-destructive=false

ToolDescription
rancher_token_deleteDelete API token
rancher_global_role_binding_deleteDelete global role binding
rancher_cluster_registration_token_deleteDelete registration token
rancher_cloud_credential_deleteDelete cloud credential

Norman responses: catalog, cluster repos, audit

  • rancher_cluster_repo_list / rancher_cluster_repo_get: Tries Norman /v3/clusterrepos first. If that returns 404 (common), falls back to catalog.cattle.io/v1 ClusterRepo on the local cluster via Steve/Kubernetes, trying namespaces cattle-global-data, fleet-default, fleet-local, cattle-fleet-system. Success JSON includes "_source":"kubernetes_api_fallback". If nothing works, the tool still returns 200-style JSON with "_source":"unavailable" and per-attempt errors—not a hard MCP error—so automation can continue.
  • rancher_catalog_list / rancher_catalog_get: If Norman /v3/catalogs is not registered (404), returns JSON with "_source":"unavailable" instead of failing.
  • rancher_audit_log_list: If the server returns 404 or 405 (GET not supported), returns JSON with "_source":"unavailable" and _http_status; audit may be disabled or exposed outside Norman.

For catalog data when ClusterRepo is unavailable everywhere, use kubernetes_list on cluster local with api_version catalog.cattle.io/v1 and kind ClusterRepo, or Helm / Fleet tools as appropriate.

Helm tools

ToolDescription
helm_listList Helm releases (optionally by namespace, deployed/failed/pending)
helm_getGet release details (manifest, values, notes)
helm_historyGet revision history for a release
helm_repo_listList configured Helm chart repositories (from local config)
helm_installInstall a Helm chart (when not read-only)
helm_upgradeUpgrade a Helm release (when not read-only)
helm_rollbackRollback a release to a previous revision (when not read-only)
helm_uninstallUninstall a release (when destructive allowed)

All tools take cluster (Rancher cluster ID). Install/upgrade require chart, release; optional repo_url, version, values (JSON).

Fleet tools

ToolDescription
fleet_gitrepo_listList Fleet GitRepos (GitOps sources)
fleet_gitrepo_getGet one GitRepo (spec, status)
fleet_gitrepo_createCreate a GitRepo (when not read-only)
fleet_gitrepo_deleteDelete a GitRepo (when destructive allowed)
fleet_gitrepo_actionPause, unpause, disablePolling, enablePolling, forceUpdate
fleet_gitrepo_cloneClone a GitRepo to a new name (copy spec)
fleet_bundle_listList Fleet Bundles (deployment units from GitRepos)
fleet_cluster_listList Fleet clusters (downstream clusters registered with Fleet)
fleet_drift_detectReport BundleDeployments with Modified state (drift)

All tools use the Rancher management cluster (local). Optional namespace (default: fleet-default). List tools support format, limit, continue (pagination). fleet_gitrepo_create requires name, repo; optional branch, paths. fleet_gitrepo_action supports: pause, unpause, disablePolling, enablePolling, forceUpdate. fleet_gitrepo_clone copies spec from an existing GitRepo to a new name.

Kubernetes tools

ToolDescription
kubernetes_listList resources by apiVersion/kind (e.g. v1 Pod, apps/v1 Deployment)
kubernetes_getGet one resource by apiVersion, kind, namespace, name
kubernetes_describeGet resource + recent events
kubernetes_logsGet recent pod logs (tail only; container, tailLines, sinceSeconds)
kubernetes_eventsList events in a namespace (optional involvedObject filter)
kubernetes_capacityNode capacity/allocatable summary per node
kubernetes_createCreate resource from JSON (when not read-only)
kubernetes_patchPatch resource with JSON (when not read-only)
kubernetes_deleteDelete resource (when destructive allowed)

All tools take cluster (Rancher cluster ID). List/get support namespace, format (json|table), limit, continue (pagination). Create/patch/delete are gated by read_only and disable_destructive. kubernetes_logs does not support follow (streaming); use tail_lines and since_seconds to limit output. In some Rancher/proxy setups pod logs can return 503 or stream errors; see Troubleshooting.


Setup: Rancher token & Harvester cluster ID

Get a Rancher API token

  1. Log in to your Rancher UI.
  2. Click your profile/avatar (top right) → Account & API Keys (or API & Keys).
  3. Click Create API Key, name it (e.g. mcp-server), then Create.
  4. Copy the token once (format like token-abc12:xyz...). Use it as --rancher-token or RANCHER_MCP_RANCHER_TOKEN.

Find your Harvester cluster ID

Harvester tools require the cluster ID (e.g. c-tx8rn) on each call.

  • From Rancher UI: Go to Cluster Management → open your Harvester cluster. The URL contains the cluster ID: .../c/<cluster-id>/....
  • From API (Steve): curl -s -H "Authorization: Bearer YOUR_TOKEN" "https://YOUR_RANCHER_URL/k8s/clusters/local/v1/management.cattle.io.clusters" | jq '.data[] | {name: .metadata.name}'
  • Norman schemas: curl -s -H "Authorization: Bearer YOUR_TOKEN" "https://YOUR_RANCHER_URL/v3/schemas" | jq '.data[0:5].id'

Docker (Streamable HTTP)

For HTTP server mode, use the container image from GitHub Container Registry (ghcr.io). For Cursor/Claude with stdio, use npm (see Quick start).

Run the server and expose the port:

bash
docker run -d -p 8080:8080 \
  -e RANCHER_MCP_RANCHER_SERVER_URL=https://rancher.example.com \
  -e RANCHER_MCP_RANCHER_TOKEN="token-xxxxx:yyyy" \
  -e RANCHER_MCP_TRANSPORT=http \
  -e RANCHER_MCP_PORT=8080 \
  ghcr.io/mrostamii/rancher-mcp-server:latest

Connect clients to the MCP endpoint: http://localhost:8080/mcp (Streamable HTTP; default path is /mcp). Example: claude mcp add -t http rancher http://localhost:8080/mcp

Supported platforms

  • macOS (Apple Silicon & Intel)
  • Linux (x64 & ARM64)
  • Windows (x64)

Troubleshooting

IssueWhat to check
"rancher-server-url and rancher-token are required"Check --rancher-server-url and --rancher-token in args, or env vars RANCHER_MCP_RANCHER_SERVER_URL and RANCHER_MCP_RANCHER_TOKEN.
401 UnauthorizedToken expired or invalid. Create a new API key in Rancher.
TLS / certificate errorsFor self-signed Rancher, pass --tls-insecure (dev only).
"cluster not found" or empty listsWrong cluster ID. Get it from Rancher UI URL or API; pass it as cluster to Harvester/Kubernetes tools.
Cursor doesn't show toolsRestart Cursor after editing mcp.json; check Tools & MCP that the server is enabled.
Binary not foundUse absolute paths in mcp.json for command when building from source.
kubernetes_logs 503 or stream errorsKnown in some Rancher/proxied setups (e.g. RKE2). Reduce tail_lines or try another cluster; see rancher/rancher#40711.
Norman tool returns "_source":"unavailable"That collection may not exist on your Rancher version (e.g. legacy catalogs, clusterrepos, or audit via GET). Use rancher_norman_schema_list to see registered types, or kubernetes_list / Helm / Fleet for chart sources.
Cluster repo list shows unavailable or empty datacatalog.cattle.io ClusterRepo may not be installed or proxied for your token; try kubernetes_list with catalog.cattle.io/v1 and ClusterRepo on cluster local across namespaces.

License

Apache-2.0

将 Rancher MCP Server MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Rancher MCP Server 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请勿关闭终端窗口或停止其中的连接器进程。
3

将 Rancher MCP Server 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Rancher MCP Server MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "rancher-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Rancher MCP Server MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Rancher MCP Server MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Rancher MCP Server 帮我完成这项任务吗?
Rancher MCP Server
当然,我看过了。
以下是我使用 Rancher MCP Server 得到的结果。

常见问题

Rancher MCP Server MCP 服务器有什么用途?

Rancher MCP Server 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Rancher MCP Server MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您无需为每个模型单独配置 MCP 服务器,就能在 Claude、ChatGPT、Gemini 或您在 TypingMind 中配置的其他 AI 模型中使用 Rancher MCP Server。

为什么在 TypingMind 中使用 Rancher MCP Server MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是最出色的大语言模型聊天前端之一。连接 Rancher MCP Server 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Rancher MCP Server MCP 连接到 TypingMind?

Rancher MCP Server 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

Rancher MCP Server MCP 在 TypingMind 中提供哪些工具?

Rancher MCP Server 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Rancher MCP Server MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行选择模型提供商,并自行管理 API 密钥、提示词和 MCP 配置。如果 Rancher MCP Server 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇