mcp-k8s-go
by: strowk
MCP server connecting to Kubernetes
📌Overview
Purpose: The MCP K8S Go framework serves as a Golang-based server that connects to Kubernetes, facilitating seamless Kubernetes management and resource access.
Overview: MCP K8S Go is designed to simplify interactions with Kubernetes environments through a set of command-line tools and prompts, enhancing the efficiency of managing Kubernetes resources.
Key Features:
-
Kubernetes Context Management: Access and list Kubernetes contexts directly from kubeconfig configurations, allowing users to efficiently navigate multiple clusters.
-
Resource Management Tools: A suite of commands to list namespaces, nodes, resources, and events in specified contexts, as well as to retrieve logs from pods, tailoring resource management to user needs.
Golang-based MCP Server Connecting to Kubernetes
Table of Contents
Features
- Resource: K8S contexts as read from kubeconfig configurations
- Tool: list-k8s-contexts
- Tool: list-k8s-namespaces in a given context
- Tool: list-k8s-nodes in a given context
- Tool: list-k8s-resources in a given context and namespace for specified resource kind
- Includes custom mappings for resources like pods, services, deployments
- Tool: get-k8s-resource in a given context and namespace for specified name and resource kind
- Tool: list-k8s-events in a given context and namespace
- Tool: get-k8s-pod-logs in a given context and namespace for specified pod
- Prompt: list-k8s-namespaces in a given context
- Prompt: list-k8s-pods in current context and with given namespace
Browse With Inspector
To use the latest published version with Inspector, run:
npx @modelcontextprotocol/inspector npx @strowk/mcp-k8s
For a version built from sources, run:
tools/inspector/run.sh
Use With Claude
To use this MCP server with Claude Desktop, first install it using one of the following methods:
Smithery | mcp-get | Pre-built NPM | From GitHub releases | Building from source | |
---|---|---|---|---|---|
Claude Setup | Auto | Auto | Manual | Manual | Manual |
Prerequisite | Node.js | Node.js | Node.js | None | Golang |
Using Smithery
To install MCP K8S Go for Claude Desktop automatically:
npx -y @smithery/cli install @strowk/mcp-k8s --client claude
Using mcp-get
To install MCP K8S Go for Claude Desktop automatically:
npx @michaellatman/mcp-get@latest install @strowk/mcp-k8s
Manually with Prebuilt Binaries
Prebuilt from npm
If you have npm installed:
npm install -g @strowk/mcp-k8s
Then check the version:
mcp-k8s --version
Add configuration to claude_desktop_config.json
:
{
"mcpServers": {
"mcp_k8s": {
"command": "mcp-k8s",
"args": []
}
}
}
From GitHub Releases
Download the latest release for your platform from GitHub releases.
Unpack the archive and configure claude_desktop_config.json
:
{
"mcpServers": {
"mcp_k8s": {
"command": "mcp-k8s-go",
"args": []
}
}
}
Building from Source
Install Golang and build the project:
go get github.com/strowk/mcp-k8s-go
go install github.com/strowk/mcp-k8s-go
Then add to claude_desktop_config.json
:
{
"mcpServers": {
"mcp_k8s_go": {
"command": "mcp-k8s-go",
"args": []
}
}
}
Using from Claude Desktop
You can use Claude Desktop to:
- See K8S contexts available to attach to conversation as a resource
- Ask Claude to list contexts, pods, events, or read logs
Environment Variables and Command-line Options
Environment Variables
KUBECONFIG
: Path to your Kubernetes configuration file (optional, defaults to ~/.kube/config)
Command-line Options
--allowed-contexts=<ctx1,ctx2,...>
: Comma-separated list of allowed Kubernetes contexts--help
: Display help information--version
: Display version information
Contributing
Check out CONTRIBUTION.md for more information on how to contribute to this project.