K8s Lens MCP

K8s Lens MCP

Enables natural language Kubernetes operations, including smart resource queries, pod root-cause analysis, cross-environment diffs, and manifest generation.

Category
Visit Server

README

🔭 K8s Lens MCP

A Model Context Protocol (MCP) server for intelligent, natural-language-powered Kubernetes operations.

Stop memorizing kubectl flags. Ask your cluster questions in plain English.


✨ What It Does

K8s Lens MCP exposes deep analytical tools to any MCP-compatible AI assistant (Claude, Cursor, Copilot, etc.):

Capability Example Prompt
Smart Resource Queries "Show me all pods with status CrashLoopBackOff in namespace staging"
Pod Root-Cause Analysis "Why is this pod failing?" — correlates events, logs, resource limits, and node conditions
Cross-Environment Diff "Diff the nginx deployment between staging and prod"
Manifest Generation "Create a basic nginx deployment with 2 replicas and a LoadBalancer service"

Unlike thin kubectl wrappers, K8s Lens MCP analyzes and correlates data so the AI can give you real answers, not just raw command output.


🚀 Quick Start

1. Install

pip install k8s-lens-mcp

Or with Poetry:

poetry add k8s-lens-mcp

2. Configure Your AI Client

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "k8s-lens": {
      "command": "k8s-lens-mcp",
      "args": []
    }
  }
}

Cursor

Add to Cursor Settings → MCP:

{
  "mcpServers": {
    "k8s-lens": {
      "command": "k8s-lens-mcp",
      "args": []
    }
  }
}

3. Start Talking to Your Cluster

Open Claude or Cursor and ask:

"Show me all failing pods in the default namespace and tell me why they're failing."


🛡️ Safety First

  • Read-only by default — the server starts in --read-only mode. No accidental deletions.
  • RBAC-respecting — we use your kubeconfig / ServiceAccount. We don't bypass Kubernetes permissions.
  • Secret masking — Kubernetes Secret data is never returned in tool output.

To enable read-write mode (future feature):

k8s-lens-mcp --read-only=false

🏗️ Development

Prerequisites

  • Python 3.11+
  • Poetry
  • A Kubernetes cluster (e.g. kind, minikube, or a remote cluster)

Setup

git clone https://github.com/yourusername/k8s-lens-mcp.git
cd k8s-lens-mcp
poetry install

Run Locally

poetry run k8s-lens-mcp

Test with MCP Inspector

npx @modelcontextprotocol/inspector poetry run k8s-lens-mcp

Run Tests

poetry run pytest

Lint & Format

poetry run ruff check .
poetry run ruff format .

📋 Roadmap

  • [x] Core MCP server scaffold
  • [x] get_resources — filtered resource queries
  • [x] analyze_pod — multi-signal root cause analysis
  • [x] compare_deployments — cross-environment diffing
  • [x] generate_manifest — best-practice manifest generation
  • [ ] Cost / resource optimization advisor
  • [ ] Multi-cluster context aggregation
  • [ ] Helm release values diffing
  • [ ] In-cluster deployment (Helm chart)
  • [ ] kubectl plugin wrapper (kubectl lens "...")

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Please read our Code of Conduct.


📄 License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured