capi-mcp is a tool that integrates CAPI (Cluster API) resources with the Model Context Protocol (MCP), enabling programmatic and prompt-based management of Kubernetes clusters and machines.
MCP (Model Context Protocol) is an open protocol for describing, invoking, and managing tools and prompts in a standardized way. It enables interoperability between tools, agents, and UIs.
CAPI (Cluster API) is a Kubernetes project to manage Kubernetes clusters declaratively using Kubernetes-style APIs. It provides a consistent way to create, update, and manage clusters and their infrastructure.
Clone the repository and build the binary:
make build
Run linting (installs golangci-lint if not present):
make lint
To run the MCP inspector with your built binary:
npx @modelcontextprotocol/inspector -e KUBECONFIG=kubeconfig.yaml bin/capi-mcp
Replace kubeconfig.yaml
with your actual kubeconfig file.
To use this MCP server with Claude Desktop, you need to configure it in Claude's settings:
-
Build the binary (if not already done):
make build
-
Locate Claude's configuration file:
- On macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- On Windows:
%APPDATA%\Claude\claude_desktop_config.json
- On Linux:
~/.config/Claude/claude_desktop_config.json
- On macOS:
-
Add the MCP server configuration:
{ "mcpServers": { "capi-mcp": { "command": "/absolute/path/to/capi-mcp/bin/capi-mcp", "env": { "KUBECONFIG": "/absolute/path/to/your/kubeconfig.yaml" } } } }
-
Restart Claude Desktop to load the new configuration.
-
Verify the connection: In a new conversation with Claude, you should see that the CAPI MCP server is connected and running through developer settings.

If you're using Claude through a VSCode extension that supports MCP:
-
Install the Claude extension from the VSCode marketplace.
-
Configure the MCP server in your VSCode settings or the extension's configuration file:
{ "claude.mcpServers": { "capi-mcp": { "command": "/absolute/path/to/capi-mcp/bin/capi-mcp", "env": { "KUBECONFIG": "/absolute/path/to/your/kubeconfig.yaml" } } } }
-
Restart VSCode to apply the configuration.
You can also integrate this MCP server with VSCode toolsets for enhanced development workflows:
-
Create a toolset configuration in your workspace:
- Open the Command Palette (
Cmd/Ctrl + Shift + P
) - Run "Toolsets: Configure Toolsets"
- Add a new toolset configuration
- Open the Command Palette (
-
Configure the CAPI MCP toolset:
{ "name": "CAPI MCP Server", "description": "Cluster API management via MCP", "tools": [ { "name": "capi-mcp", "command": "/absolute/path/to/capi-mcp/bin/capi-mcp", "env": { "KUBECONFIG": "/absolute/path/to/your/kubeconfig.yaml" }, "protocol": "mcp" } ] }
-
Use the toolset:
- Access via the Toolsets panel in the sidebar
- Invoke tools directly from the Command Palette
- Integrate with other VSCode AI features and extensions
This allows you to use CAPI management tools directly within your VSCode development environment alongside other development toolsets.
Once connected, you can use Claude to:
Tools:
list_clusters
- List all CAPI clusters in your Kubernetes environmentget_cluster
- Get detailed information about a specific clusterget_cluster_kubeconfig
- Generate and retrieve a kubeconfig for accessing a CAPI clustercheck_upgrade_eligibility
- Verify if a cluster can be safely upgraded to a target Kubernetes versionlist_machines
- List all machines (nodes) across clustersget_machine
- Get detailed information about a specific machineget_kube_resource
- Get any Kubernetes resource by name, kind, and API versionrollout_controlplane
- Rollout a restart of control plane (triggers rolling update - non-read-only)get_control_plane_status
- Get status of control plane components for a CAPI cluster
Prompts:
debug_capi_cluster
- Get step-by-step debugging guidance for cluster issuesdebug_capi_machine
- Get step-by-step debugging guidance for machine issuesrestart_control_plane
- Get step-by-step instructions for restarting a cluster's control plane
Ask Claude / Copilot questions like:
- "Show me all my CAPI clusters"
- "What's the status of my cluster named 'production'?"
- "List all machines in the cluster 'staging'"
- "Get me the kubeconfig for my cluster 'dev-cluster' in namespace 'default'"
- "Check if my cluster can be upgraded to Kubernetes v1.32.0"
- "Help me debug my cluster using the debug_capi_cluster prompt"
- "Get the status of control plane components for my cluster"
- "Get the deployment named 'my-app' in the default namespace using kind 'Deployment' and apiVersion 'apps/v1'"
Note: Make sure your kubeconfig.yaml
file has the necessary permissions to access CAPI resources in your Kubernetes cluster. Some tools like rollout_controlplane
are write operations and require appropriate RBAC permissions.