k3s-mcp

Sean-Michael/k3s-mcp

3.3

If you are the rightful owner of k3s-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The K3s MCP Server is a Python implementation of a Model Context Protocol (MCP) Server that allows an LLM, such as Claude, to interface with a Kubernetes cluster.

Tools
  1. get_pod_count

    Runs 'kubectl get pods --all-namespaces --no-headers' to get information on the running pods in the cluster and returns a count of the pods.

  2. get_node_info

    Runs 'kubectl get nodes -o json' to get information on the nodes in the cluster and returns a count of nodes followed by their names.

K3s MCP Server

Python implementation of a Model Context Protocol (MCP) Server

Overview

This server allows an LLM such as Claude to interface with a Kubernetes cluster. It uses Tools defined in the server.py that act as endpoints for the LLM to access kubectl and other commands' output.

Tools

Currently the following tools are implemented. Please reference the server.py to verify the most up-to-date information.

get_pod_count

  • Runs kubectl get pods --all-namespaces --no-headers to get information on the running pods in the cluster.
  • Returns a count of the pods.

get_node_info

  • Runs kubectl get nodes -o json to get information on the nodes in the cluster.
  • Returns a count of nodes followed by their names.

Installation

This project was built with pip but uv is recommended by mcp devs. Either way the requirements.txt file includes the dependencies required for running the MCP Server.

Python Virtual Environment and Pip

To start, create a virtual env and install requirements.txt

python3 -m venv .venv

source .venv/bin/activate

pip install -r requirements.txt

Testing the MCP Server

In order to test the MCP server we can launch the MCP inspector provided by anthropic. This will run the server code and launch a seperate process where we can see all the primitives we've defined.

mcp dev server.py

Now you can explore the available tools from Tools -> List Tools. Then you may run each tool with Run Tool and see their output.