Skip to main content

A read-only Kubernetes MCP server for safely interacting with Kubernetes clusters

Project description

Kubernetes Read Only MCP Server

A Model Context Protocol (MCP) server for safely interacting with Kubernetes clusters using read-only operations.

This MCP server was created to provide a secure way to interact with Kubernetes clusters without allowing any create, update, or delete operations. It only exposes read-only APIs to ensure your clusters remain safe while still enabling AI assistants to help you monitor and troubleshoot your Kubernetes resources.

Built with FastMCP 2.0 and the official Kubernetes Python client library.

Blog Post and Demo Video

Read more about running the MCP server using Amazon Q CLI at https://vijay.eu/posts/building-my-first-mcp-server/

Features

This MCP server provides the following read-only tools:

  • list_pods: List all pods in a namespace or across all namespaces
  • list_deployments: List all deployments in a specified namespace
  • list_services: List all services in a namespace or across all namespaces
  • list_namespaces: List all namespaces in the cluster
  • get_events: Get Kubernetes events from the cluster
  • get_pod_logs: Get logs from a specific pod
  • get_logs: Get logs from pods, deployments, jobs, or resources matching a label selector

Prerequisites

  • Kubernetes cluster creation and configuring your kubectl must be done before starting the installation. Default K8s context will be used.
  • For demo purposes, you can use kind and docker to setup a local k8s cluster running quickly in your local machine.
  • Refer to this quickstart: https://kind.sigs.k8s.io/docs/user/quick-start/

Installation

MCP configuration

Add this to your MCP Server configuration file:

{
  "mcpServers": {
    "kubernetes-readonly-mcp": {
        "command": "uvx",
        "args": ["kubernetes-readonly-mcp@latest"]
    }
  }
}

Every MCP Hosts/Clients manages their MCP Server configuration differently. If you are using it for the first time then most probably mcp configuration file might not be present. You might have to create it and paste the above JSON text into it.

Here is related documentation for Claude Desktop and Amazon Q CLI:

  1. Claude Desktop: https://modelcontextprotocol.io/quickstart/user
  2. Amazon Q CLI: https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-configuration.html

Verify Installation

Verify that your MCP Host/Client is restarted and the kubernetes-readonly-mcp MCP server is visible in the list.

You can use Amazon Q CLI, Claude Desktop, VSCode + Cline, or any other MCP-compatible client.

Example Prompts

  1. "Get list of pods from my kubernetes cluster"
  2. "Are there any failing pods? Debug why they are failing"
  3. "Show me the logs from the nginx deployment"
  4. "List all services in the default namespace"

License

Apache License 2.0

Disclaimer

This is an experimental project and not production-ready. Use it at your own discretion.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kubernetes_readonly_mcp-0.1.3.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kubernetes_readonly_mcp-0.1.3-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file kubernetes_readonly_mcp-0.1.3.tar.gz.

File metadata

  • Download URL: kubernetes_readonly_mcp-0.1.3.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for kubernetes_readonly_mcp-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f0dd40794d791b1e80217c7446d8f0bda72e53ff254d57d18838c3afbc99a285
MD5 1e1df12dece335e323ecd364eb15eed8
BLAKE2b-256 ecbea03bc43daa06487446c46538160412b6f901c9af74c55d6d410d7d701d16

See more details on using hashes here.

File details

Details for the file kubernetes_readonly_mcp-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for kubernetes_readonly_mcp-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fbd94d8c09d7b2d9778ae0d505076e382efd8b67ae101e54621dd5e7f8aa4991
MD5 b5ef62e11cf2ff8a86b74615382d5336
BLAKE2b-256 b6fb01979fc94ba0d5c5130021bf34217d51bfe004b3e41fd652839783e91edf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page