Labsco
feiskyer logo

Kubernetes Server

โ˜… 19

from feiskyer

An MCP server that enables AI assistants to interact with and manage Kubernetes clusters.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

mcp-kubernetes-server

PyPI version License Build Status

The mcp-kubernetes-server is a server implementing the Model Context Protocol (MCP) to enable AI assistants (such as Claude, Cursor, and GitHub Copilot) to interact with Kubernetes clusters. It acts as a bridge, translating natural language requests from these assistants into Kubernetes operations and returning the results.

It allows AI assistants to:

  • Query Kubernetes resources
  • Execute kubectl commands
  • Manage Kubernetes clusters through natural language interactions
  • Diagnose and interpret the states of Kubernetes resources

How It Works

The mcp-kubernetes-server acts as an intermediary between AI assistants (that support the Model Context Protocol) and your Kubernetes cluster. It receives natural language requests from these assistants, translates them into kubectl commands or direct Kubernetes API calls, and executes them against the target cluster. The server then processes the results and returns a structured response, enabling seamless interaction with your Kubernetes environment via the AI assistant.

Available Tools

The mcp-kubernetes-server provides a comprehensive set of tools for interacting with Kubernetes clusters, categorized by operation type:

Command Tools

Command Tools

These tools provide general command execution capabilities:

ToolDescriptionParameters
kubectlRun any kubectl command and return the outputcommand (string)
helmRun any helm command and return the outputcommand (string)
Read Tools

Read Tools

These tools provide read-only access to Kubernetes resources:

ToolDescriptionParameters
k8s_getFetch any Kubernetes object (or list) as JSON stringresource (string), name (string), namespace (string)
k8s_describeShow detailed information about a specific resource or group of resourcesresource_type (string), name (string, optional), namespace (string, optional), selector (string, optional), all_namespaces (boolean, optional)
k8s_logsPrint the logs for a container in a podpod_name (string), container (string, optional), namespace (string, optional), tail (integer, optional), previous (boolean, optional), since (string, optional), timestamps (boolean, optional), follow (boolean, optional)
k8s_eventsList events in the clusternamespace (string, optional), all_namespaces (boolean, optional), field_selector (string, optional), resource_type (string, optional), resource_name (string, optional), sort_by (string, optional), watch (boolean, optional)
k8s_apisList all available APIs in the Kubernetes clusternone
k8s_crdsList all Custom Resource Definitions (CRDs) in the Kubernetes clusternone
k8s_top_nodesDisplay resource usage (CPU/memory) of nodessort_by (string, optional)
k8s_top_podsDisplay resource usage (CPU/memory) of podsnamespace (string, optional), all_namespaces (boolean, optional), sort_by (string, optional), selector (string, optional)
k8s_rollout_statusGet the status of a rollout for a deployment, daemonset, or statefulsetresource_type (string), name (string), namespace (string, optional)
k8s_rollout_historyGet the rollout history for a deployment, daemonset, or statefulsetresource_type (string), name (string), namespace (string, optional), revision (string, optional)
k8s_auth_can_iCheck whether an action is allowedverb (string), resource (string), subresource (string, optional), namespace (string, optional), name (string, optional)
k8s_auth_whoamiShow the subject that you are currently authenticated asnone
Write Tools

Write Tools

These tools provide create, update or patch operations to Kubernetes resources:

ToolDescriptionParameters
k8s_createCreate a Kubernetes resource from YAML/JSON contentyaml_content (string), namespace (string, optional)
k8s_applyApply a configuration to a resource by filename or stdinyaml_content (string), namespace (string, optional)
k8s_exposeExpose a resource as a new Kubernetes serviceresource_type (string), name (string), port (integer), target_port (integer, optional), namespace (string, optional), protocol (string, optional), service_name (string, optional), labels (object, optional), selector (string, optional), type (string, optional)
k8s_runCreate and run a particular image in a podname (string), image (string), namespace (string, optional), command (array, optional), env (object, optional), labels (object, optional), restart (string, optional)
k8s_set_resourcesSet resource limits and requests for containersresource_type (string), resource_name (string), namespace (string, optional), containers (array, optional), limits (object, optional), requests (object, optional)
k8s_set_imageSet the image for a containerresource_type (string), resource_name (string), container (string), image (string), namespace (string, optional)
k8s_set_envSet environment variables for a containerresource_type (string), resource_name (string), container (string), env_dict (object), namespace (string, optional)
k8s_rollout_undoUndo a rollout for a deployment, daemonset, or statefulsetresource_type (string), name (string), namespace (string, optional), to_revision (string, optional)
k8s_rollout_restartRestart a rollout for a deployment, daemonset, or statefulsetresource_type (string), name (string), namespace (string, optional)
k8s_rollout_pausePause a rollout for a deployment, daemonset, or statefulsetresource_type (string), name (string), namespace (string, optional)
k8s_rollout_resumeResume a rollout for a deployment, daemonset, or statefulsetresource_type (string), name (string), namespace (string, optional)
k8s_scaleScale a resourceresource_type (string), name (string), replicas (integer), namespace (string, optional)
k8s_autoscaleAutoscale a deployment, replica set, stateful set, or replication controllerresource_type (string), name (string), min (integer), max (integer), namespace (string, optional), cpu_percent (integer, optional)
k8s_cordonMark a node as unschedulablenode_name (string)
k8s_uncordonMark a node as schedulablenode_name (string)
k8s_drainDrain a node in preparation for maintenancenode_name (string), force (boolean, optional), ignore_daemonsets (boolean, optional), delete_local_data (boolean, optional), timeout (integer, optional)
k8s_taintUpdate the taints on one or more nodesnode_name (string), key (string), value (string, optional), effect (string)
k8s_untaintRemove the taints from a nodenode_name (string), key (string), effect (string, optional)
k8s_exec_commandExecute a command in a containerpod_name (string), command (string), container (string, optional), namespace (string, optional), stdin (boolean, optional), tty (boolean, optional), timeout (integer, optional)
k8s_port_forwardForward one or more local ports to a podresource_type (string), name (string), ports (array), namespace (string, optional), address (string, optional)
k8s_cpCopy files and directories to and from containerssrc_path (string), dst_path (string), container (string, optional), namespace (string, optional)
k8s_patchUpdate fields of a resourceresource_type (string), name (string), patch (object), namespace (string, optional)
k8s_labelUpdate the labels on a resourceresource_type (string), name (string), labels (object), namespace (string, optional), overwrite (boolean, optional)
k8s_annotateUpdate the annotations on a resourceresource_type (string), name (string), annotations (object), namespace (string, optional), overwrite (boolean, optional)
Delete Tools

Delete Tools

These tools provide delete operations to Kubernetes resources:

ToolDescriptionParameters
k8s_deleteDelete resources by name, label selector, or all resources in a namespaceresource_type (string), name (string, optional), namespace (string, optional), label_selector (string, optional), all_namespaces (boolean, optional), force (boolean, optional), grace_period (integer, optional)

Development

How to run the project locally:

uv run -m src.mcp_kubernetes_server.main

How to inspect MCP server requests and responses:

npx @modelcontextprotocol/inspector uv run -m src.mcp_kubernetes_server.main

Contribution

This project is open source, available on GitHub at feiskyer/mcp-kubernetes-server and licensed under the Apache License.

If you would like to contribute to the project, please follow these guidelines:

  1. Fork the repository and clone it to your local machine.
  2. Create a new branch for your changes.
  3. Make your changes and commit them with a descriptive commit message.
  4. Push your changes to your forked repository.
  5. Open a pull request to the main repository.