kubectl-mcp
kubectl MCP Plugin
Documentation
kubectl MCP (Model Context Protocol) Plugin
Overview
The `kubectl-mcp` plugin implements a Model Context Protocol (MCP) server for kubectl. This server enables AI assistants like Amazon Q to interact with kubectl functionality directly through a standardized protocol, allowing for seamless integration of kubectl commands into AI-powered workflows.
What is MCP?
Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context and tools to Large Language Models (LLMs). It enables AI assistants to:
1. Discover available tools and their capabilities
2. Execute commands and receive structured responses
3. Provide contextual information to enhance AI interactions
How the kubectl MCP Plugin Works
The kubectl MCP plugin exposes all kubectl commands as tools that can be invoked by AI assistants. The implementation consists of several key components:
Core Components
1. `main.go`: Entry point that starts the MCP server
2. `pkg/mcp/server.go`: Creates and configures the MCP server with all kubectl commands
3. `pkg/mcp/tools.go`: Handles the registration of kubectl commands as MCP tools
Implementation Details
- The server uses the `mcp-go` library to implement the Model Context Protocol
- It dynamically registers all kubectl commands (get, apply, delete, etc.) as MCP tools
- Each command's help text, flags, and parameters are exposed through the protocol
- The server runs as a stdio server, communicating through standard input/output
Command Registration Process
1. The server recursively traverses the kubectl command tree
2. For each command, it extracts:
Using the kubectl MCP Plugin with Amazon Q Chat
To use the kubectl MCP plugin with Amazon Q Chat, you need to register it in the Amazon Q configuration file.
Create or edit the file at `$HOME/.aws/amazonq/mcp.json` with the following content:
{
"mcpServers": {
"kubectl": {
"command": "kubectl-mcp",
"args": []
}
}
}This configuration tells Amazon Q Chat to:
1. Register a server named "kubectl"
2. Use the `kubectl-mcp` command to start the MCP server
3. Make all kubectl commands available as tools with the prefix `kubectl___`
Benefits
- Seamless Integration: AI assistants can execute kubectl commands directly
- Structured Responses: Commands return structured data that can be parsed by AI models
- Discoverability: AI assistants can discover available commands and their parameters
- Context-Aware: Provides rich context about Kubernetes resources
Installation
To install the kubectl MCP plugin:
1. Build the plugin:
make kubectl-mcp2. Move the binary to a location in your PATH:
sudo mv kubectl-mcp /usr/local/bin/3. Verify the installation:
kubectl plugin list | grep mcpQuick test for MCP server
To quickly test the MCP server, you can run the following command in your terminal:
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | kubectl-mcp | jqRecommendations
- Monitor background operations for long-running commands. Commands such as resource creation have a 45-second timeout for command responses but the processes continue in background.
- For complex kubectl operations, consider using the plugin in combination with kubectl apply -f for declarative resource management.
Frequently asked questions
What is kubectl-mcp?
kubectl-mcp is kubectl MCP Plugin
How do I install kubectl-mcp?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is kubectl-mcp open source?
Yes — it is hosted on GitHub at https://github.com/dims/kubectl-mcp.
Related MCP tools
eBPF-powered network observability for Kubernetes. Indexes L4/L7 traffic with full K8s context, decrypts TLS without keys. Queryable by AI agents via MCP and humans via dashboard.
GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
The missing open-source Kubernetes UI with a built-in MCP server for AI agents. See what's broken, why, and what changed. Issues, Topology, event timeline, Helm, GitOps, live service traffic, and cluster audits - all in one Go binary.
mcp-language-server gives MCP enabled clients access semantic tools like get definition, references, rename, and diagnostics.
The Terraform MCP Server provides seamless integration with Terraform ecosystem, enabling advanced automation and interaction capabilities for Infrastructure as Code (IaC) development.
Run MATLAB® using AI applications with the official MATLAB MCP Server from MathWorks®. This MCP server for MATLAB supports a wide range of coding agents like Claude Code® and Visual Studio® Code.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP