mcp-k8s is a stdio-based MCP (Model Control Protocol) server used to connect to a Kubernetes cluster and interact with the cluster through MCP tools. It allows users to manage Kubernetes resources using natural language, including native resources and CRDs, while also providing Helm support.
Main Capabilities
- Query the resource types supported by Kubernetes (built-in resources and CRDs).
- Fine-grained control operations on Kubernetes resources:
- Read operations: get resource details, list resources by type with filtering options.
- Write operations: create, update, delete resources, each of which can be independently enabled or disabled.
- Support all Kubernetes resource types, including custom resources.
- Connect to a Kubernetes cluster through kubeconfig.
- Helm support with fine-grained control:
- Helm release management (list, get, install, upgrade, uninstall).
- Helm repository management (list, add, remove).
- Each operation can be independently enabled or disabled.
Available Tools
- get_api_resources: get all supported API resource types in the cluster.
- get_resource: get detailed information about a specific resource.
- list_resources: list all instances of a resource type.
- create_resource: create a new resource (can be disabled).
- update_resource: update an existing resource (can be disabled).
- delete_resource: delete a resource (can be disabled).
- list_helm_releases: list all Helm releases in the cluster.
- get_helm_release: get detailed information about a specific Helm release.
- install_helm_chart: install a Helm chart (can be disabled).
- upgrade_helm_chart: upgrade a Helm release (can be disabled).
- uninstall_helm_chart: uninstall a Helm release (can be disabled).
- list_helm_repositories: list the configured Helm repositories.
- add_helm_repository: add a new Helm repository (can be disabled).
- remove_helm_repository: remove a Helm repository (can be disabled).
Usage
mcp-k8s supports three communication modes:
- Stdio mode (default): communicate with the client through standard input/output streams, suitable for most scenarios.
- SSE mode: expose an HTTP endpoint to MCP clients, which can be deployed on a remote server (security considerations required). Configuration parameters:
- --transport: set to "sse" to enable SSE mode.
- --port: HTTP server port (default 8080).
- --host: HTTP server host (default "localhost").
- Streamable HTTP mode: expose an HTTP endpoint that supports direct HTTP responses and SSE streams, providing better flexibility and supporting streaming output. Configuration parameters:
- --transport: set to "streamable-http" to enable this mode.
- --endpoint-path: the endpoint path of the MCP server (default "/mcp").
Command-line Arguments
You can use mcp-k8s --help to view all available options, or mcp-k8s --version to view the version.
- --kubeconfig: Kubernetes configuration file path (if not specified, the default configuration is used).
- --enable-create: enable resource creation operations (default false).
- --enable-update: enable resource update operations (default false).
- --enable-delete: enable resource deletion operations (default false).
- --enable-list: enable resource listing operations (default true).
- --enable-helm-release-list: enable Helm release listing operations (default true).
- --enable-helm-release-get: enable Helm release get operations (default true).
- --enable-helm-install: enable Helm chart installation (default false).
- --enable-helm-upgrade: Enable Helm chart upgrade (default false).
- --enable-helm-uninstall: Enable Helm chart uninstall (default false).
- --enable-helm-repo-list: Enable Helm repository list operations (default true).
- --enable-helm-repo-add: Enable Helm repository add operations (default false).
- --enable-helm-repo-remove: Enable Helm repository remove operations (default false).
- --transport: Transport type (stdio, sse, or streamable-http) (default "stdio").
- --host: Host for HTTP transport (SSE or Streamable HTTP) (default "localhost").
- --port: TCP port for HTTP transport (SSE or Streamable HTTP) (default 8080).
- --endpoint-path: Endpoint path for Streamable HTTP transport (default "/mcp").
- --version: Display version information, including version, commit hash, and build date.
- --help or -h: Display help information.
Obtaining and Building
You can directly download the binary for the corresponding platform from the releases page and use it. The Makefile automatically injects version information from the VERSION file; when building directly, the version is displayed as "dev" unless ldflags are manually specified.
Docker Environment
Assuming the image name is mcp-k8s, you need to map ports and set environment parameters, and run the corresponding command (the specific command is not provided in the materials).
Testing Streamable HTTP
You can use the provided test script to test whether Streamable HTTP mode works properly. For detailed testing instructions, see TEST_STREAMABLE_HTTP.md.
Integration with MCP Clients
mcp-k8s is a stdio-based MCP server that can be integrated with any MCP-compatible LLM client. For integration instructions, refer to the documentation of the MCP client you are using.client documentation.
Applicable Scenarios
- Managing Kubernetes Resources via LLM
- Interactive resource management: Manage Kubernetes resources by interacting with the LLM in natural language, without needing to memorize complex kubectl commands.
- Batch operations: Describe complex batch operation requirements in natural language, and the LLM converts them into specific resource operations.
- Resource status queries: Query cluster resource status in natural language and receive easy-to-understand responses.
- Automated Operations Scenarios
- Intelligent operations assistant: Acts as an intelligent assistant for operations personnel's daily cluster management tasks.
- Problem diagnosis: Describe problems in natural language to assist in diagnosing cluster issues.
- Configuration review: Use the LLM's comprehension capabilities to help review and optimize Kubernetes resource configurations.
- Development and Testing Support
- Rapid prototype validation: Developers can quickly create and validate resource configurations through natural language.
- Environment management: Simplify test environment resource management, and quickly create, modify, and clean up test resources.
- Configuration generation: Automatically generate resource configurations that follow best practices based on requirement descriptions.
- Education and Training Scenarios
- Interactive learning: Beginners can learn Kubernetes concepts and operations through natural language interaction.
- Best practice guidance: The LLM provides best practice suggestions during resource operations.
- Error explanation: Provide easy-to-understand error explanations and correction suggestions when operations fail.
Technology Stack and Core Components
- Kubernetes client-go library.
- Helm v3 client library.
- Use stdio for communication.
- MCP server: Use the mcp-k8s package of mcp-go to create a stdio-based MCP server.
- K8s client: Use client-go to connect to the Kubernetes cluster.
- Helm client: Use the Helm v3 library for Helm operations.
- Tool implementation: Implement various MCP tools to perform different Kubernetes operations.
Security Considerations
- Write operations are strictly controlled through independent configuration switches.
- Use RBAC to ensure the K8s client has only the necessary permissions.
- Validate all user input to prevent injection attacks.
- Helm operations follow the same securityFull principle: read operations are enabled by default, write operations are disabled by default.
Limitations
The materials do not provide information about fees, pricing, platform support scope, performance metrics, or specific effects.