Kubernetes tools#
The Lens MCP Server provides four Kubernetes tools for managing and investigating your clusters. All operations are read-only.
Prerequisites#
- Lens MCP Server enabled and connected to your MCP client (see Get started with Lens MCP Server)
- Lens Desktop running with at least one cluster added
list-clusters#
List all Kubernetes clusters known to Lens Desktop 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 from a Kubernetes cluster. Use this to filter which clusters your MCP client investigates.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
clusterId |
string | Yes | The cluster ID to disconnect from |
Example prompt: "Disconnect from the staging cluster, I only want to look at production."
Response: Disconnected from cluster "staging-eks" (cluster-def456)
Tip
Use connect and disconnect to narrow your investigation scope. Connect only to the clusters you want to troubleshoot, then ask your MCP client to "check all connected clusters."
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 |
events |
List cluster events |
auth |
Check authorization |
explain |
Show resource documentation |
version |
Show cluster version |
ping |
Test connectivity to the Lens MCP Server |
Blocked commands: delete, edit, create, apply, replace, patch, scale, drain, cordon, and all other mutating operations.
Warning
Shell operators (|, &, ;, <, >, `, $, \) are blocked in command arguments for security.
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?"
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.