The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Mkp listing page.
MKP is a Model Context Protocol (MCP) server for Kubernetes that allows LLM-powered applications to interact with Kubernetes clusters. It provides tools for listing and applying Kubernetes resources through the MCP protocol.
MKP offers several key advantages as a Model Context Protocol server for Kubernetes:
Clone the repository:
Install dependencies:
Build the server:
To run the server with the default kubeconfig:
To run the server with a specific kubeconfig:
To run the server on a specific port:
MKP can be run as a Model Context Protocol (MCP) server using ToolHive, which simplifies the deployment and management of MCP servers.
See the ToolHive documentation for detailed instructions on how to set up MKP with the ToolHive UI, CLI, or Kubernetes operator.
The MKP server provides the following MCP tools:
Get a Kubernetes resource or its subresource.
Parameters:
resource_type (required): Type of resource to get (clustered or namespaced)group: API group (e.g., apps, networking.k8s.io)version (required): API version (e.g., v1, v1beta1)resource (required): Resource name (e.g., deployments, services)namespace: Namespace (required for namespaced resources)name (required): Name of the resource to getsubresource: Subresource to get (e.g., status, scale, logs)parameters: Optional parameters for the request (see examples below)Example:
Example of getting logs from a specific container with parameters:
Available parameters for pod logs:
container: Specify which container to get logs fromprevious: Get logs from previous container instance (true/false)sinceSeconds: Only return logs newer than a relative duration in secondssinceTime: Only return logs after a specific time (RFC3339 format)timestamps: Include timestamps on each line (true/false)limitBytes: Maximum number of bytes to returntailLines: Number of lines to return from the end of the logsBy default, pod logs are limited to the last 100 lines and 32KB to avoid overwhelming the LLM's context window. These defaults can be overridden using the parameters above.
Available parameters for regular resources:
resourceVersion: When specified, shows the resource at that particular
versionLists Kubernetes resources of a specific type.
Parameters:
resource_type (required): Type of resource to list (clustered or namespaced)group: API group (e.g., apps, networking.k8s.io)version (required): API version (e.g., v1, v1beta1)resource (required): Resource name (e.g., deployments, services)namespace: Namespace (required for namespaced resources)label_selector: Kubernetes label selector for filtering resources (optional)include_annotations: Whether to include annotations in the output (default:
true)exclude_annotation_keys: List of annotation keys to exclude from output
(supports wildcards with *)include_annotation_keys: List of annotation keys to include in output (if
specified, only these are included)The list_resources tool provides powerful annotation filtering capabilities to
control metadata output size and prevent truncation issues with large
annotations (such as GPU node annotations).
Basic Usage:
Exclude specific annotations (useful for GPU nodes):
Include only specific annotations:
Disable annotations completely for maximum performance:
Annotation Filtering Rules:
kubectl.kubernetes.io/last-applied-configuration is excluded to
prevent large configuration dataexclude_annotation_keys supports wildcard patterns using * (e.g.,
nvidia.com/* excludes all NVIDIA annotations)include_annotation_keys is specified, it takes precedence and only
those annotations are includedinclude_annotations: false completely removes all annotations from
the output* at the end of the key (e.g.,
nvidia.com/*)Applies (creates or updates) a Kubernetes resource.
Parameters:
resource_type (required): Type of resource to apply (clustered or
namespaced)group: API group (e.g., apps, networking.k8s.io)version (required): API version (e.g., v1, v1beta1)resource (required): Resource name (e.g., deployments, services)namespace: Namespace (required for namespaced resources)manifest (required): Resource manifestExample:
Posts to a Kubernetes resource or its subresource, particularly useful for executing commands in pods.
Parameters:
resource_type (required): Type of resource to post to (clustered or
namespaced)group: API group (e.g., apps, networking.k8s.io)version (required): API version (e.g., v1, v1beta1)resource (required): Resource name (e.g., deployments, services)namespace: Namespace (required for namespaced resources)name (required): Name of the resource to post tosubresource: Subresource to post to (e.g., exec)body (required): Body to post to the resourceparameters: Optional parameters for the requestExample of executing a command in a pod:
The body for pod exec supports the following fields:
command (required): Command to execute, either as a string or an array of
stringscontainer (optional): Container name to execute the command in (defaults to
the first container)timeout (optional): Timeout in seconds (defaults to 15 seconds, maximum 60
seconds)Note on timeouts:
The response includes stdout, stderr, and any error message:
The MKP server provides access to Kubernetes resources through MCP resources. The resource URIs follow these formats:
k8s://clustered/{group}/{version}/{resource}/{name}k8s://namespaced/{namespace}/{group}/{version}/{resource}/{name}MKP supports two transport protocols for the MCP server:
You can configure the transport protocol using either a CLI flag or an environment variable:
The MCP_TRANSPORT environment variable is automatically set by ToolHive when
running MKP in that environment.
By default, MKP serves all Kubernetes resources as MCP resources, which provides useful context for LLMs. However, in large clusters with many resources, this can consume significant context space in the LLM.
You can disable this behavior by using the --serve-resources flag:
Even with resource discovery disabled, the MCP tools (get_resource,
list_resources, apply_resource, delete_resource, and post_resource)
remain fully functional, allowing you to interact with your Kubernetes cluster.
By default, MKP operates in read-only mode, meaning it does not allow write
operations on the cluster, i.e. the apply_resource, delete_resource, and
post_resource tools will not be available. You can enable write operations by
using the --read-write flag:
MKP includes a built-in rate limiting mechanism to protect the server from excessive API calls, which is particularly important when used with AI agents. The rate limiter uses a token bucket algorithm and applies different limits based on the operation type:
Rate limits are applied per client session, ensuring fair resource allocation across multiple clients. The rate limiting feature can be enabled or disabled via the command line flag:
Rate limits can be customized via environment variables:
MKP_RATE_LIMIT_DEFAULT: Default rate limit (default: 60)MKP_RATE_LIMIT_READ: Read operations rate limit (default: 120)MKP_RATE_LIMIT_WRITE: Write operations rate limit (default: 30)We welcome contributions to this MCP server! If you'd like to contribute, please review the CONTRIBUTING guide for details on how to get started.
If you run into a bug or have a feature request, please
open an issue in the repository or
join us in the #mcp-servers channel on our
community Discord server.
This project is licensed under the Apache v2 License - see the LICENSE file for details.