Connect Kubernetes to ChatGPT: Manage Pods, Deployments & Services
Connect Kubernetes to ChatGPT using Truto's auto-generated MCP server. Learn how to securely automate cluster ops, debug pods, and scale deployments.
If you need to connect Kubernetes to ChatGPT to automate cluster operations, scale deployments, or debug crashing pods, you need a Model Context Protocol (MCP) server. This server acts as the critical translation layer between ChatGPT's JSON-RPC tool calls and the Kubernetes API server. You can either spend weeks configuring, securing, and maintaining a custom proxy infrastructure, or you can use a managed integration platform like Truto to dynamically generate a secure, authenticated MCP server URL.
If your team uses Claude, check out our guide on connecting Kubernetes to Claude or explore our broader architectural overview on connecting Kubernetes to AI Agents.
Giving a Large Language Model (LLM) read and write access to a live Kubernetes cluster is a massive engineering challenge. You have to handle complex nested objects, strict JSON merge patch requirements, and sprawling API groups. Every time the cluster gets upgraded or Custom Resource Definitions (CRDs) are introduced, standard static wrappers break down.
This guide breaks down exactly how to use Truto to generate a secure, managed MCP server for Kubernetes, connect it natively to ChatGPT, and execute complex DevOps workflows using natural language.
The Engineering Reality of the Kubernetes API
A custom MCP server is essentially a self-hosted integration layer. While the open MCP standard provides a predictable way for models to discover tools, implementing it against the Kubernetes API is exceptionally painful.
If you decide to build a custom MCP server for Kubernetes, you own the entire API lifecycle. Here are the specific integration challenges that break standard CRUD assumptions when working with Kubernetes:
GroupVersionResource (GVR) Fragmentation
Unlike standard SaaS platforms with a flat REST hierarchy (e.g., /api/v1/users), the Kubernetes API is heavily fragmented by API Groups, Versions, and Resources. A Pod lives in the core/v1 group, but a Deployment lives in apps/v1, and a CronJob lives in batch/v1. If an LLM attempts to interact with your cluster, it cannot simply guess the endpoint path. Your MCP server must dynamically expose schemas that explicitly map to the correct GVR. Without a dynamic schema generation layer, the LLM will constantly hallucinate endpoint paths, resulting in HTTP 404 errors.
JSON Merge Patch Constraints
When an LLM decides to update a resource—for instance, scaling a deployment or adding an annotation—it cannot simply issue a standard PUT request with a partial body. Kubernetes strictly enforces HTTP PATCH using specific content types, most notably application/merge-patch+json or application/strategic-merge-patch+json. Your translation layer must take the flat arguments generated by the LLM, properly nest them according to the Kubernetes OpenAPI specification, and issue the correct patch format. Failure to do so results in API rejection or, worse, completely overwriting nested metadata.
Strict IETF Rate Limiting Headers
Kubernetes control planes actively throttle aggressive list or watch loops to prevent etcd degradation. When connecting an AI agent that might issue rapid successive requests during a complex debugging loop, you will hit HTTP 429 Too Many Requests errors.
Factual note on rate limits: Truto does not retry, throttle, or apply backoff on rate limit errors. When the upstream Kubernetes API returns an HTTP 429, Truto passes that error directly to the caller. Truto normalizes the upstream rate limit info into standardized headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) per the IETF specification. The caller (the AI agent or underlying LLM framework) is entirely responsible for interpreting these headers and executing the appropriate retry and exponential backoff logic.
Creating the Kubernetes MCP Server
Truto solves these architectural challenges by dynamically generating MCP tools based on the Kubernetes API's actual resource definitions and documentation. Instead of hand-coding tools, Truto builds the JSON-RPC interface dynamically. You can create an MCP server for Kubernetes using either the Truto UI or the API.
Method 1: Via the Truto UI
For immediate provisioning without writing code, use the dashboard:
- Navigate to the Integrated Accounts page and select your connected Kubernetes instance.
- Click the MCP Servers tab.
- Click Create MCP Server.
- Select your desired configuration (e.g., limit to
readmethods only, or restrict access via tags likepodsanddeployments). - Copy the generated MCP server URL. This URL contains a cryptographic token that handles routing and authentication natively.
Method 2: Via the Truto API
For teams embedding AI into internal developer platforms or automating cluster access for on-call engineers, generate the server programmatically. A single POST request validates that the connection is active, provisions the server, and returns the URL.
curl -X POST https://api.truto.one/integrated-account/$INTEGRATED_ACCOUNT_ID/mcp \
-H "Authorization: Bearer $TRUTO_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Kubernetes Production Debugger",
"config": {
"methods": ["read"],
"tags": ["core", "apps"]
},
"expires_at": "2026-12-31T23:59:59Z"
}'The response provides the url endpoint (e.g., https://api.truto.one/mcp/<hashed_token>). Treat this URL as a highly sensitive credential.
Connecting the MCP Server to ChatGPT
Once you have the Truto MCP URL, you can connect it to ChatGPT. There are two primary ways to register MCP servers, depending on your client environment.
Method A: Via the ChatGPT UI
If you are using ChatGPT Pro, Plus, Business, Enterprise, or Education accounts, you can add custom connectors directly in the interface:
- In ChatGPT, click your profile and navigate to Settings -> Apps -> Advanced settings.
- Toggle on Developer mode to expose MCP functionality.
- Under MCP servers / Custom connectors, click to add a new server.
- Enter a logical name (e.g., "Production K8s Cluster").
- Paste the Truto MCP server URL into the Server URL field.
- Click Add. ChatGPT will immediately execute an initialization handshake and discover the available Kubernetes tools.
Method B: Via Manual Config File (SSE Transport)
If you are running local agents, using Cursor, or working with standard MCP client tooling that requires a configuration file, you can utilize the @modelcontextprotocol/server-sse package to connect to Truto's remote SSE endpoint.
Create or update your mcp.json (or specific client config file) with the following definition:
{
"mcpServers": {
"kubernetes-prod": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sse",
"--url",
"https://api.truto.one/mcp/YOUR_TRUTO_TOKEN"
]
}
}
}This configuration instructs the local client to initiate a Server-Sent Events (SSE) connection to Truto's remote infrastructure, allowing seamless tool execution without exposing local network boundaries.
Kubernetes Hero Tools
Truto automatically maps the Kubernetes API into discrete, highly documented tools. When ChatGPT lists available tools, it receives explicit JSON schemas dictating exactly which query parameters and payload bodies are required. Here are the highest-leverage tools for DevOps and IT automation.
list_all_kubernetes_pods
Fetches a paginated list of pods across a specific namespace (or cluster-wide, depending on RBAC). This tool accepts label selectors and field selectors, making it the primary entry point for agentic cluster audits.
"Find all pods in the 'kube-system' namespace that currently have a status of 'CrashLoopBackOff' or 'Evicted', and return their exact names and restart counts."
kubernetes_pods_get_log
Retrieves the raw log output for a specific pod. This bypasses the need for engineers to manually context-switch into kubectl logs. The tool maps directly to the /log subresource.
"Fetch the last 100 lines of logs for the pod named 'auth-service-7bb8c8945-xyz' in the 'production' namespace, and identify any database connection timeouts."
list_all_kubernetes_deployments
Queries deployments within a namespace. It returns full manifests, including scale configurations, rollout status, and container image versions.
"List all deployments in the 'staging' namespace and tell me which ones are currently running container images tagged as 'latest' rather than a specific version hash."
kubernetes_deployments_update_scale
Interacts directly with the Scale subresource of a deployment (apps/v1). This allows the agent to modify the replica count without needing to parse or patch the entire complex deployment manifest.
"The frontend deployment in the 'prod' namespace is struggling with high traffic. Check its current replica count, and if it is under 10, scale it up to 15 replicas immediately."
kubernetes_events_list_all_namespaces
Retrieves the cluster event stream. Since events in Kubernetes are temporary and highly noisy, giving the LLM access to this tool allows it to rapidly correlate application failures with underlying infrastructure events (e.g., node autoscaling, image pull backoffs).
"Pull the most recent warning events across all namespaces from the last 30 minutes to see if we are hitting any persistent volume attachment failures."
kubernetes_nodes_get_status
Reads the status of a specific cluster node. This provides the agent with critical telemetry regarding memory pressure, disk pressure, and overall node readiness.
"Check the status of the node 'ip-10-0-1-123.ec2.internal'. Look specifically at the conditions array and tell me if it is reporting MemoryPressure or DiskPressure."
To view the complete inventory of available Kubernetes tools, schemas, and required parameters, visit the Kubernetes integration page.
Workflows in Action
AI agents excel at executing multi-step diagnostic and remediation workflows that would normally require an engineer to manually chain dozens of CLI commands. Here is how ChatGPT utilizes the Truto MCP server in production scenarios.
Scenario 1: Autonomous Incident Triage
When a service goes down, engineers waste critical minutes typing kubectl get pods and kubectl logs. An AI agent can perform the entire triage loop in seconds.
"The checkout service is reporting high error rates in the production namespace. Figure out why it is failing and summarize the root cause."
list_all_kubernetes_pods: ChatGPT calls this tool withnamespace: "production"and a label selector matching the checkout service to identify the failing pod.kubernetes_events_list_all_namespaces: The agent fetches recent events, noting that Kubernetes is repeatedly firingBackOffevents for the specific pod.kubernetes_pods_get_log: The agent pulls the logs for the failing pod, extracts a PostgreSQL connection timeout stack trace, and returns a concise human-readable summary to the user.
sequenceDiagram participant User as User participant ChatGPT as ChatGPT Agent participant Truto as Truto MCP participant K8s as Kubernetes API User->>ChatGPT: "Why is checkout-service failing?" ChatGPT->>Truto: tools/call list_all_kubernetes_pods Truto->>K8s: GET /api/v1/namespaces/production/pods K8s-->>Truto: Pod List JSON Truto-->>ChatGPT: checkout-service-xyz details ChatGPT->>Truto: tools/call kubernetes_pods_get_log Truto->>K8s: GET /api/v1/namespaces/production/pods/.../log K8s-->>Truto: Log Text Truto-->>ChatGPT: Exception stack trace ChatGPT-->>User: "Checkout service is failing due to a database connection timeout."
Scenario 2: Emergency Scaling Operations
During a sudden traffic spike, on-call responders need to scale resources immediately without digging through YAML files in a Git repository.
"We are getting hammered with Black Friday traffic. Check the replica count of the inventory-api deployment in production and double it."
list_all_kubernetes_deployments: ChatGPT locates theinventory-apideployment and checks thespec.replicasfield, finding it currently set to 4.kubernetes_deployments_update_scale: The agent executes this tool, targeting the deployment's scale subresource, passing a new payload to set the replicas to 8.list_all_kubernetes_pods: The agent polls the pod list to confirm that the 4 new pods are moving into thePendingand thenRunningstate.
Security and Access Control
Giving an LLM access to your Kubernetes cluster is highly sensitive. Truto provides rigorous access controls at the MCP token level, ensuring that you never accidentally grant a model excessive privileges.
- Method Filtering: You can strictly limit an MCP server to read-only operations. By setting
methods: ["read"]in the token configuration, Truto physically filters out allcreate,update, anddeletetools during generation. The LLM simply will not know those actions exist. - Tag Filtering: Limit the scope of the server to specific functional areas. By passing
tags: ["pods", "events"], you prevent the agent from discovering tools related to secrets, RBAC rules, or persistent volumes. require_api_token_auth: For highly sensitive clusters, possession of the Truto URL alone is not enough. Enabling this flag forces the MCP client to pass a valid Truto API bearer token in the headers, adding a strict second layer of authentication.expires_at: Perfect for incident response. You can generate a Kubernetes MCP server with an explicitexpires_attimestamp. Once the timestamp is reached, the token is automatically wiped from distributed KV storage, and the server URL permanently ceases to function.
Stop wrangling raw API requests and copying authentication certs just to ask an LLM to debug a pod. By leveraging Truto's dynamically generated MCP tools, you can transform ChatGPT into a fully capable Site Reliability Engineer in a matter of minutes.
FAQ
- How does Truto handle Kubernetes API rate limits?
- Truto does not absorb, retry, or apply backoff to rate limit errors. When the Kubernetes API returns a 429 status, Truto passes the error back to ChatGPT along with standardized IETF rate limit headers (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`). The LLM client handles the retry logic.
- Can I restrict ChatGPT to read-only Kubernetes access?
- Yes. When creating the Truto MCP server, you can set the `methods` configuration to `["read"]`. This ensures the server only exposes GET and LIST tools, preventing the LLM from executing any modifications to the cluster.
- How do I deal with the complexity of Kubernetes JSON merge patches via ChatGPT?
- Truto automatically handles the mapping of the LLM's flat arguments to the deeply nested schemas required by Kubernetes, mapping requests to the correct subresources (like Scale or Status) and ensuring the correct patch content types are applied.
- Can I connect the Truto MCP server via a CLI or local client instead of the ChatGPT UI?
- Yes. Truto supports standard Server-Sent Events (SSE) connections. You can configure clients like Claude Desktop or Cursor by using the `@modelcontextprotocol/server-sse` package in your JSON configuration and pointing it at your Truto MCP URL.