Kubernetes Read Only MCP Server
Provides read-only access to Kubernetes cluster resources, allowing listing of pods, deployments, services, namespaces, nodes, and fetching logs from pods and other resources.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Kubernetes Read Only MCP Server list pods in all namespaces"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 3.x (the standalone fastmcp framework) and the official Kubernetes Python client library. Secret values are never exposed: for any Secret, only its metadata and type are returned, never data or stringData.
Blog post and Demo
Watch the demo and read the write-up at https://vijay.eu/posts/building-my-first-mcp-server/
Related MCP server: homelab-mcp
Features
This MCP server provides the following read-only tools. Every tool is annotated read-only (readOnlyHint=True, destructiveHint=False) and returns native structured data.
Curated tools
list_pods: List all pods in a namespace or across all namespaceslist_deployments: List all deployments in a specified namespacelist_services: List all services in a namespace or across all namespaceslist_namespaces: List all namespaces in the clusterget_events: Get Kubernetes events from the clusterget_pod_logs: Get logs from a specific podget_logs: Get logs from pods, deployments, jobs, or resources matching a label selectorlist_nodes: List all nodes in the cluster and their status
Generic tools (any kind, including CRDs)
These use the Kubernetes dynamic client, so they work for built-in kinds and Custom Resources alike. They are GET/LIST only and never mutate the cluster.
list_resource: List resources of anykind(e.g.Ingress,ConfigMap, a CRD), optionally scoped byapi_version,namespace,label_selector, andfield_selector.get_resource: Get a single resource of anykindbyname(with optionalapi_versionandnamespace).list_api_resources: Discover which resource kinds the cluster exposes and can be listed (returnsgroup_version,kind,namespaced, andverbs), so you know what to pass to the tools above.
Secret safety: even
list_resource/get_resourcewithkind="Secret"return only metadata andtype— thedataandstringDatafields are always stripped before output.
Prerequisites
Python 3.10 or higher.
uvis installed (it providesuvx). If not, install it withpip install uv(orpipx install uv).Kubernetes cluster up and running.
Kubeconfig configured with a default context.
For demo purposes, you can use kind and Docker to set up a local Kubernetes cluster quickly on your machine. Refer to this quickstart: https://kind.sigs.k8s.io/docs/user/quick-start/
General MCP Host Configuration
Different MCP Hosts (AI assistants or CLIs that support MCP) manage their MCP server configurations in different ways. Generally, you tell your MCP Host how to start the kubernetes-readonly-mcp server. This involves:
The command to run the server. For
kubernetes-readonly-mcpthis isuvx kubernetes-readonly-mcp@latest, which usesuvxto download and run the package from PyPI.Any necessary arguments.
A working directory, if the host requires one.
uvx handles downloading and running kubernetes-readonly-mcp on first invocation; no separate install step is needed. The server communicates over STDIO.
Host-specific, copy-paste configuration follows below. You can find more information about the Model Context Protocol at:
Example Host Documentation:
Claude Code: MCP
Codex CLI: MCP
Kiro CLI: MCP Configuration
Antigravity: Editor MCP and CLI MCP
Claude Desktop: Connect to local MCP servers
Host Setup
1. Claude Code
Add the server with the CLI (the -- separates Claude Code's own flags from the command to run; STDIO is the default transport). Without an explicit scope, Claude Code stores this as a local, private server for the current project:
claude mcp add kubernetes-readonly-mcp -- uvx kubernetes-readonly-mcp@latestTo share the server with a project (committed to the repo), add it with project scope:
claude mcp add --scope project kubernetes-readonly-mcp -- uvx kubernetes-readonly-mcp@latestOr create a .mcp.json at the project root:
{
"mcpServers": {
"kubernetes-readonly-mcp": {
"command": "uvx",
"args": ["kubernetes-readonly-mcp@latest"]
}
}
}2. Codex CLI
Add the server with the CLI:
codex mcp add kubernetes-readonly-mcp -- uvx kubernetes-readonly-mcp@latestCodex CLI and the Codex IDE extension share MCP configuration. You can also add the server directly to ~/.codex/config.toml:
[mcp_servers.kubernetes-readonly-mcp]
command = "uvx"
args = ["kubernetes-readonly-mcp@latest"]Use codex mcp list to verify it is configured.
3. Kiro CLI
Kiro CLI is the rebranded next update of Amazon Q Developer CLI. Add the server with the CLI:
kiro-cli mcp add --name kubernetes-readonly-mcp --scope global --command uvx --args kubernetes-readonly-mcp@latestOr configure servers in ~/.kiro/settings/mcp.json (user scope) or <project>/.kiro/settings/mcp.json (project scope):
{
"mcpServers": {
"kubernetes-readonly-mcp": {
"command": "uvx",
"args": ["kubernetes-readonly-mcp@latest"],
"disabled": false
}
}
}If you previously used Amazon Q, migrate your old ~/.aws/amazonq/mcp.json entries to ~/.kiro/settings/mcp.json.
4. Antigravity (Google)
Antigravity Editor reads MCP servers from ~/.gemini/antigravity/mcp_config.json (on Windows, C:\Users\<USER>\.gemini\antigravity\mcp_config.json). You can open this file from the app: the "..." menu -> MCP Servers -> Manage MCP Servers -> View raw config.
Antigravity CLI v2.0+ also supports MCP. Open the CLI MCP manager with /mcp, or add the same server block to ~/.gemini/antigravity-cli/mcp_config.json for global CLI setup. For a workspace-local CLI setup, use .agents/mcp_config.json in the active project.
{
"mcpServers": {
"kubernetes-readonly-mcp": {
"command": "uvx",
"args": ["kubernetes-readonly-mcp@latest"]
}
}
}5. Claude Desktop
Edit claude_desktop_config.json (on macOS, ~/Library/Application Support/Claude/claude_desktop_config.json; on Windows, %APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"kubernetes-readonly-mcp": {
"command": "uvx",
"args": ["kubernetes-readonly-mcp@latest"]
}
}
}Restart Claude Desktop after editing so it picks up the new server.
Verifying the setup
kubernetes-readonly-mcp is a STDIO MCP server: running it starts a process that speaks the MCP protocol over standard input/output and waits for an MCP host to connect. It does not take a tool name as a command-line argument.
To confirm uvx can fetch and launch the package, run:
uvx kubernetes-readonly-mcp@latestThe process will start and wait silently for an MCP client (press Ctrl+C to stop). It will not print a namespace list — tools are invoked by an MCP host, not from the shell. Beyond that, verification depends on your MCP host: after configuration, the server and its tools should appear in the host's interface, where you can invoke them.
Example Prompts
"Get list of pods from my kubernetes cluster"
"Are there any failing pods? Debug why they are failing"
"Show me the logs from the nginx deployment"
"List all services in the default namespace"
"List all ingresses across every namespace" (uses the generic
list_resourcetool withkind="Ingress",api_version="networking.k8s.io/v1")
License
Apache License 2.0
Disclaimer
This is an experimental project and not production-ready. Use it at your own discretion.
Available Tools
11 toolsget_eventsGet EventsBRead-onlyIdempotent
Get Kubernetes events from the cluster for a specific namespace or all namespaces
Inputs: namespace, field_selector.
get_logsGet LogsBRead-onlyIdempotent
Get logs from pods, deployments, jobs, or resources matching a label selector
Inputs: resource_type (required), namespace, name, label_selector, +4 more.
get_pod_logsGet Pod LogsCRead-onlyIdempotent
Get logs from a pod in a specified namespace
Inputs: namespace (required), pod_name (required), container, tail_lines, +1 more.
get_resourceGet ResourceARead-onlyIdempotent
Get a single resource of any kind (including CRDs) by name via the dynamic client. GET only; never mutates.
Inputs: kind (required), name (required), api_version, namespace.
list_api_resourcesList API ResourcesARead-onlyIdempotent
Discover which resource kinds (including CRDs) the cluster exposes and can be listed. Read-only discovery.
Inputs: no named parameters.
list_deploymentsList DeploymentsBRead-onlyIdempotent
List all deployments in a specified namespace
Inputs: namespace.
list_namespacesList NamespacesARead-onlyIdempotent
List all namespaces in the cluster
Inputs: no named parameters.
list_nodesList NodesARead-onlyIdempotent
List all nodes in the cluster
Inputs: no named parameters.
list_podsList PodsARead-onlyIdempotent
List all pods in a namespace or across all namespaces
Inputs: namespace.
list_resourceList ResourceARead-onlyIdempotent
List resources of any kind (including CRDs) via the dynamic client. GET/LIST only; never mutates.
Inputs: kind (required), api_version, namespace, label_selector, +1 more.
list_servicesList ServicesARead-onlyIdempotent
List all services in a namespace or across all namespaces
Inputs: namespace.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Most tools have distinct purposes, but get_logs and get_pod_logs have overlapping functionality; however, their descriptions clarify that get_logs is for broader resource types while get_pod_logs targets a specific pod, reducing ambiguity.
All tool names follow a consistent verb_noun pattern with underscores (e.g., get_events, list_pods), making the set predictable and easy to navigate.
With 11 tools, the server is well-scoped for a read-only Kubernetes interface, covering essential resources and operations without unnecessary bloat or omissions.
The set includes generic get_resource and list_resource for CRDs, plus specific tools for common resources, logs, events, and API discovery, providing comprehensive read-only coverage without obvious gaps.
Maintenance
Related MCP Connectors
Provides read access to your GKE and Kubernetes resources.
Read-only access to a Lumin project's logs, metrics, uptime checks, alerts and infrastructure.
Read-only access to your Infrly services, deploys, logs, metrics and billing.
Read-only access to your KollGuard SOC 2 / HIPAA findings, posture, scans and tickets.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceProvides read-only access to Kubernetes clusters for AI assistants.25MIT
- AlicenseBqualityBmaintenanceEnables AI agents to inspect and operate a Kubernetes cluster safely, with read-only mode and namespace allowlist for mutations.1072 PyPI2MIT
- FlicenseNot gradedqualityBmaintenanceEnables read-only Kubernetes incident investigation through MCP tools for listing pods, describing resources, fetching logs, and searching runbooks.1-
- FlicenseNot gradedqualityDmaintenanceProvides a read-only interface to Kubernetes clusters, enabling LLMs to list pods, get pod status and logs, fetch deployment manifests, and perform pod health analysis with resource trend tracking.-