home / mcp / kubernetes mcp server
Provides an MCP server enabling AI tools to interact with Kubernetes clusters for data access and resource management.
Configuration
View docs{
"mcpServers": {
"briankscheong-k8s-mcp-server": {
"url": "https://placeholder.example/mcp"
}
}
}You run an MCP server that lets AI tools talk to Kubernetes clusters using natural language. It exposes common Kubernetes operations as tasks you can call from your MCP client, enabling automation, monitoring, and troubleshooting without writing raw kubectl commands.
To use this MCP server, connect your MCP client to the local stdio endpoint and provide the path to your kubeconfig. This lets the AI tool request information about pods, deployments, services, and more, and optionally perform management actions if permitted.
Typical usage patterns include asking the AI to list resources in a namespace, fetch logs from a pod, or scale a deployment. You can enable read-only mode to prevent mutations, or configure RBAC and namespace boundaries to limit scope.
Prerequisites you need before installation are a Kubernetes cluster with API access and a kubeconfig file or service account credentials. You should also ensure you have appropriate RBAC permissions for the operations you intend to perform.
Step 1: Install the MCP server binary via Go or from prebuilt binaries if available. Step 2: Run the MCP server in stdio mode with your kubeconfig path.
# If building from source
# (adjust to your environment as needed)
# Example: go install to fetch the latest release
goproxy=https://proxy.golang.org
go install github.com/briankscheong/k8s-mcp-server/cmd/k8s-mcp-server@latest
# Run the server (stdio transport) with kubeconfig
k8smcp stdio --kubeconfig=/path/to/your/kubeconfigIf you prefer to use a prebuilt binary, obtain the k8s-mcp-server binary and run it with the same stdio configuration. Keep your kubeconfig secure and ensure the environment where you run the server has access to it.
The server uses your kubeconfig or service account credentials to determine access. You can tighten security by creating a dedicated service account with limited RBAC rights, restricting the default namespace, and optionally enabling read-only mode to prevent changes to cluster state.
Transport options include stdio for local integration and SSE for HTTP-based connections if you deploy the server in a Kubernetes cluster and expose a port for clients.
By default, operations follow the permissions of the credentials you provide. For higher security, limit permissions with a dedicated service account, set namespace scoping, and use read-only mode when mutations are not needed.
If you encounter connection issues, verify that the kubeconfig path is correct and accessible by the MCP server process. Check RBAC permissions and ensure the MCP server process has network access to the Kubernetes API server.
This MCP server supports resource queries like listing pods or deployments, retrieving details for specific resources, fetching pod logs, listing namespaces, and performing management operations such as deleting pods or scaling deployments when read-only mode is disabled.
If you deploy in a Kubernetes cluster, you can use the SSE transport to expose a JSON-RPC endpoint and connect clients over HTTP. For local development, stdio remains the simplest option.
Keep the MCP server up to date with the latest release to benefit from improved Kubernetes API support and security updates. When upgrading, review any changes to command-line flags or environment variables and adjust your startup script accordingly.
Use read-only mode to block create/update/delete operations, and apply RBAC constraints to align with your organizational policies. You can combine kubeconfig context switching with namespace scoping to manage multiple clusters from the same MCP client.
Contributions that enhance Kubernetes resource support, add new operations, or improve security and reliability are welcome. Follow standard contribution practices for your repositoryโs workflow.
Retrieve detailed information about a specific pod. Parameters: namespace (optional), name (required).
List pods in a namespace. Parameters: namespace (optional), label_selector (optional), field_selector (optional).
Get logs from a pod. Parameters: namespace (optional), name (required), container (optional), tail_lines (optional), previous (optional).
Get information about a specific deployment. Parameters: namespace (optional), name (required).
List deployments in a namespace. Parameters: namespace (optional), label_selector (optional).
Get information about a specific service. Parameters: namespace (optional), name (required).
List services in a namespace. Parameters: namespace (optional), label_selector (optional).
Get information about a specific ConfigMap. Parameters: namespace (optional), name (required).
List ConfigMaps in a namespace. Parameters: namespace (optional), label_selector (optional).
List all namespaces in the cluster. No parameters.
List all nodes in the cluster. No parameters.
Delete a pod from a namespace. Parameters: namespace (optional), name (required), grace_period_seconds (optional).
Scale a deployment to a specific number of replicas. Parameters: namespace (optional), name (required), replicas (required).