Skip to content

Lens CLI#

The Lens CLI is a command-line interface that extends Lens Desktop to your terminal. Use it to list and connect to clusters, retrieve authentication tokens for cloud providers, and enable integrations such as the Lens MCP Server.

Command summary#

Command Description
lens open Open Lens Desktop from the terminal
lens clusters ls List all clusters
lens clusters show Show cluster details
lens clusters connect Connect to a cluster
lens clusters disconnect Disconnect from a cluster
lens get-eks-token Retrieve an AWS EKS authentication token
lens get-aks-token Retrieve an Azure AKS authentication token
lens teamwork get-exec-credential Retrieve a Lens Teamwork Space credential
lens completion Generate shell auto-completion scripts
lens version Display Lens CLI version
lens help Display help for any command

Prerequisites#

  • You have a Plus, Pro, or Enterprise subscription plan. For details, see Lens Pricing
  • Lens Desktop installed and running
  • Lens CLI enabled in Preferences > App > Lens CLI

Note

On Windows, the Lens CLI is available in your PATH by default. On macOS and Linux, toggle Lens CLI on in Preferences > App to add it to your PATH.

Verify the installation#

Run the following command to confirm the Lens CLI is accessible:

lens version

If the command returns a version string, the CLI is ready to use. If the command is not found, verify that the Lens CLI toggle is enabled in Preferences > App and restart your terminal.

Commands#

lens open#

Open the Lens Desktop application from your terminal.

lens open
Flag Description
-w, --no-wait Return immediately without waiting for the application to start

lens clusters ls#

List all clusters available in Lens Desktop.

# List clusters in JSON format
lens clusters ls --output json
Flag Description
-o, --output Output format: json or yaml
-s, --space Filter results by Lens Teamwork Space name

lens clusters show#

Display details for a specific cluster.

lens clusters show <cluster-name>
Flag Description
-o, --output Output format: json or yaml
-s, --space Lens Teamwork Space name

lens clusters connect#

Connect to a cluster and make it the active context.

lens clusters connect <cluster-name>
Flag Description
--open Also open the Lens Desktop application
-s, --space Lens Teamwork Space name

lens clusters disconnect#

Disconnect from a cluster.

lens clusters disconnect <cluster-name>
Flag Description
-s, --space Lens Teamwork Space name

lens get-eks-token#

Retrieve an authentication token for an AWS EKS cluster. For details on adding EKS clusters, see Add AWS EKS clusters.

lens get-eks-token <cluster-name> <region> <profile>
Argument Description
<cluster-name> Name of the EKS cluster
<region> AWS region where the cluster runs
<profile> AWS CLI profile to use for authentication

lens get-aks-token#

Retrieve an authentication token for an Azure AKS cluster. For details on adding AKS clusters, see Add Azure AKS clusters.

lens get-aks-token <cluster-name> <resource-group> <subscription-id> <tenant-id>
Argument Description
<cluster-name> Name of the AKS cluster
<resource-group> Azure resource group containing the cluster
<subscription-id> Azure subscription ID
<tenant-id> Azure Active Directory tenant ID

lens teamwork get-exec-credential#

Retrieve an exec credential for a cluster shared through a Lens Teamwork Space.

lens teamwork get-exec-credential <spaceName> <clusterId>
Argument Description
<spaceName> Name of the Lens Teamwork Space
<clusterId> ID of the cluster in the Space

lens completion#

Generate shell auto-completion scripts. After generating the script, restart your shell or source the completion file.

lens completion bash > $(brew --prefix)/etc/bash_completion.d/lens
lens completion bash > /etc/bash_completion.d/lens
lens completion zsh > "${fpath[1]}/_lens"
lens completion fish > ~/.config/fish/completions/lens.fish
lens completion powershell > lens.ps1

lens version#

Display the current Lens CLI version.

lens version

lens help#

Display help information for the Lens CLI or a specific command. Pass a command name as an argument to see its usage, flags, and arguments.

lens help clusters ls

Global flags#

All commands support the following flags:

Flag Description
--debug Enable debug output
-h, --help Display help for any command

Tip

Run lens <command> --help to see available flags and arguments for a specific command.

Requirements#

  • Lens Desktop installed on macOS, Windows, or Linux
  • A Plus, Pro, or Enterprise subscription plan

Limitations#

  • The Lens CLI requires Lens Desktop to be installed. It does not operate as a standalone tool.
  • Cloud token commands (get-eks-token, get-aks-token) require the respective cloud provider CLI credentials to be configured on your machine.