mcp-k8s-go-bridge
Golang implementation of the Model Context Protocol (MCP) server facilitating interaction with Kubernetes clusters.
Author
strowk
Quick Info
Actions
Tags
Golang-based MCP gateway interfacing with Kubernetes APIs
K8s MCP Server (Go)
Capabilities ⚙ Inspect with Inspector ⚙ Interact via Claude ⚙ Contribute ↗ ⚙ About MCP ↗
Key Capabilities
MCP 💬 context input 🗂️ resource interaction 🤖 automated execution
- 🗂️🤖 Context Enumeration for Kubernetes environments
- 💬🤖 Namespace Discovery for current cluster setup
- 🤖 Comprehensive API access for any K8s resource type
- Includes specialized handlers for common objects like Pods, Services, Deployments
- 🤖 Node inventory retrieval
- 💬 Pod listing functionality
- 🤖 Retrieval of diagnostic Kubernetes Events
- 🤖 Extraction of container logs from specified Pods
- 🤖 Execution of arbitrary shell commands within a running Pod container
Inspect Integration
To leverage the most recent released artifact via the Inspector client:
npx @modelcontextprotocol/inspector npx @strowk/mcp-k8s
Interact With Claude
Demonstration Snippet
Below is an illustration of the workflow in Claude Desktop, where a specific cluster context is selected, and then a command is issued to examine logs for error indicators within the 'kube-system' namespace:To integrate this MCP server with Claude Desktop (or alternative compliant clients), choose your preferred installation method.
| Deployment Method | Smithery | mcp-get | NPM Package | GitHub Binary | Source Build | Docker Image |
|---|---|---|---|---|---|---|
| Client Setup | Automatic | Automatic | Manual | Manual | Manual | Manual |
| Dependency | Node.js | Node.js | Node.js | None | Golang Toolchain | Docker Engine |
Smithery Integration
Automated setup for Claude Desktop using Smithery:
npx -y @smithery/cli install @strowk/mcp-k8s --client claude
mcp-get Utility
Automated installation for Claude Desktop via mcp-get:
npx @michaellatman/mcp-get@latest install @strowk/mcp-k8s
Manual Installation via Binaries
Pre-compiled npm Distribution
If Node Package Manager (npm) is available, use this for pre-built binaries:
npm install -g @strowk/mcp-k8s
Verify installation with mcp-k8s --version. Once confirmed, update your client configuration file (claude_desktop_config.json):
{
"mcpServers": {
"mcp_k8s": {
"command": "mcp-k8s",
"args": []
}
}
}
Alternatively, execute via npx:
npx @strowk/mcp-k8s
Configuration example for Claude:
{
"mcpServers": {
"mcp_k8s": {
"command": "npx",
"args": [
"@strowk/mcp-k8s"
]
}
}
}
Binaries from GitHub Releases
Obtain the latest binary package from the GitHub releases page. Unzip the archive containing the executable named mcp-k8s-go, place it in a directory within your system's PATH, and then configure your client config file (claude_desktop_config.json) as follows:
{
"mcpServers": {
"mcp_k8s": {
"command": "mcp-k8s-go",
"args": []
}
}
}
Compilation from Source Code
Requires the Golang development environment:
go get github.com/strowk/mcp-k8s-go
go install github.com/strowk/mcp-k8s-go
Then, configure the client using the installed binary name:
{
"mcpServers": {
"mcp_k8s_go": {
"command": "mcp-k8s-go",
"args": []
}
}
}
Docker Containerization
This server image is available on Docker Hub since version 0.3.1-beta.2, supporting linux/amd64 and linux/arm64 multi-arch builds.
Use the 'latest' tag, ensuring Kubeconfig volume mounting:
docker run -i -v ~/.kube/config:/home/nonroot/.kube/config --rm mcpk8s/server:latest
Note for Windows users (Git Bash): You may need to translate ~/.kube/config to a full path like //c/Users/<username>/.kube/config for volume mapping.
Client configuration example for Claude:
{
"mcpServers": {
"mcp_k8s_go": {
"command": "docker",
"args": [
"run",
"-i",
"-v",
"~/.kube/config:/home/nonroot/.kube/config",
"--rm",
"mcpk8s/server:latest"
]
}
}
}
Environment Variables and Runtime Arguments
The MCP server respects the following environment settings:
KUBECONFIG: Specifies the path to the Kubernetes configuration file (defaults to~/.kube/configif unset).
The server accepts these command-line flags during invocation:
--allowed-contexts=<list>: Limits operational scope to a comma-separated set of Kubernetes contexts (e.g.,dev,prod). If omitted, all contexts are accessible.--readonly: Activates read-only mode, blocking any operations that modify cluster state.--help: Prints usage instructions.--version: Outputs the current version information.
Example configuration in claude_desktop_config.json to restrict context access and enforce read-only operations:
{
"mcpServers": {
"mcp_k8s": {
"command": "mcp-k8s",
"args": [
"--allowed-contexts=dev,prod",
"--readonly"
]
}
}
}
