Kubernetes Read-Only MCP
The server is a read-only MCP tool for diagnosing Kubernetes clusters without creating or changing cluster objects.
Discover available cluster contexts from kubeconfig files with
list_clusters.Assess cluster health, node readiness, namespaces, pods, deployments, statefulsets, and events.
Inspect pod details and read bounded container logs (2,000 lines max).
Read ConfigMaps, list Secret metadata only, and inspect storage and RBAC resources.
Discover CRDs and API resources, then use generic
list_resources/get_resourceto read any object by apiVersion and kind.Filter resource listings by namespace, label selectors, field selectors, limits, and continue tokens.
All operations use read-only Kubernetes APIs and MCP read-only annotations; no shell, watch, exec, port-forwarding, or mutating actions.
Provides read-only diagnostics for Kubernetes clusters, including listing clusters, nodes, namespaces, pods, deployments, statefulsets, events, storage, RBAC resources, CRDs, and API resources, as well as describing pods, fetching pod logs, reading ConfigMaps and Secrets, and retrieving arbitrary resource objects when RBAC allows.
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 List clusters and then check the health of the production context."
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
MCP server for diagnosing Kubernetes clusters without creating or changing cluster objects.
Prerequisites
uvOne or more readable kubeconfig files in
~/.kube/configs(or a custom path viaKUBECONFIG_DIRECTORY/KUBECONFIG_DIRenvironment variables)Kubernetes RBAC limited to read-only permissions, for defense in depth
The MCP identifier for a cluster is the Kubernetes context name declared inside a kubeconfig, not the file name. Use list_clusters first to discover the available contexts. When the same context occurs in more than one file, the server uses the first file in alphabetical order and lists only the ignored file names in duplicate_kubeconfig_files.
Related MCP server: k8s-mcp-server
Configuration
By default, the server looks for kubeconfig files in ~/.kube/configs (using the current user's $HOME or Path.home()). You can override this path by setting environment variables:
KUBECONFIG_DIRECTORYorKUBECONFIG_DIR: Full or relative path to the directory containing kubeconfig files (e.g./home/user/.kube/configsor~/.kube/configs).
Remote Environments (VS Code Remote SSH / Tunnels)
When connecting to VS Code via Remote SSH or Tunnels:
Open this repository as a workspace inside the remote window.
VS Code will execute
uv run main.pydirectly on the remote server using the workspace .vscode/mcp.json, resolving$HOMEand~/.kube/configsfrom the remote host.If you need to explicitly point to a specific directory in .vscode/mcp.json, you can define the
envblock:
{
"servers": {
"kubernetes-readonly": {
"type": "stdio",
"command": "uv",
"args": ["run", "main.py"],
"env": {
"KUBECONFIG_DIRECTORY": "${env:HOME}/.kube/configs"
}
}
}
}Run
uv run main.pyor:
make runThe server uses the MCP stdio transport. VS Code can use the included .vscode/mcp.json configuration.
Use in VS Code
Open this repository as a folder or workspace in VS Code and mark it as trusted.
Open the Command Palette with
Ctrl+Shift+Pand runMCP: List Servers.Select
kubernetes-readonlyand start it if it is not already running. VS Code executesuv run main.pyfrom this workspace using .vscode/mcp.json.In Copilot Chat, select the
kubernetes-readonlyserver in the tools picker. Asklist_clustersfirst, then use the returned context name as theclusterargument in subsequent requests.
For example: Use list_clusters and then show the health of the context <context-name>. The server runs over stdio, so do not start it manually with make run while VS Code is managing the server.
Available diagnostics
list_clusters,get_cluster_health,list_nodes,list_namespaceslist_pods,describe_pod,get_pod_logslist_deployments,list_statefulsets,list_eventslist_storage,list_rbac,get_configmap,list_secretslist_crds,list_api_resources,list_resources,get_resource
Use list_crds to discover installed CRDs, their groups, kinds, scopes, and served versions. Use list_api_resources to discover any built-in or custom Kubernetes API resource available to the selected context. Then use list_resources or get_resource with the returned api_version and kind to read full resource objects, including CRDs and Secret data when Kubernetes RBAC allows it. list_resources supports namespace, label_selector, field_selector, limit, and continue_token for large result sets; omitting namespace lists namespaced resources across the whole cluster.
Pod logs are limited to 2,000 lines per request. They may contain sensitive application data. ConfigMap values are returned for diagnosis. list_secrets returns only Secret metadata and key names, while get_resource can return the full Secret object for agents that need unrestricted read access and have RBAC permission.
Read-only boundary
Every tool is marked with MCP's read-only annotation and directly invokes only Kubernetes discovery, read_*, list_*, log read or dynamic-client GET calls. The server exposes no shell commands, watch streams, pod execution, port forwarding, or mutating Kubernetes APIs. The annotation is advisory, so actual protection must also come from read-only Kubernetes RBAC assigned to the credentials in each kubeconfig.
Available Tools
18 toolsdescribe_podARead-only
Return detailed status, container state and conditions for a Pod.
Inputs: name (required), cluster (required), namespace (required). Returns: object
get_cluster_healthBRead-only
Get Kubernetes version and a summary of node readiness for one context.
Inputs: cluster (required). Returns: object
get_configmapARead-only
Read a ConfigMap including its data. Review returned data for sensitive values.
Inputs: name (required), cluster (required), namespace (required). Returns: object
get_pod_logsARead-only
Read a bounded tail of container logs. Logs may contain sensitive application data.
Inputs: name (required), cluster (required), namespace (required), previous, +2 more. Returns: result
get_resourceBRead-only
Get any Kubernetes resource object by apiVersion, kind and name.
Inputs: kind (required), name (required), cluster (required), api_version (required), +1 more. Returns: object
list_api_resourcesCRead-only
Discover Kubernetes API resources, including CRDs, that can be queried.
Inputs: cluster (required), kind, api_version. Returns: result
list_clustersARead-only
List contexts and kubeconfig files skipped due to duplicate contexts.
Inputs: no named parameters. Returns: object
list_crdsBRead-only
List all installed CustomResourceDefinitions and their served versions.
Inputs: cluster (required). Returns: result
list_deploymentsBRead-only
List Deployments and replica readiness.
Inputs: cluster (required), namespace. Returns: result
list_eventsBRead-only
List recent warning and normal Kubernetes events, newest first.
Inputs: cluster (required), hours, namespace. Returns: result
list_namespacesBRead-only
List namespaces and their phases.
Inputs: cluster (required). Returns: result
list_nodesBRead-only
List nodes with readiness, roles, version and pressure conditions.
Inputs: cluster (required). Returns: result
list_podsBRead-only
List Pods, optionally restricting results to Pods with failure signals.
Inputs: cluster (required), namespace, problems_only. Returns: result
list_rbacBRead-only
List Roles, RoleBindings, ClusterRoles and ClusterRoleBindings as metadata.
Inputs: cluster (required), namespace. Returns: object
list_resourcesBRead-only
List any Kubernetes resource kind using apiVersion/kind discovery.
Inputs: kind (required), cluster (required), api_version (required), limit, +4 more. Returns: object
list_secretsARead-only
List Secret metadata only; secret values are never returned.
Inputs: cluster (required), namespace. Returns: result
list_statefulsetsARead-only
List StatefulSets and replica readiness.
Inputs: cluster (required), namespace. Returns: result
list_storageBRead-only
List PersistentVolumeClaims, PersistentVolumes and StorageClasses.
Inputs: cluster (required), namespace. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Most tools target clearly distinct resource areas, but list_api_resources, list_crds, and list_resources have similar names and overlapping discovery/list purposes. Generic list/get tools also overlap with specialized listers, though descriptions clarify their intended use.
All tools consistently use lowercase snake_case verb_noun naming: list_* for collections, get_* for single objects and logs, and describe_pod for detailed pod status. No mixed conventions or unpredictable patterns.
18 tools is slightly above the typical 3-15 well-scoped range, but the breadth of Kubernetes read-only scenarios justifies the count. Each tool addresses a meaningful area and the overlap is modest.
The surface covers cluster health, discovery, common workloads, events, storage, RBAC, and secrets, with generic list_resources/get_resource filling gaps for resource types without dedicated tools. Missing convenience getters for services, ingresses, and jobs, but no dead ends exist.
Maintenance
Related MCP Connectors
Provides read access to your GKE and Kubernetes resources.
Read-only server insight: why a Linux server or K8s cluster is slow, failing or changed.
kube-linter audit for Kubernetes manifests — 63 checks: security, availability, RBAC, network.
Deploy and operate Kubernetes: clusters, stacks, apps, logs, metrics and security, with OAuth.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables real-time Kubernetes cluster observability and debugging through standardized MCP interface. Provides access to pods, services, nodes, events, and includes built-in tools for cluster health analysis and issue identification.-
- FlicenseNot gradedqualityDmaintenanceEnables read-only interaction with a Kubernetes cluster, allowing listing of nodes, pods, deployments, and services, as well as fetching pod logs.-
- AlicenseNot gradedqualityBmaintenanceEnables read-only Kubernetes cluster diagnostics through MCP tools, allowing a local LLM to inspect pods and events and debug issues via natural language queries.MIT
- AlicenseBqualityCmaintenanceEnables read-only, stack-aware diagnostics for microservices on Kubernetes, turning debugging runbooks into conversational tools that investigate slow requests, changes, leaks, and in-pod conditions without exposing cluster credentials.57Apache 2.0