Rancher Mcp

io.github.rex由 GitHub 帳號 rex 發布v1.59.0更新於 Oct 24, 2026

Capability-aware MCP server for Rancher-managed Kubernetes: discovery, resources, workflows.

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理透過 Rancher 的 Norman 與 Steve API 檢視並在受保護的前提下變更 Rancher 代管的 Kubernetes 叢集。

可以做什麼
探索 Rancher 執行個體支援的能力:伺服器版本、API schema 與能力領域,支援多執行個體,且每個工具都可指定執行個體。透過涵蓋兩個 API 平面的通用引擎讀取與操作任意資源,包括增刪改查、動作、連結與 watch。依約 25 個領域讀取結構化資料,例如 Pod、Deployment、儲存、網路、RBAC、監控、政策報告與 Longhorn。執行受保護的寫入操作,例如擴縮或重啟 Deployment、暫停 CronJob、封鎖節點、建立 Secret。提供一鍵維運彙總用於排查,例如叢集健康檢查、失敗 Pod、停滯的滾動部署與專案健康摘要。
適用情境
當助理需要檢視或操作 Rancher 代管的 Kubernetes 叢集,尤其是同時管理多個執行個體,並且希望具備稽核日誌、限流、唯讀執行個體標記與刪除時的確認詞,而非直接使用 kubectl 時,適合採用。
執行需求
以 Python 套件形式透過 stdio 在本機執行(需要 Python 3.12+ 與 uv,以 uvx 啟動)。需要 RANCHER_URL 中的 Rancher 伺服器位址與 RANCHER_TOKEN 中的 API 權杖,或在 RANCHER_INSTANCES_JSON 中提供多執行個體 JSON 設定。TLS 驗證由 RANCHER_VERIFY_SSL 控制,預設開啟。需要能連線至 Rancher 伺服器的網路。
安裝前請注意
RANCHER_TOKEN 或 RANCHER_INSTANCES_JSON 中的 API 權杖可存取你的叢集,請妥善保管。伺服器提供 28 個寫入工具與 5 個破壞性工具,助理可能修改或刪除叢集資源;刪除需要輸入確認詞,標記為 read_only 的執行個體會拒絕所有變更。精選回應中的 Secret 值與憑證私鑰會被遮蔽,但可透過通用工具的明確選項揭露。關閉 TLS 驗證會降低連線安全性。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Rancher Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[MCP Rancher — the capability-aware control plane for AI-assisted Rancher operations]

[CI] [MCP server] [206 tools] [Python 3.12+] [Pyright strict] [MIT license]

Operate Rancher-managed Kubernetes through any MCP client — discovery, generic resource access, and curated operator workflows, wrapped in an audit-logged, rate-limited, confirmation-guarded safety model.

Quick start · Tool surface · Architecture · Safety model · Compatibility · Development


Why this exists

Rancher is how real fleets run Kubernetes — and it speaks two APIs (the legacy Norman /v3 plane and the modern Steve /v1 plane), varies by version, and wraps every cluster behind its own proxy. Pointing a generic Kubernetes MCP server at it misses everything Rancher-specific; pointing an agent at raw kubectl gives up auditability, guardrails, and the management-plane view entirely.

MCP Rancher is built for that reality:

  • Capability-aware, not version-naive. It detects what each connected Rancher actually supports instead of assuming. One binary spans 2.6.5 → 2.9.3 with the same tool surface.
  • Multi-instance first. Lab, staging, prod — configure them all; mark prod read_only: true and every mutation is refused at the config layer, before any guard even has to fire.
  • Nothing is out of reach. Curated tools cover the common 95%; the generic engine reaches every resource either API plane exposes — even types nobody wrote a tool for yet.

The tool surface

206 tools: 178 read-only · 28 writes · 5 destructive — counted from the registry itself, not by hand. docs/tool-manifest.json is generated from the live FastMCP registry (make tool-manifest) and a CI gate fails the build if it ever drifts from the code. Per-tool descriptions, safety annotations, and parameters all live there; the narrative registry with slice tracking is docs/tool-catalog.md.

LayerWhat it doesExamples
Discovery & schemaExplore what any instance can dorancher_server_version, rancher_norman_schema_list, rancher_capability_domain_list
Generic engineCRUD + actions + links + watch on any resource, both planesrancher_steve_resource_list, rancher_norman_resource_action_invoke, rancher_steve_resource_watch
Curated readsTyped, shaped responses across ~25 domainsrancher_pods_list, rancher_deployments_list, rancher_longhorn_volumes_list, rancher_policy_reports_list
Curated writesGuarded mutationsrancher_deployment_scale, rancher_deployment_restart, rancher_cron_job_suspend, rancher_node_cordon, rancher_secret_create
Operator rollupsOne-call triagerancher_cluster_health_check, rancher_find_failing_pods, rancher_find_stalled_rollouts, rancher_project_health_summary

