Labsco
siddjoshi logo

MCP Server for Kubernetes

from siddjoshi

A server for managing Kubernetes clusters using the Model Context Protocol.

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

MCP Kubernetes Server

A Model Context Protocol (MCP) server for Kubernetes, supporting chunked HTTP streaming, advanced troubleshooting prompts, and full Kubernetes resource/tool coverage.


1. Build and Run Locally

npm install
npm run build
MCP_TRANSPORT=http-chunked npm start
  • By default, the server uses your local kubeconfig (~/.kube/config or C:\Users\<username>\.kube\config).
  • To use a custom kubeconfig, set the KUBECONFIG environment variable:
    export KUBECONFIG=/path/to/your/kubeconfig
    npm start

2. Dockerize the MCP Server

Build the Docker image

docker build -t yourrepo/mcp-server:latest .

Push to your registry

docker push yourrepo/mcp-server:latest

4. Using the MCP Server

HTTP Chunked Endpoint

  • The server exposes /call-tool-chunked on port 3000.
  • Example (using curl):
    curl -X POST http://<server-ip>:3000/call-tool-chunked \
      -H "Content-Type: application/json" \
      -d '{"name": "get_pods", "args": {"namespace": "default"}}'
  • The response will stream progress and results as JSON lines.

Using Prompts

  • To use a prompt, POST to /call-tool-chunked with the prompt name, e.g.:
    curl -X POST http://<server-ip>:3000/call-tool-chunked \
      -H "Content-Type: application/json" \
      -d '{"name": "k8s-pod-crashloop-diagnose", "args": {"podName": "my-pod", "namespace": "default"}}'

5. Kubeconfig and Permissions

  • The MCP server uses the kubeconfig available in the container (default: /root/.kube/config).
  • For in-cluster deployments, it uses the ServiceAccount and RBAC provided in the manifest.
  • To use a custom kubeconfig, mount it as a secret and update the Deployment (see commented lines in the manifest).

6. Security Notes

  • Do not expose the MCP server to the public internet without authentication and TLS.
  • Use network policies, firewalls, or VPNs to restrict access.
  • Use least-privilege RBAC for the ServiceAccount.

7. Extending and Customizing

  • Add new tools, resources, or prompts in the src/ directory.
  • Rebuild and redeploy the Docker image after making changes.