Harvester MCP Server
Model Context Protocol (MCP) server for Harvester HCI that enables Claude Desktop, Cursor, and other AI assistants to interact with Harvester clusters through the MCP protocol.
Overview
Harvester MCP Server is a Go implementation of the Model Context Protocol (MCP) specifically designed for Harvester HCI. It allows AI assistants like Claude Desktop and Cursor to perform CRUD operations on Harvester clusters, which are essentially Kubernetes clusters with Harvester-specific CRDs.
Features
Kubernetes Core Resources :
- Pods: List, Get, Delete
- Deployments: List, Get
- Services: List, Get
- Namespaces: List, Get
- Nodes: List, Get
- Custom Resource Definitions (CRDs): List
Harvester-Specific Resources :
- Virtual Machines: List, Get
- Images: List
- Volumes: List
- Networks: List
Enhanced User Experience :
- Human-readable formatted outputs for all resources
- Automatic grouping of resources by namespace or status
- Concise summaries with the most relevant information
- Detailed views for comprehensive resource inspection
Requirements
- Go 1.23+
- Access to a Harvester cluster with a valid kubeconfig
Installation
From Source
# Clone the repository
git clone https://github.com/starbops/harvester-mcp-server.git
cd harvester-mcp-server
# Build
make build
# Run
./bin/harvester-mcp-server
Using Go Install
go install github.com/starbops/harvester-mcp-server/cmd/harvester-mcp-server@latest
Configuration
The server automatically looks for Kubernetes configuration in the following order:
- In-cluster configuration (if running inside a Kubernetes cluster)
- Path specified by the
--kubeconfig
flag
- Path specified by the
KUBECONFIG
environment variable
- Default location at
~/.kube/config
Command-Line Flags
Usage:
harvester-mcp-server [flags]
Flags:
-h, --help help for harvester-mcp-server
--kubeconfig string Path to the kubeconfig file (default is $KUBECONFIG or $HOME/.kube/config)
--log-level string Log level (debug, info, warn, error, fatal, panic) (default "info")
Examples
Using a specific kubeconfig file:
harvester-mcp-server --kubeconfig=/path/to/kubeconfig.yaml
Using the KUBECONFIG environment variable:
export KUBECONFIG=$HOME/config.yaml
harvester-mcp-server
With debug logging:
harvester-mcp-server --log-level=debug
Usage with Claude Desktop
- Install Claude Desktop
- Open Claude Desktop configuration file (
~/Library/Application\ Support/Claude/claude_desktop_config.json
or similar)
- Add the Harvester MCP server to the
mcpServers
section:
{
"mcpServers": {
"harvester": {
"command": "/path/to/harvester-mcp-server",
"args": ["--kubeconfig", "/path/to/kubeconfig.yaml", "--log-level", "info"]
}
}
}
- Restart Claude Desktop
- The Harvester MCP tools should now be available to Claude
Example Queries for Claude Desktop
Once your Harvester MCP server is configured in Claude Desktop, you can ask questions like:
- "How many nodes are in my Harvester cluster?"
- "List all pods in the cattle-system namespace"
- "Show me the details of the pod named rancher-789c976c6-xbvmd in cattle-system namespace"
- "List all virtual machines in the default namespace"
- "What services are running in the harvester-system namespace?"
Development
Project Structure
cmd/harvester-mcp-server
: Main application entry point
pkg/client
: Kubernetes client implementation
pkg/cmd
: CLI commands implementation using Cobra
pkg/mcp
: MCP server implementation
pkg/tools
: Tool implementations for interacting with Harvester resources
Adding New Tools
To add a new tool:
- Create a new function in the appropriate file under
pkg/tools
- Register the tool in
pkg/mcp/server.go
in the registerTools
method
- Implement a formatting function to provide human-readable output
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Acknowledgments