Kubernetes tools#
The Lens MCP Server provides four Kubernetes tools for managing and investigating your clusters. The kubectl tool runs read-only commands. For the tools that work in Lens itself, see Lens tools.
Prerequisites#
- Lens MCP Server enabled and connected to your MCP client (see Get started with Lens MCP Server)
- Lens K8S IDE running with at least one cluster added
list-clusters#
List all Kubernetes clusters known to Lens K8S IDE with their connection status.
Parameters: None
Example prompt: "List all my Kubernetes clusters in Lens."
Response format:
[
{
"id": "cluster-abc123",
"name": "production-eks",
"contextName": "arn:aws:eks:us-east-1:123456:cluster/production",
"kubeconfigFilePath": "/Users/you/.kube/config",
"connectionStatus": "connected"
}
]
The response includes clusters from all sources: local kubeconfig, AWS EKS integration, Azure AKS integration, and Lens Teamwork Spaces.
connect-cluster#
Connect to a Kubernetes cluster by its ID. Use list-clusters first to find available cluster IDs.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
clusterId |
string | Yes | The cluster ID from list-clusters |
Example prompt: "Connect to my production EKS cluster."
Response: Connected to cluster "production-eks" (cluster-abc123)
disconnect-cluster#
Disconnect Lens from a Kubernetes cluster.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
clusterId |
string | Yes | The cluster ID to disconnect from |
Example prompt: "Disconnect from the staging cluster."
Response: Disconnected from cluster "staging-eks" (cluster-def456)
kubectl#
Run read-only kubectl commands against a connected cluster.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
clusterId |
string | Yes | The cluster ID to run the command against |
command |
string[] | Yes | The kubectl arguments as an array |
Allowed read-only commands:
| Command | Description |
|---|---|
get |
List resources |
describe |
Show resource details |
logs |
View container logs |
top |
Display resource usage (CPU/memory) |
api-resources |
List available resource types |
api-versions |
List available API versions |
cluster-info |
Show cluster endpoint information |
config |
Show kubeconfig settings |
events |
List cluster events |
auth |
Check authorization |
explain |
Show resource documentation |
version |
Show cluster version |
Blocked commands: the Lens MCP Server rejects every command missing from the table above, for example delete, edit, create, apply, replace, patch, scale, drain, or cordon. It rejects them before it runs kubectl.
Warning
The Lens MCP Server rejects a command when an argument contains a shell operator (|, &, ;, <, >, `, $, \). It checks the arguments before it runs kubectl.
Example prompts:
- "Show me all pods in the kube-system namespace."
- "Describe the nginx deployment in the default namespace."
- "Show me the logs for the api-server pod."
- "What is the CPU and memory usage across all nodes?"
Argo CD, Argo Rollouts, and Flux
The kubectl tool reads Argo CD, Argo Rollouts, and Flux resources, as it reads any custom resource. Ask, for example, "Which Argo CD Applications are out of sync?"
Example command (internal):
{
"clusterId": "cluster-abc123",
"command": ["get", "pods", "-n", "kube-system", "-o", "wide"]
}
Typical workflow#
- List clusters to discover what is available.
- Connect to the clusters you want to investigate.
- Run kubectl commands to investigate resources, check logs, and view events.
- Disconnect from clusters you no longer need.
You do not need to call these tools directly. Describe what you want in natural language and your MCP client selects the appropriate tool.
Related topics#
-
Get started with Lens MCP Server
Enable the MCP Server and connect your MCP client.
-
Query metrics, view alerts, inspect targets, and run PromQL queries.
-
Navigation, dock, Helm, port forwards, costs, extensions, and driving Lens.