Skip to content

Get started with Lens MCP Server#

In this guide, you will enable the Lens MCP Server and connect it to an MCP client. This takes about 5 minutes.

Prerequisites#

  • A Plus, Pro, or Enterprise subscription plan. For details, see Lens Pricing .
  • Lens K8S IDE installed and running.
  • At least one Kubernetes cluster added to Lens.
  • An MCP client installed and configured.

Step 1: Enable the MCP Server#

  1. Open Lens.
  2. Navigate to Preferences > Integrations.
  3. Scroll to the AI & Intelligence Integrations section.
  4. Locate Enable Lens MCP Server and turn the toggle on.

Note

The Lens CLI is bundled with Lens K8S IDE. You do not need to install or enable a separate Lens CLI setting for the MCP Server to work.

When you turn the toggle on, Lens also writes the client configuration to ~/.k8slens/.mcp.json, unless that file already exists.

Step 2: Configure your MCP client#

  1. In Preferences > Integrations > AI & Intelligence Integrations > Enable Lens MCP Server, click Configure your MCP client to expand the configuration snippet. This control is only visible when the MCP Server toggle is on.

    Preferences > Integrations with Enable Lens MCP Server on and Configure your MCP client expanded: the configuration snippet with the command, args, and env entries, and the copy icon in its top-right corner

  2. Click the copy icon in the top-right corner of the snippet (tooltip Copy to clipboard). The snippet holds the absolute path to the bundled Lens CLI, so your MCP client can launch the server without relying on your shell PATH. Its env entry points the CLI at this Lens, and not at another Lens build running at the same time.

    An example of the copied snippet looks like this:

    {
      "mcpServers": {
        "lens": {
          "command": "<absolute path to the bundled Lens CLI>",
          "args": ["mcp-server"],
          "env": { "LENS_CLI_API_SOCKET": "<path to the socket of this Lens>" }
        }
      }
    }
    
  3. Paste the snippet into your MCP client configuration. For example, add it to your project's .mcp.json.

The paths in the snippet differ per platform and installation, so copy the snippet from Lens instead of typing them. The configuration file and its format vary by MCP client, and some clients add servers through their own interface. See your client's documentation. After you add or change the configuration, restart your MCP client session so that it detects the server.

Step 3: Verify the connection#

Ping the server#

  1. Open your MCP client.
  2. Ask the MCP client to ping the server. For example: "Ping the Lens MCP server."
  3. Verify that the response is pong.

Tip

If you do not receive a pong response, restart your MCP client session and confirm that its configuration matches the snippet in Lens, and that Lens is running.

List your clusters#

  1. Ask the MCP client to list your clusters. For example: "List all Kubernetes clusters in Lens."
  2. Verify that your clusters appear in the response with their connection status.

Expected output:

[
  {
    "id": "a1b2c3d4e5f6",
    "name": "my-eks-cluster",
    "contextName": "arn:aws:eks:us-east-1:123456789012:cluster/my-eks-cluster",
    "kubeconfigFilePath": "/Users/you/.kube/config",
    "connectionStatus": "disconnected"
  },
  {
    "id": "f6e5d4c3b2a1",
    "name": "minikube",
    "contextName": "minikube",
    "kubeconfigFilePath": "/Users/you/.kube/config",
    "connectionStatus": "connected"
  }
]

Step 4: Run your first command#

Ask your MCP client to retrieve information from one of the clusters listed in Step 3.

Example prompt:

Show me all pods in the default namespace on minikube

The MCP client calls the Lens MCP Server, runs a read-only kubectl get pods command against the specified cluster, and returns the results.

Tip

Replace minikube with the name of any cluster from your Step 3 output.

Completed

You have connected your MCP client to Lens K8S IDE through the MCP Server. You can now inspect resources, troubleshoot clusters, and query Prometheus metrics using natural language.

Next steps#

  • Kubernetes tools


    List clusters, connect to them, and run read-only kubectl commands.

  • Prometheus tools


    Query metrics, view alerts, inspect targets, and run PromQL queries.

  • Lens tools


    Navigation, dock, Helm, port forwards, costs, extensions, and driving Lens.

  • Configure AWS EKS integration


    Video: set up the AWS EKS integration, so the MCP Server reaches your EKS clusters.