Provides comprehensive Kubernetes cluster management capabilities including listing and monitoring resources (pods, services, deployments, namespaces), viewing logs, describing pod details, getting cluster events, port-forwarding services, scaling deployments, and executing kubectl commands through natural language.
Kubernetes MCP Server
A powerful MCP (Model Context Protocol) server for Kubernetes operations that allows you to manage your Kubernetes clusters using natural language through AI assistants.
🌟 Features
� Resource Listing
List pods, services, deployments, and namespaces
Get detailed resource information
🔍 Monitoring & Debugging
View pod logs with customizable line counts
Describe pod details for troubleshooting
Get cluster events for debugging
⚡ Operations
Port-forward services to local ports
Scale deployments up or down
Execute kubectl commands through natural language
🎯 Developer Focused
Designed for common Kubernetes developer workflows
Easy to extend with additional tools
Comprehensive error handling
� Available Tools
Tool | Description | Parameters |
| List pods in a namespace |
(optional) |
| List services in a namespace |
(optional) |
| List deployments in a namespace |
(optional) |
| List all namespaces | None |
| Get detailed pod information |
(required),
(optional) |
| Get pod logs |
(required),
(optional),
(optional),
(optional) |
| Port forward a service |
,
,
(required),
(optional) |
| Scale a deployment |
,
(required),
(optional) |
| Get cluster events |
(optional) |
📋 Requirements
Node.js v18+
kubectl installed and configured to access your cluster
@modelcontextprotocol/cli (optional, for testing)
🔧 Installation
🏃 Running the Server
The server runs on stdio transport and will output: Kubernetes MCP server running on stdio
🔌 Connecting to MCP Clients
Claude Desktop
Add to your claude_desktop_config.json
:
Other MCP Clients
For clients that support MCP, configure them to connect to this server using:
Command:
node
Args:
["/path/to/server.js"]
Transport: stdio
💡 Example Usage
Once connected to an MCP-compatible client, you can use natural language like:
"List all pods in the default namespace"
"Show me the logs for the nginx pod"
"Port forward the web service on port 8080 to my local port 3000"
"Scale the api deployment to 3 replicas"
"What events happened recently in the kube-system namespace?"
🧪 Testing
Run the test script to verify everything is working:
This will check:
✅ kubectl availability
✅ Server syntax validation
✅ Server startup capability
✅ Cluster connectivity
🛠️ Development
To add new tools:
Add the tool definition to the
tools
array inserver.js
Add a corresponding case in the
CallToolRequestSchema
handlerImplement the kubectl command and response formatting
Test with
node test.js
⚠️ Security Notes
This server executes kubectl commands on your system
Ensure your kubectl context is set to the correct cluster
Be cautious when scaling deployments or port-forwarding in production
Review all operations before execution
📜 License
MIT License - feel free to modify and distribute
🤝 Contributing
Contributions are welcome! Please feel free to submit issues and enhancement requests.
Restart your MCP-enabled client (Cursor AI, Claude Desktop, VS Code MCP extension, etc.)
Now you can issue natural commands like:
“Show me all pods in namespace payments”
“Port forward postgres service to local 5432”
“Get logs from api-pod”
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
Enables managing Kubernetes clusters through natural language by providing tools to list resources, view logs, port-forward services, scale deployments, and execute kubectl operations via AI assistants.