How to Configure Amazon Q Kubernetes MCP Server

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an amazon q kubernetes mcp server by registering the tool server in your agent settings. Then you point that server at a scoped cluster kubeconfig file. Teams often reuse their personal cluster admin files during initial testing to move fast. That shortcut gives the coding assistant full power to edit or delete live workloads. If a prompt goes wrong, an overly broad role turns a simple check into an outage. How the amazon q kubernetes mcp server works with cluster RBAC Amazon Q Dev

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up an amazon q kubernetes mcp server by registering the tool server in your agent settings. Then you point that server at a scoped cluster kubeconfig file. Teams often reuse their personal cluster admin files during initial testing to move fast. That shortcut gives the coding assistant full power to edit or delete live workloads. If a prompt goes wrong, an overly broad role turns a simple check into an outage.

How the amazon q kubernetes mcp server works with cluster RBAC

Amazon Q Developer talks to external tools through the Model Context Protocol. The assistant starts the local tool server process and sends requests over standard input and output. When you ask a question about pods, the agent calls a tool exposed by the server. The server then translates that tool call into a standard request to the Kubernetes API server.

The API server checks every request using its built-in Role-Based Access Control system. In Kubernetes, permissions are purely additive, meaning there are no deny rules. A Role sets permissions inside a single namespace, while a RoleBinding grants those rules to a user. A ClusterRole and ClusterRoleBinding grant rules across the entire cluster and cover nodes or all namespaces.

To keep the assistant safe, you should create a dedicated service account for the tool server. Bind that account to a Role that only allows reading pod status in one namespace. Be careful with subresources like pod logs or pod exec rules. If you grant exec access in a role, the agent can run shell commands inside containers.

What native RBAC solves and what it leaves open

Native cluster roles and local agent settings solve the basic startup problem. They let the assistant read cluster state and answer questions about failing pods or deployments. A read-only Role stops the assistant from deleting namespaces or changing deployment images. Local tool approval prompts also let the developer review a tool request before it runs.

Still, static roles only decide who can log in and which API endpoints they can call. They do not inspect what individual commands or queries do while in flight. If an engineer needs the assistant to run a command inside a pod, RBAC is binary. Once you allow the exec subresource, the role cannot block dangerous shell commands inside that container.

Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static roles also cannot filter sensitive text out of pod logs or cluster events. App logs often print user emails, phone numbers, card numbers, or national IDs during errors. When the tool server reads those logs, that sensitive text flows straight into the model prompt. Finally, sharing kubeconfig files on laptops makes it hard to track which prompt triggered a cluster action.

Scoping namespaces and subresources for safer agent runs

Start by separating read checks from write actions in your daily workflow. Give the local tool server a RoleBinding that covers only a single development or staging namespace. Avoid using a ClusterRoleBinding unless the assistant must inspect cluster-wide nodes or storage classes. Leave out secrets and pod exec rules from the base role so the agent stays read-only.

Review your cluster audit logs often to see which resources the service account reads. When a team needs production access or data masking on log outputs, local config files fall short. At that stage, you need runtime controls that inspect every command and rewrite sensitive fields in results.

Govern kubectl and API calls in flight

Identity providers and Kubernetes RBAC decide who logs into a cluster. They cannot redact keys inside returned JSON objects or hold a risky delete call for review. By design, hoop.dev runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. Next, hoop.dev data masking rewrites sensitive keys in returned Secret, ConfigMap, and log responses in memory, and writes each decision to the audit trail. Explore the repo on GitHub.

Frequently asked questions

Should I use a Role or a ClusterRole for the MCP server?

Use a Role and RoleBinding whenever possible to keep the agent inside one namespace. Only use a ClusterRoleBinding if the agent needs to check nodes or resources across all namespaces.

Why are pod log and pod exec permissions risky for AI agents?

Pod logs often contain emails, phone numbers, or card numbers that get sent to the model. Pod exec rules let the agent run arbitrary commands inside a live container without command-level checks.

Can Kubernetes RBAC block specific commands inside a pod exec session?

No, Kubernetes RBAC only controls whether a user can start an exec call on a pod. It cannot inspect or block the specific shell commands that run inside the container afterward.

The query runs. The emails stay hidden.