rancher-mcp-server
Provides tools to inspect and manage Rancher-managed Kubernetes clusters, including listing clusters, nodes, projects, workloads, pods, logs, and events, as well as scaling and redeploying workloads with safety controls.
Click 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., "@rancher-mcp-server diagnose the inference-api workload in the default project"
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.
Rancher MCP Server
Servidor MCP (Model Context Protocol) que expõe clusters gerenciados pelo Rancher como ferramentas para assistentes de IA. Na prática: um copiloto de SRE. Você pergunta "por que o serviço de inferência está reiniciando?" e o assistente inspeciona clusters, workloads, pods, logs e eventos para responder.
MCP server that exposes Rancher-managed clusters as tools for AI assistants, turning Claude into an SRE copilot.
Ferramentas
Tool | Descrição | Modo |
| Clusters com estado, versão e capacidade | leitura |
| Nós com papéis, estado e recursos | leitura |
| Projetos Rancher de um cluster | leitura |
| Workloads de um projeto | leitura |
| Pods, com filtro | leitura |
| Últimas N linhas de log (inclui container anterior com | leitura |
| Eventos recentes do cluster (Warnings por padrão) | leitura |
| Diagnóstico em uma chamada: estado + pods doentes + eventos | leitura |
| Escala um workload | escrita (gated) |
| Redeploy rolling | escrita (gated) |
Related MCP server: Kubernetes MCP Server
Segurança
Somente leitura por padrão.
scale_workloaderedeploy_workloadsó funcionam comRANCHER_MCP_ALLOW_WRITE=true.Escala limitada por
RANCHER_MCP_MAX_REPLICAS(padrão 20), evitando um "scale to 5000" acidental.Credenciais apenas via variáveis de ambiente. Nada de token em arquivo de configuração ou código.
Respostas resumidas: as tools devolvem os campos que um SRE precisa, não o payload bruto da API.
Instalação
git clone https://github.com/flaviagaia/rancher-mcp-server.git
cd rancher-mcp-server
pip install -e .Crie um token de API no Rancher (avatar > Account & API Keys > Create API Key; prefira escopo por cluster) e exporte:
export RANCHER_URL="https://rancher.example.com"
export RANCHER_TOKEN="token-xxxxx:yyyyyyyyyyyy"
# opcional:
# export RANCHER_MCP_ALLOW_WRITE=true
# export RANCHER_MCP_MAX_REPLICAS=10
# export RANCHER_VERIFY_TLS=false # apenas para labs com certificado self-signedUso com Claude
Claude Code / Cowork:
claude mcp add rancher --env RANCHER_URL=$RANCHER_URL --env RANCHER_TOKEN=$RANCHER_TOKEN -- rancher-mcp-serverClaude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"rancher": {
"command": "rancher-mcp-server",
"env": {
"RANCHER_URL": "https://rancher.example.com",
"RANCHER_TOKEN": "token-xxxxx:yyyyyyyyyyyy"
}
}
}
}Exemplos de conversa:
"Liste meus clusters e me diga se algum está degradado."
"Quais pods estão em crash loop no projeto Default?"
"Diagnostique o workload deployment:ml-serving:inference-api e me mostre os logs do container que caiu."
Sem um Rancher à mão?
Suba um em um container para testar:
docker run -d --name rancher --privileged -p 8443:443 rancher/rancher:latest
# depois: export RANCHER_URL=https://localhost:8443 e RANCHER_VERIFY_TLS=falseTestes
pip install -e ".[dev]"
pytestOs testes usam um cliente mockado; não precisam de um Rancher real.
Roadmap
Métricas de uso (CPU/memória por workload) para sugestões de rightsizing
Suporte a Fleet (GitOps) e Rancher apps
Tool de comparação de estado entre clusters (staging vs prod)
Licença
MIT. Feita com carinho por Flávia Gaia.
Available Tools
10 toolsdiagnose_workloadA
One-shot diagnosis of a workload: state, unhealthy pods, restart counts and related Warning events. Ideal first call when something is failing.
Inputs: project_id (required), workload_id (required). Returns: object
get_eventsB
List recent Kubernetes events of a cluster (Warning events by default).
Inputs: cluster_id (required), limit, namespace, only_warnings. Returns: result
get_pod_logsB
Fetch the last N log lines of a pod. Use previous=True to read logs from the previous (crashed) container instance.
Inputs: pod_name (required), namespace (required), cluster_id (required), previous, +2 more. Returns: result
list_clustersA
List all Rancher-managed clusters with state and capacity summary.
Inputs: no named parameters. Returns: result
list_nodesA
List the nodes of a cluster with roles, state and requested resources.
Inputs: cluster_id (required). Returns: result
list_podsA
List pods of a project. Set only_unhealthy=True to see only pods in CrashLoopBackOff/Error/Pending states or with more than 3 restarts.
Inputs: project_id (required), namespace, only_unhealthy. Returns: result
list_projectsA
List Rancher projects of a cluster (project ids are needed to inspect workloads).
Inputs: cluster_id (required). Returns: result
list_workloadsA
List workloads (deployments, daemonsets...) of a project, optionally filtered by namespace.
Inputs: project_id (required), namespace. Returns: result
redeploy_workloadB
Trigger a rolling redeploy of a workload (equivalent to the Rancher UI 'Redeploy' button). Requires RANCHER_MCP_ALLOW_WRITE=true.
Inputs: project_id (required), workload_id (required). Returns: object
scale_workloadA
Scale a workload to N replicas. Requires RANCHER_MCP_ALLOW_WRITE=true. Capped by RANCHER_MCP_MAX_REPLICAS (default 20).
Inputs: replicas (required), project_id (required), workload_id (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool targets a distinct resource or action: listing clusters, projects, workloads, pods, nodes; retrieving events, logs; diagnosing a workload; redeploying or scaling. No overlaps.
All tools use an imperative verb followed by a noun (e.g., list_clusters, get_pod_logs, diagnose_workload). Names are uniformly snake_case and follow a predictable pattern.
10 tools is right in the ideal range (3-15). The set covers listing, retrieval, diagnosis, and two write operations without being bloated or too sparse.
For a diagnostics and light remediation server, the tool surface is complete: full read coverage of relevant Rancher resources, log/event access, workload diagnosis, and write operations for redeploy and scaling. No obvious gaps.
Maintenance
Related MCP Connectors
Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.
Query your app's logs, metrics and incidents from your AI assistant.
Provides capabilities that let LLM agents perform a range of infrastructure management tasks.
Fail-closed policy guardrails for AI agents running kubectl, terraform, helm, and argocd.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceProvides read-only access to Kubernetes clusters for AI assistants.25MIT
- AlicenseBqualityDmaintenanceEnables managing Kubernetes clusters through natural language by providing tools to list resources, view logs, port-forward services, scale deployments, and execute kubectl operations via AI assistants.81MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with and manage Kubernetes clusters, supporting operations on pods, deployments, services, configmaps, secrets, namespaces, metrics, and events with built-in safety features for destructive actions.97 npm1MIT
- FlicenseNot gradedqualityDmaintenanceExposes Kubernetes cluster management tools to LLMs, enabling querying pods, deployments, logs, metrics, and managing port forwards via natural language.1-