Domains covered: clusters & nodes · projects & namespaces · workloads · pods & services · storage · networking · config & secrets (values masked) · certificates (keys masked) · RBAC · auth & identity · apps & catalogs · logging pipeline · Prometheus monitoring · policy reports · CIS compliance · backup operator · etcd backups · Longhorn · Fleet · provisioning · settings & features · alerts & notifiers.

All 206 stay exposed by default — every tool schema is deferred behind Claude Code's own search, so a small default would only help other hosts at the good host's expense. A constrained host (a small local model, a tight context budget) can opt into a smaller surface via RANCHER_TOOLSETS; see Toolset profiles under Configuration.

Quick start

Requirements

Install & run

bash
# From sourcegit clone https://github.com/rex/mcp-rancher.gitcd mcp-ranchermake setup                 # deps, .env scaffold, pre-commit hookscp .env.example .env       # set RANCHER_URL + RANCHER_TOKENmake dev                   # run the MCP server (stdio)

Once published to PyPI, it's one line: uvx rancher-mcp.

Claude Code

bash
claude mcp add rancher \  -e RANCHER_URL=https://rancher.example.com \  -e RANCHER_TOKEN=token-xxxxx:yyyyyyyyy \  -- uv run --directory /path/to/mcp-rancher rancher-mcp

Claude Desktop

json
{  "mcpServers": {    "rancher": {      "command": "uv",      "args": ["run", "--directory", "/path/to/mcp-rancher", "rancher-mcp"],      "env": {        "RANCHER_URL": "https://rancher.example.com",        "RANCHER_TOKEN": "token-xxxxx:yyyyyyyyy"      }    }  }}

Multiple instances

env
RANCHER_INSTANCES_JSON='{  "production": {"url": "https://rancher.prod.example.com",    "token": "token-a:xxx", "verify_ssl": true, "read_only": true},  "lab":        {"url": "https://rancher.lab.example.com",     "token": "token-b:yyy", "verify_ssl": false, "read_only": false}}'RANCHER_DEFAULT_INSTANCE=production

Every tool takes an optional instance argument. Instances flagged read_only: true refuse all mutations at the settings layer.

Architecture

mermaid
flowchart LR    A[MCP client<br/>Claude Code · Claude Desktop · any] -- stdio --> S
    subgraph S[rancher-mcp]        direction TB        L1[Discovery & schema<br/>planes · schemas · capabilities]        L2[Generic engine<br/>any resource · both planes<br/>CRUD · actions · links · watch]        L3[Curated tools<br/>typed models · shaped output<br/>next-step hints]        G[Safety layer<br/>read-only guard · confirmation phrases<br/>audit log · rate limit · masking]        L1 --> L2 --> L3        L3 --> G        L2 --> G    end
    G -- Norman /v3 --> R1[(Rancher<br/>instance A)]    G -- Steve /v1 + k8s proxy --> R1    G -- Norman + Steve --> R2[(Rancher<br/>instance B)]

Three layers, deliberately separate: discovery tells you what an instance can do, the generic engine can touch anything it exposes, and curated tools make the common paths typed, shaped, and self-describing (every response carries suggested_next_steps). Most curated tools are generated from YAML descriptors (catalog/curated_tools/) with a drift gate — the editorial decisions live in descriptors, not boilerplate.

Safety model

Built for the day an agent is pointed at the cluster that pays your salary:

GuardBehavior
Read-only instancesread_only: true refuses every mutation for that instance, before tool logic runs
Destructive confirmationDeletes require an explicit typed phrase (e.g. "delete steve namespace foo") — no phrase, no delete
Tool annotationsEvery tool declares readOnlyHint / destructiveHint / idempotentHint, so clients can gate UX on them
Audit logEvery mutation emits a structured event="audit" record — tool, operation, plane, instance, resource, outcome. Argument names only; values never logged
Rate limitingToken-bucket on writes (default 60/min) — a runaway loop can't machine-gun your API
Secret & key maskingSecret values and certificate private keys are structurally absent from curated responses (reveal is an explicit generic-tool opt-in)
Structured errorsGuard rejections return typed error_code envelopes agents can branch on — never raw strings

Compatibility

Primary targetRancher 2.9.3 (production-validated)
Compatibility floorRancher 2.6.5 (kept green via capability detection)
API planesNorman /v3 + Steve /v1 (+ per-cluster Kubernetes proxy)
Transportstdio

Capability detection bridges version differences at runtime — no version-pinned builds, no "works on my Rancher." Both targets are exercised by the same test suite, and read paths have been validated live against both a 2.6.5 lab and a 2.9.3 production fleet (validation report).

