RR

rancher/rancher-ai-mcp

Developer tools
27 stars 24 forks Quality 70 Trend 21Apache-2.0

The MCP server allows the Rancher AI agent to securely retrieve or update Kubernetes and Rancher resources across local and downstream clusters.

Overview

The MCP server allows the Rancher AI agent to securely retrieve or update Kubernetes and Rancher resources across local and downstream clusters. It expects the Rancher token in a header, which the agent will always provide for authentication. This Model Context Protocol (MCP) server provides a secure bridge between the Rancher AI agent and Kubernetes clusters, enabling AI-powered cluster management through a standardized tool interface. The server runs as a Kubernetes deployment within the Rancher environment and exposes tools for resource inspection, modification, and cluster operations. - - CLI commands and server initialization - serve.go - HTTP/TLS server setup with dynamic listener support - root.go - Root command configuration - - Kubernetes client abstraction - Dynamic client wrapper with cluster ID resolution - Rancher API integration for cluster management - Support for both local and downstream cluster operations - - Tool registration and organization - toolsets.

README

MCP Server for Rancher

The MCP server allows the Rancher AI agent to securely retrieve or update Kubernetes and Rancher resources across local and downstream clusters. It expects the Rancher token in a header, which the agent will always provide for authentication.

Overview

This Model Context Protocol (MCP) server provides a secure bridge between the Rancher AI agent and Kubernetes clusters, enabling AI-powered cluster management through a standardized tool interface. The server runs as a Kubernetes deployment within the Rancher environment and exposes tools for resource inspection, modification, and cluster operations.

Architecture

Package Structure

  • cmd/ - CLI commands and server initialization

    • serve.go - HTTP/TLS server setup with dynamic listener support, and stdio transport
    • root.go - Root command configuration
  • pkg/client/ - Kubernetes client abstraction

    • Dynamic client wrapper with cluster ID resolution
    • Rancher API integration for cluster management
    • Support for both local and downstream cluster operations
  • pkg/toolsets/ - Tool registration and organization

    • toolsets.go - Central registry for tool collections
    • core/ - Core Kubernetes operation tools
  • pkg/response/ - Response formatting utilities

    • Structured text and content generation for MCP responses
  • pkg/converter/ - Data transformation utilities

    • Group/Version/Resource (GVR) conversion helpers

Multi-Agent Architecture

The server is designed with a modular toolset architecture to support a multi-agent system. Each toolset contains a collection of related tools that serve a specific agent or domain within the Rancher AI ecosystem.

Current Toolsets:

  • core - Fundamental Kubernetes operations (resource management, pod inspection, metrics)

This architecture allows different AI agents to access only the tools they need, improving security, maintainability, and scalability.

TLS & Security

The server supports two modes:

  1. TLS Mode (Production): Uses Rancher’s dynamic listener with auto-generated certificates

    • Certificates stored as Kubernetes secrets
    • Automatic cert rotation and renewal
    • Client certificate authentication support
    • TLS 1.2+ with secure cipher suites
  2. Insecure Mode (Development): Plain HTTP for local testing

    • Enabled via --insecure flag or INSECURE_SKIP_TLS=true

Available Tools

Each tool is exposed through the MCP protocol and can be invoked by the Rancher AI agent. The full, up-to-date list of tools grouped by toolset is maintained in TOOLS.md, which is generated from the tool definitions.

To regenerate it after adding or changing tools, run:

go generate ./...
# or
make generate

Configuration

Command-line Flags

--port               Port to listen on (default: 9092)
--insecure                Skip TLS verification (default: false)
--stdio                   Serve MCP over stdin/stdout instead of HTTP (default: false)
--rancher-token   Rancher token used for all tool calls in stdio mode (default: $RANCHER_TOKEN)
--rancher-url     Rancher server URL used in stdio mode (default: $RANCHER_URL)

stdio Mode

With --stdio the server talks MCP over stdin/stdout, so a local MCP client can start it as a subprocess. There are no HTTP headers in this mode, so the Rancher token and URL come from --rancher-token/--rancher-url or the RANCHER_TOKEN/RANCHER_URL env vars. --port, --authz-server-url, --jwks-url and --resource-url are ignored. Logs go to stderr.

Rancher’s certificate is checked against the system trust store.

Example MCP client configuration:

{
  "mcpServers": {
    "rancher": {
      "command": "mcp",
      "args": ["serve", "--stdio", "--rancher-url", "https://rancher.example.com", "--rancher-token", "token-xxx"]
    }
  }
}
View the full README on GitHub

Install

This server does not publish a one-line install command.

Open the repository installation guide New to MCP? Start with the mcpskill.org guide →

Configuration

{ "mcpServers": { "rancher": { "command": "mcp", "args": ["serve", "--stdio", "--rancher-url", "https://rancher.example.com", "--rancher-token", "token-xxx"] } } }