Configuration

VariableDefaultPurpose
RANCHER_URL—Rancher server URL (single-instance mode)
RANCHER_TOKEN—API token (token-xxxxx:yyyyyyyyy)
RANCHER_VERIFY_SSLtrueTLS verification
RANCHER_INSTANCES_JSON—Multi-instance config (see above)
RANCHER_DEFAULT_INSTANCEfirst definedInstance used when a tool call names none
RANCHER_MCP_SERVER_NAMErancher-mcpServer identity announced to clients
RANCHER_MCP_SERVER_DESCRIPTIONbuilt-inServer description announced to clients
RANCHER_MCP_WRITE_RATE_LIMIT_PER_MIN60Write rate limit (0 disables)
RANCHER_TOOLSETSallComma-separated toolset profile(s) exposed at startup — see below
RANCHER_TOOLS—Comma-separated tool names force-included on top of the selected profile(s)
RANCHER_EXCLUDE_TOOLS—Comma-separated tool names removed, applied last — always wins over RANCHER_TOOLS

Toolset profiles

The default is all: every tool stays exposed. Claude Code, the primary host, defers every tool schema behind its own search, so a small default would only help other hosts at the cost of making the good host worse — this is a deliberate choice, not an oversight.

RANCHER_TOOLSETS opts a constrained host (a small local model, or a context budget) into a smaller surface. Values are either a family name — one per src/rancher_mcp/tools/ module (storage, workloads, pods_services, rbac, …; see rancher_mcp.toolsets.FAMILY_REGISTRARS for the full list) — or the cross-family core profile: a ~32-tool triage/orientation set (rancher_find_*, the health/summary rollups, core list/get pairs, and the generic rancher_{steve,norman}_resource_{list,get} escape hatches). core cuts the tools/list payload from 206 tools / ~401 KB to 32 tools / ~78 KB (~80% smaller). Profiles compose: RANCHER_TOOLSETS=core,storage gives the triage set plus everything storage-related.

env
RANCHER_TOOLSETS=core                        # small triage surfaceRANCHER_TOOLSETS=core,storage,workloads      # triage + two full familiesRANCHER_TOOLS=rancher_secret_get             # add one extra tool on topRANCHER_EXCLUDE_TOOLS=rancher_secret_create  # remove one, wins over the above

An unknown profile name fails loudly at startup rather than silently producing an empty or shrunken surface. Calling a real tool that exists but isn't in the active profile returns a structured TOOLSET_NOT_ENABLED error naming the tool, the toolset that would enable it, and the env var to set — never a bare "unknown tool", which would make a disabled tool indistinguishable from a typo.

Project status

Shipping and stable for read, triage, and guarded write operations. Honest ledger of what's beyond that:

  • Destructive workflows (node drain, etcd/backup restore, cert rotation, cluster upgrade/delete) are roadmap — deliberately staged after real-world read-path mileage. The generic engine + confirmation guard already covers these cases for operators who need them today.
  • The Alertmanager routes/silences surface needs an in-cluster API integration and is deferred.
  • The full per-version compatibility matrix (Track G) is in progress; the first live validation run covers the read matrix on both targets.

Work is tracked to the tool level: docs/tool-catalog.md (every tool has a row, every gap a slice ID) and ROADMAP.md.

Development

bash
make help               # every target, documentedmake validate           # codegen drift + manifest drift + architecture + lint + typecheck + testsmake tool-manifest      # regenerate docs/tool-manifest.json from the registrymake lab-up             # local Rancher 2.6.5 lab (kind + helm), fully scriptedmake integration-current # isolated Rancher 2.14.3 end-to-end test runmake live-read-matrix   # read-only validation probes against configured instancesmake mock-rancher       # fixture-backed mock Rancher for provider-config testing
  • Local lab — a self-contained Rancher 2.6.5 on kind with a simulated downstream cluster; repo-local kubeconfigs, never touches your machine state.
  • Current integration lab — Rancher 2.14.3 on separate Kind clusters and port 9443; run it serially with make integration-current to avoid overlapping Docker resource demand with the legacy lab.
  • Contract fixtures — sanitized captures from live Rancher committed under tests/fixtures/; respx pins the HTTP boundary in tests.
  • Codegen — curated tools are emitted from catalog/curated_tools/*.yml descriptors; make check-codegen fails on drift.
  • Gates — ruff, pyright strict, 624 tests with coverage floor, architecture line-limits, module-shape checks, secret scanning. All fail closed, all wired into pre-commit.

Stack: Python 3.12 · FastMCP · httpx · Pydantic v2 · structlog · uv

Security

See SECURITY.md for the threat model, token guidance, and how to report vulnerabilities.

License

MIT

來源:README.md,提交 1069bcb

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.59.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分