kubectl-mcp-server 1.13.0__py3-none-any.whl → 1.15.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,780 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: kubectl-mcp-server
3
- Version: 1.13.0
4
- Summary: A Model Context Protocol (MCP) server for Kubernetes with 127+ tools, 8 resources, and 8 prompts
5
- Home-page: https://github.com/rohitg00/kubectl-mcp-server
6
- Author: Rohit Ghumare
7
- Author-email: ghumare64@gmail.com
8
- Project-URL: Bug Tracker, https://github.com/rohitg00/kubectl-mcp-server/issues
9
- Project-URL: Documentation, https://github.com/rohitg00/kubectl-mcp-server#readme
10
- Project-URL: Source, https://github.com/rohitg00/kubectl-mcp-server
11
- Keywords: kubernetes,mcp,model-context-protocol,kubectl,helm,ai-assistant,claude,cursor,windsurf,fastmcp,devops,cloud-native,mcp-ui
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
- Classifier: License :: OSI Approved :: MIT License
18
- Classifier: Operating System :: OS Independent
19
- Classifier: Topic :: System :: Systems Administration
20
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
- Classifier: Intended Audience :: Developers
22
- Classifier: Intended Audience :: System Administrators
23
- Requires-Python: >=3.9
24
- Description-Content-Type: text/markdown
25
- License-File: LICENSE
26
- Requires-Dist: fastmcp>=3.0.0b1
27
- Requires-Dist: pydantic>=2.0.0
28
- Requires-Dist: fastapi>=0.100.0
29
- Requires-Dist: uvicorn>=0.22.0
30
- Requires-Dist: starlette>=0.27.0
31
- Requires-Dist: kubernetes>=28.1.0
32
- Requires-Dist: PyYAML>=6.0.1
33
- Requires-Dist: requests>=2.31.0
34
- Requires-Dist: urllib3>=2.1.0
35
- Requires-Dist: websocket-client>=1.7.0
36
- Requires-Dist: jsonschema>=4.20.0
37
- Requires-Dist: cryptography>=42.0.2
38
- Requires-Dist: rich>=13.0.0
39
- Requires-Dist: aiohttp>=3.8.0
40
- Requires-Dist: aiohttp-sse>=2.1.0
41
- Provides-Extra: ui
42
- Requires-Dist: mcp-ui-server>=0.5.0; extra == "ui"
43
- Provides-Extra: all
44
- Requires-Dist: mcp-ui-server>=0.5.0; extra == "all"
45
- Dynamic: author
46
- Dynamic: author-email
47
- Dynamic: classifier
48
- Dynamic: description
49
- Dynamic: description-content-type
50
- Dynamic: home-page
51
- Dynamic: keywords
52
- Dynamic: license-file
53
- Dynamic: project-url
54
- Dynamic: provides-extra
55
- Dynamic: requires-dist
56
- Dynamic: requires-python
57
- Dynamic: summary
58
-
59
- # Kubectl MCP Server
60
-
61
- A Model Context Protocol (MCP) server for Kubernetes that enables AI assistants like Claude, Cursor, and others to interact with Kubernetes clusters through natural language.
62
-
63
- [![GitHub Stars](https://img.shields.io/github/stars/rohitg00/kubectl-mcp-server?style=flat&logo=github)](https://github.com/rohitg00/kubectl-mcp-server)
64
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
65
- [![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/)
66
- [![Kubernetes](https://img.shields.io/badge/kubernetes-%23326ce5.svg?style=flat&logo=kubernetes&logoColor=white)](https://kubernetes.io/)
67
- [![MCP](https://img.shields.io/badge/MCP-compatible-green.svg)](https://modelcontextprotocol.io)
68
- [![PyPI](https://img.shields.io/pypi/v/kubectl-mcp-server?color=blue&label=PyPI)](https://pypi.org/project/kubectl-mcp-server/)
69
- [![npm](https://img.shields.io/npm/v/kubectl-mcp-server?color=green&label=npm)](https://www.npmjs.com/package/kubectl-mcp-server)
70
- [![Docker](https://img.shields.io/docker/pulls/rohitghumare64/kubectl-mcp-server.svg)](https://hub.docker.com/r/rohitghumare64/kubectl-mcp-server)
71
- [![Tests](https://img.shields.io/badge/tests-187%20passed-success)](https://github.com/rohitg00/kubectl-mcp-server)
72
- [![agentregistry](https://img.shields.io/badge/agentregistry-verified-blue?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0id2hpdGUiIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTE1Ljk5MiA2LjAzN2wtMy4wMjEtLjQzOS0xLjM1LTIuNzM2Yy0uMzQ2LS43MDItMS41MDQtLjcwMi0xLjg1IDBMOC40MjEgNS41OTggNS40IDYuMDM3Yy0uNzc2LjExMy0xLjA4OCAxLjA1My0uNTI4IDEuNTkzbDIuMTg2IDIuMTI5LS41MTYgMy4wMWMtLjEzMy43NzUuNjgyIDEuMzY2IDEuMzc4Ljk5OGwyLjcwMi0xLjQyIDIuNzAyIDEuNDJjLjY5Ni4zNjggMS41MTEtLjIyMyAxLjM3OC0uOTk4bC0uNTE2LTMuMDEgMi4xODYtMi4xMjljLjU2LS41NCAwLjI0OC0xLjQ4LS41MjgtMS41OTN6Ii8+PC9zdmc+)](https://aregistry.ai)
73
-
74
- ## MCP Client Compatibility
75
-
76
- Works with all MCP-compatible AI assistants:
77
-
78
- | Client | Status | Client | Status |
79
- |--------|--------|--------|--------|
80
- | Claude Desktop | ✅ Native | Claude Code | ✅ Native |
81
- | Cursor | ✅ Native | Windsurf | ✅ Native |
82
- | GitHub Copilot | ✅ Native | OpenAI Codex | ✅ Native |
83
- | Gemini CLI | ✅ Native | Goose | ✅ Native |
84
- | Roo Code | ✅ Native | Kilo Code | ✅ Native |
85
- | Amp | ✅ Native | Trae | ✅ Native |
86
- | OpenCode | ✅ Native | Kiro CLI | ✅ Native |
87
- | Antigravity | ✅ Native | Clawdbot | ✅ Native |
88
- | Droid (Factory) | ✅ Native | Any MCP Client | ✅ Compatible |
89
-
90
- ## Live Demos
91
-
92
- ### Claude Desktop
93
- ![Claude MCP](./docs/claude/claude-mcp.gif)
94
-
95
- ### Cursor AI
96
- ![Cursor MCP](./docs/cursor/cursor-mcp.gif)
97
-
98
- ### Windsurf
99
- ![Windsurf MCP](./docs/windsurf/windsurf-mcp.gif)
100
-
101
- ## Features
102
-
103
- ### 127 MCP Tools for Complete Kubernetes Management
104
-
105
- | Category | Tools |
106
- |----------|-------|
107
- | **Pods** | `get_pods`, `get_logs`, `get_pod_events`, `check_pod_health`, `exec_in_pod`, `cleanup_pods`, `get_pod_conditions`, `get_previous_logs` |
108
- | **Deployments** | `get_deployments`, `create_deployment`, `scale_deployment`, `kubectl_rollout`, `restart_deployment` |
109
- | **Workloads** | `get_statefulsets`, `get_daemonsets`, `get_jobs`, `get_replicasets` |
110
- | **Services & Networking** | `get_services`, `get_ingress`, `get_endpoints`, `diagnose_network_connectivity`, `check_dns_resolution`, `trace_service_chain` |
111
- | **Storage** | `get_persistent_volumes`, `get_pvcs`, `get_storage_classes` |
112
- | **Config** | `get_configmaps`, `get_secrets`, `get_resource_quotas`, `get_limit_ranges` |
113
- | **Cluster** | `get_nodes`, `get_namespaces`, `get_cluster_info`, `get_cluster_version`, `health_check`, `get_node_metrics`, `get_pod_metrics` |
114
- | **RBAC & Security** | `get_rbac_roles`, `get_cluster_roles`, `get_service_accounts`, `audit_rbac_permissions`, `check_secrets_security`, `get_pod_security_info`, `get_admission_webhooks` |
115
- | **CRDs** | `get_crds`, `get_priority_classes` |
116
- | **Helm Releases** | `helm_list`, `helm_status`, `helm_history`, `helm_get_values`, `helm_get_manifest`, `helm_get_notes`, `helm_get_hooks`, `helm_get_all` |
117
- | **Helm Charts** | `helm_show_chart`, `helm_show_values`, `helm_show_readme`, `helm_show_crds`, `helm_show_all`, `helm_search_repo`, `helm_search_hub` |
118
- | **Helm Repos** | `helm_repo_list`, `helm_repo_add`, `helm_repo_remove`, `helm_repo_update` |
119
- | **Helm Operations** | `install_helm_chart`, `upgrade_helm_chart`, `uninstall_helm_chart`, `helm_rollback`, `helm_test`, `helm_template`, `helm_template_apply` |
120
- | **Helm Development** | `helm_create`, `helm_lint`, `helm_package`, `helm_pull`, `helm_dependency_list`, `helm_dependency_update`, `helm_dependency_build`, `helm_version`, `helm_env` |
121
- | **Context** | `get_current_context`, `switch_context`, `list_contexts`, `list_kubeconfig_contexts` |
122
- | **Diagnostics** | `diagnose_pod_crash`, `detect_pending_pods`, `get_evicted_pods`, `compare_namespaces` |
123
- | **Operations** | `kubectl_apply`, `kubectl_create`, `kubectl_describe`, `kubectl_patch`, `delete_resource`, `kubectl_cp`, `backup_resource`, `label_resource`, `annotate_resource`, `taint_node`, `wait_for_condition` |
124
- | **Autoscaling** | `get_hpa`, `get_pdb` |
125
- | **Cost Optimization** | `get_resource_recommendations`, `get_idle_resources`, `get_resource_quotas_usage`, `get_cost_analysis`, `get_overprovisioned_resources`, `get_resource_trends`, `get_namespace_cost_allocation`, `optimize_resource_requests` |
126
- | **Advanced** | `kubectl_generic`, `kubectl_explain`, `get_api_resources`, `port_forward`, `get_resource_usage`, `node_management` |
127
- | **UI Dashboards** | `show_pod_logs_ui`, `show_pods_dashboard_ui`, `show_resource_yaml_ui`, `show_cluster_overview_ui`, `show_events_timeline_ui`, `render_k8s_dashboard_screenshot` |
128
-
129
- ### MCP Resources (FastMCP 3)
130
-
131
- Access Kubernetes data as browsable resources:
132
-
133
- | Resource URI | Description |
134
- |--------------|-------------|
135
- | `kubeconfig://contexts` | List all available kubectl contexts |
136
- | `kubeconfig://current-context` | Get current active context |
137
- | `namespace://current` | Get current namespace |
138
- | `namespace://list` | List all namespaces |
139
- | `cluster://info` | Get cluster information |
140
- | `cluster://nodes` | Get detailed node information |
141
- | `cluster://version` | Get Kubernetes version |
142
- | `cluster://api-resources` | List available API resources |
143
- | `manifest://deployments/{ns}/{name}` | Get deployment YAML |
144
- | `manifest://services/{ns}/{name}` | Get service YAML |
145
- | `manifest://pods/{ns}/{name}` | Get pod YAML |
146
- | `manifest://configmaps/{ns}/{name}` | Get ConfigMap YAML |
147
- | `manifest://secrets/{ns}/{name}` | Get secret YAML (data masked) |
148
- | `manifest://ingresses/{ns}/{name}` | Get ingress YAML |
149
-
150
- ### MCP Prompts (FastMCP 3)
151
-
152
- Pre-built workflow prompts for common Kubernetes operations:
153
-
154
- | Prompt | Description |
155
- |--------|-------------|
156
- | `troubleshoot_workload` | Comprehensive troubleshooting guide for pods/deployments |
157
- | `deploy_application` | Step-by-step deployment workflow |
158
- | `security_audit` | Security scanning and RBAC analysis workflow |
159
- | `cost_optimization` | Resource optimization and cost analysis workflow |
160
- | `disaster_recovery` | Backup and recovery planning workflow |
161
- | `debug_networking` | Network debugging for services and connectivity |
162
- | `scale_application` | Scaling guide with HPA/VPA best practices |
163
- | `upgrade_cluster` | Kubernetes cluster upgrade planning |
164
-
165
- ### Key Capabilities
166
-
167
- - **Multi-Transport Support**: stdio, SSE, HTTP/streamable-http
168
- - **AI Assistant Integration**: Claude Desktop, Claude Code, Cursor, Windsurf
169
- - **Multi-Cluster**: Context switching between clusters
170
- - **Security**: Non-destructive mode, secrets masking, RBAC validation
171
- - **Diagnostics**: Pod crash analysis, network connectivity testing, DNS resolution checks
172
- - **Helm v3**: Full Helm chart lifecycle management
173
- - **Cost Optimization**: Resource recommendations, idle resource detection, usage analysis
174
- - **FastMCP 3**: MCP Resources and Prompts for enhanced AI workflows
175
- - **MCP-UI Support**: Interactive HTML dashboards for compatible hosts (Goose, LibreChat)
176
-
177
- ## Installation
178
-
179
- ### Prerequisites
180
- - Python 3.9+
181
- - kubectl CLI installed and configured
182
- - Access to a Kubernetes cluster
183
-
184
- ### npm / npx (Recommended)
185
-
186
- ```bash
187
- # Run directly without installation
188
- npx kubectl-mcp-server
189
-
190
- # Or install globally
191
- npm install -g kubectl-mcp-server
192
- ```
193
-
194
- ### pip (Python)
195
-
196
- ```bash
197
- pip install kubectl-mcp-server
198
-
199
- # With MCP-UI support (interactive dashboards)
200
- pip install kubectl-mcp-server[ui]
201
-
202
- # Legacy alias (still works for backward compatibility)
203
- pip install kubectl-mcp-tool
204
- ```
205
-
206
- ### Docker
207
-
208
- ```bash
209
- # Pull the latest image
210
- docker pull rohitghumare64/kubectl-mcp-server:latest
211
-
212
- # Run with stdio transport
213
- docker run -i -v $HOME/.kube:/root/.kube:ro rohitghumare64/kubectl-mcp-server:latest
214
-
215
- # Run with SSE transport
216
- docker run -p 8000:8000 -v $HOME/.kube:/root/.kube:ro rohitghumare64/kubectl-mcp-server:latest --transport sse
217
- ```
218
-
219
- ## Quick Start
220
-
221
- ### Claude Desktop
222
-
223
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
224
-
225
- ```json
226
- {
227
- "mcpServers": {
228
- "kubernetes": {
229
- "command": "npx",
230
- "args": ["-y", "kubectl-mcp-server"]
231
- }
232
- }
233
- }
234
- ```
235
-
236
- ### Claude Code
237
-
238
- Add to `~/.config/claude-code/mcp.json`:
239
-
240
- ```json
241
- {
242
- "mcpServers": {
243
- "kubernetes": {
244
- "command": "npx",
245
- "args": ["-y", "kubectl-mcp-server"]
246
- }
247
- }
248
- }
249
- ```
250
-
251
- ### Cursor AI
252
-
253
- Add to `~/.cursor/mcp.json`:
254
-
255
- ```json
256
- {
257
- "mcpServers": {
258
- "kubernetes": {
259
- "command": "npx",
260
- "args": ["-y", "kubectl-mcp-server"]
261
- }
262
- }
263
- }
264
- ```
265
-
266
- ### Windsurf
267
-
268
- Add to `~/.config/windsurf/mcp.json`:
269
-
270
- ```json
271
- {
272
- "mcpServers": {
273
- "kubernetes": {
274
- "command": "npx",
275
- "args": ["-y", "kubectl-mcp-server"]
276
- }
277
- }
278
- }
279
- ```
280
-
281
- ### GitHub Copilot (VS Code)
282
-
283
- Add to VS Code `settings.json`:
284
-
285
- ```json
286
- {
287
- "mcp": {
288
- "servers": {
289
- "kubernetes": {
290
- "command": "npx",
291
- "args": ["-y", "kubectl-mcp-server"]
292
- }
293
- }
294
- }
295
- }
296
- ```
297
-
298
- ### Goose
299
-
300
- Add to `~/.config/goose/config.yaml`:
301
-
302
- ```yaml
303
- extensions:
304
- kubernetes:
305
- command: npx
306
- args:
307
- - -y
308
- - kubectl-mcp-server
309
- ```
310
-
311
- ### Gemini CLI
312
-
313
- Add to `~/.gemini/settings.json`:
314
-
315
- ```json
316
- {
317
- "mcpServers": {
318
- "kubernetes": {
319
- "command": "npx",
320
- "args": ["-y", "kubectl-mcp-server"]
321
- }
322
- }
323
- }
324
- ```
325
-
326
- ### Roo Code / Kilo Code
327
-
328
- Add to `~/.config/roo-code/mcp.json` or `~/.config/kilo-code/mcp.json`:
329
-
330
- ```json
331
- {
332
- "mcpServers": {
333
- "kubernetes": {
334
- "command": "npx",
335
- "args": ["-y", "kubectl-mcp-server"]
336
- }
337
- }
338
- }
339
- ```
340
-
341
- ### Using Python Directly
342
-
343
- If you prefer Python over npx:
344
-
345
- ```json
346
- {
347
- "mcpServers": {
348
- "kubernetes": {
349
- "command": "python",
350
- "args": ["-m", "kubectl_mcp_tool.mcp_server"],
351
- "env": {
352
- "KUBECONFIG": "/path/to/.kube/config"
353
- }
354
- }
355
- }
356
- }
357
- ```
358
-
359
- ## Transport Modes
360
-
361
- ```bash
362
- # stdio (default) - for Claude Desktop, Cursor, etc.
363
- python -m kubectl_mcp_tool.mcp_server
364
-
365
- # SSE - Server-Sent Events
366
- python -m kubectl_mcp_tool.mcp_server --transport sse --port 8000
367
-
368
- # HTTP
369
- python -m kubectl_mcp_tool.mcp_server --transport http --port 8000
370
- ```
371
-
372
- ### Options
373
- - `--transport`: `stdio`, `sse`, `http`, `streamable-http` (default: `stdio`)
374
- - `--host`: Host to bind (default: `0.0.0.0`)
375
- - `--port`: Port for network transports (default: `8000`)
376
- - `--non-destructive`: Block destructive operations (delete, apply, create)
377
-
378
- ## Environment Variables
379
-
380
- | Variable | Description |
381
- |----------|-------------|
382
- | `KUBECONFIG` | Path to kubeconfig file (default: `~/.kube/config`) |
383
- | `MCP_DEBUG` | Set to `1` for verbose logging |
384
- | `MCP_LOG_FILE` | Path to log file |
385
-
386
- ### Authentication (Enterprise)
387
-
388
- | Variable | Description |
389
- |----------|-------------|
390
- | `MCP_AUTH_ENABLED` | Enable OAuth 2.1 authentication (default: `false`) |
391
- | `MCP_AUTH_ISSUER` | OAuth 2.0 Authorization Server URL |
392
- | `MCP_AUTH_JWKS_URI` | JWKS endpoint (optional, derived from issuer) |
393
- | `MCP_AUTH_AUDIENCE` | Expected token audience (default: `kubectl-mcp-server`) |
394
- | `MCP_AUTH_REQUIRED_SCOPES` | Required scopes (default: `mcp:tools`) |
395
-
396
- ### Browser Automation (Optional)
397
-
398
- | Variable | Description |
399
- |----------|-------------|
400
- | `MCP_BROWSER_ENABLED` | Enable browser automation tools (default: `false`) |
401
-
402
- ## MCP-UI Tools (Interactive Dashboards)
403
-
404
- Enable rich HTML dashboards in MCP-UI compatible hosts (Goose, LibreChat, Nanobot).
405
-
406
- ### Installation
407
-
408
- ```bash
409
- # Install with MCP-UI support
410
- pip install kubectl-mcp-server[ui]
411
- ```
412
-
413
- ### 6 UI Dashboard Tools
414
-
415
- | Tool | Description |
416
- |------|-------------|
417
- | `show_pod_logs_ui` | Interactive log viewer with search and filtering |
418
- | `show_pods_dashboard_ui` | Pods table with status, restarts, and filtering |
419
- | `show_resource_yaml_ui` | YAML viewer with syntax highlighting |
420
- | `show_cluster_overview_ui` | Cluster dashboard with nodes, namespaces, workloads |
421
- | `show_events_timeline_ui` | Events timeline with severity filtering |
422
- | `render_k8s_dashboard_screenshot` | Render any dashboard as PNG screenshot |
423
-
424
- ### Features
425
-
426
- - **Dark theme**: Catppuccin-style dark UI optimized for terminals
427
- - **Graceful fallback**: Returns JSON data if MCP-UI not supported
428
- - **Screenshot rendering**: Works with agent-browser for universal compatibility
429
- - **No external dependencies**: Pure HTML/CSS/JS dashboards
430
-
431
- ### Compatibility
432
-
433
- | Host | MCP-UI Support | Fallback |
434
- |------|----------------|----------|
435
- | Goose | ✅ Full | - |
436
- | LibreChat | ✅ Full | - |
437
- | Nanobot | ✅ Full | - |
438
- | Claude Desktop | ❌ | JSON + Screenshot |
439
- | Cursor | ❌ | JSON + Screenshot |
440
- | Other MCP Clients | ❌ | JSON + Screenshot |
441
-
442
- ## Browser Tools (Optional Module)
443
-
444
- Enable browser automation for web-based K8s operations using [agent-browser](https://github.com/vercel-labs/agent-browser).
445
-
446
- ### Setup
447
-
448
- ```bash
449
- # Install agent-browser
450
- npm install -g agent-browser
451
- agent-browser install # Download Chromium
452
-
453
- # Enable browser tools
454
- export MCP_BROWSER_ENABLED=true
455
- kubectl-mcp-server
456
- ```
457
-
458
- ### 19 Browser Tools
459
-
460
- | Tool | Description |
461
- |------|-------------|
462
- | `browser_open` | Open URL in browser |
463
- | `browser_snapshot` | Get page accessibility tree |
464
- | `browser_click` | Click element by ref |
465
- | `browser_fill` | Fill form field |
466
- | `browser_screenshot` | Take screenshot |
467
- | `browser_get_text` | Get element text |
468
- | `browser_get_url` | Get current URL |
469
- | `browser_wait` | Wait for element/text/timeout |
470
- | `browser_close` | Close browser |
471
- | `browser_test_ingress` | Test K8s service via Ingress |
472
- | `browser_screenshot_service` | Screenshot K8s service UI |
473
- | `browser_screenshot_grafana` | Screenshot Grafana dashboard |
474
- | `browser_screenshot_argocd` | Screenshot ArgoCD app |
475
- | `browser_health_check` | Health check web app |
476
- | `browser_form_submit` | Fill and submit form |
477
- | `browser_session_save` | Save browser session |
478
- | `browser_session_load` | Load browser session |
479
- | `browser_open_cloud_console` | Open EKS/GKE/AKS console |
480
- | `browser_pdf_export` | Export page as PDF |
481
-
482
- ### Use Cases
483
-
484
- - **Test deployed apps** via Ingress URLs
485
- - **Screenshot Grafana/ArgoCD** dashboards
486
- - **Automate cloud console** operations (EKS, GKE, AKS)
487
- - **Health check** web applications
488
- - **Export monitoring dashboards** as PDF
489
-
490
- ## MCP Authorization (RFC 9728)
491
-
492
- For enterprise deployments, kubectl-mcp-server supports OAuth 2.1 authentication.
493
-
494
- ```bash
495
- export MCP_AUTH_ENABLED=true
496
- export MCP_AUTH_ISSUER=https://your-idp.example.com
497
- export MCP_AUTH_AUDIENCE=kubectl-mcp-server
498
- kubectl-mcp-server --transport http --port 8000
499
- ```
500
-
501
- Supported identity providers: **Okta**, **Auth0**, **Keycloak**, **Microsoft Entra ID**, **Google OAuth**, and any OIDC-compliant provider.
502
-
503
- ## Docker MCP Toolkit
504
-
505
- Compatible with [Docker MCP Toolkit](https://docs.docker.com/ai/mcp-catalog-and-toolkit/toolkit/):
506
-
507
- ```bash
508
- # Add server
509
- docker mcp server add kubectl-mcp-server mcp/kubectl-mcp-server:latest
510
-
511
- # Configure kubeconfig
512
- docker mcp server configure kubectl-mcp-server --volume "$HOME/.kube:/root/.kube:ro"
513
-
514
- # Enable and connect
515
- docker mcp server enable kubectl-mcp-server
516
- docker mcp client connect claude
517
- ```
518
-
519
- ## agentregistry
520
-
521
- kubectl-mcp-server is published to [agentregistry](https://github.com/agentregistry-dev/agentregistry), a centralized registry for MCP servers.
522
-
523
- ### Install with arctl
524
-
525
- ```bash
526
- # Install arctl CLI
527
- curl -fsSL https://raw.githubusercontent.com/agentregistry-dev/agentregistry/main/scripts/install.sh | bash
528
-
529
- # Search for kubectl-mcp-server
530
- arctl mcp search kubectl
531
-
532
- # Install the server
533
- arctl mcp install io.github.rohitg00/kubectl-mcp-server
534
- ```
535
-
536
- ### Available Packages
537
-
538
- | Registry | Identifier |
539
- |----------|------------|
540
- | **PyPI** | `kubectl-mcp-server` (uvx) |
541
- | **npm** | `kubectl-mcp-server` (npx) |
542
- | **OCI** | `docker.io/rohitghumare64/kubectl-mcp-server` |
543
-
544
- ### agentgateway Integration
545
-
546
- Use with [agentgateway](https://github.com/agentgateway/agentgateway) for unified MCP routing to multiple MCP servers.
547
-
548
- ```bash
549
- # Start kubectl-mcp-server with streamable-http transport
550
- kubectl-mcp-server --transport streamable-http --port 8000
551
- ```
552
-
553
- Create `gateway.yaml`:
554
-
555
- ```yaml
556
- binds:
557
- - port: 3000
558
- listeners:
559
- - routes:
560
- - backends:
561
- - mcp:
562
- targets:
563
- - name: kubectl-mcp-server
564
- mcp:
565
- host: http://localhost:8000/mcp
566
- ```
567
-
568
- ```bash
569
- # Run agentgateway
570
- agentgateway --config gateway.yaml
571
- ```
572
-
573
- Connect MCP clients to `http://localhost:3000/mcp`. All 127 tools are discoverable through the gateway.
574
-
575
- ## Kubernetes Deployment
576
-
577
- Deploy kubectl-mcp-server directly in your Kubernetes cluster for centralized access.
578
-
579
- ### kMCP Deployment (Recommended)
580
-
581
- [kMCP](https://github.com/kagent-dev/kmcp) is a development platform and control plane for MCP servers. See [kMCP quickstart](https://kagent.dev/docs/kmcp/quickstart).
582
-
583
- ```bash
584
- # Install kmcp CLI
585
- curl -fsSL https://raw.githubusercontent.com/kagent-dev/kmcp/refs/heads/main/scripts/get-kmcp.sh | bash
586
-
587
- # Install kmcp controller in your cluster
588
- helm install kmcp-crds oci://ghcr.io/kagent-dev/kmcp/helm/kmcp-crds \
589
- --namespace kmcp-system --create-namespace
590
- kmcp install
591
-
592
- # Deploy kubectl-mcp-server using npx (easiest)
593
- kmcp deploy package --deployment-name kubectl-mcp-server \
594
- --manager npx --args kubectl-mcp-server
595
-
596
- # Or deploy using our Docker image with the MCPServer manifest
597
- kmcp deploy --file deploy/kmcp/kmcp.yaml --image rohitghumare64/kubectl-mcp-server:latest
598
- ```
599
-
600
- ### Standard Kubernetes Deployment
601
-
602
- Deploy using kubectl/kustomize without kMCP:
603
-
604
- ```bash
605
- # Using kustomize (recommended)
606
- kubectl apply -k deploy/kubernetes/
607
-
608
- # Or apply individual manifests
609
- kubectl apply -f deploy/kubernetes/namespace.yaml
610
- kubectl apply -f deploy/kubernetes/rbac.yaml
611
- kubectl apply -f deploy/kubernetes/deployment.yaml
612
- kubectl apply -f deploy/kubernetes/service.yaml
613
-
614
- # Access via port-forward
615
- kubectl port-forward -n kubectl-mcp svc/kubectl-mcp-server 8000:8000
616
- ```
617
-
618
- ### MCPServer Custom Resource
619
-
620
- For kMCP deployments, apply this MCPServer resource:
621
-
622
- ```yaml
623
- apiVersion: kagent.dev/v1alpha1
624
- kind: MCPServer
625
- metadata:
626
- name: kubectl-mcp-server
627
- spec:
628
- deployment:
629
- image: "rohitghumare64/kubectl-mcp-server:latest"
630
- port: 8000
631
- transportType: http
632
- httpTransport:
633
- targetPort: 8000
634
- path: /mcp
635
- ```
636
-
637
- See [deploy/](deploy/) for full manifests and configuration options.
638
-
639
- ### kagent Integration (AI Agents)
640
-
641
- [kagent](https://github.com/kagent-dev/kagent) is a Kubernetes-native AI agent framework (CNCF project). Register kubectl-mcp-server as a ToolServer to give your agents 127 K8s management tools.
642
-
643
- ```bash
644
- # Install kagent
645
- brew install kagent
646
- kagent install --profile demo
647
-
648
- # Register kubectl-mcp-server as a ToolServer
649
- kubectl apply -f deploy/kagent/toolserver-stdio.yaml
650
-
651
- # Open kagent dashboard and chat with your K8s agent
652
- kagent dashboard
653
- ```
654
-
655
- See [kagent quickstart](https://kagent.dev/docs/kagent/getting-started/quickstart) for full documentation.
656
-
657
- ## Architecture
658
-
659
- ```
660
- ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
661
- │ AI Assistant │────▶│ MCP Server │────▶│ Kubernetes API │
662
- │ (Claude/Cursor) │◀────│ (kubectl-mcp) │◀────│ (kubectl) │
663
- └─────────────────┘ └──────────────────┘ └─────────────────┘
664
- ```
665
-
666
- The MCP server implements the [Model Context Protocol](https://github.com/modelcontextprotocol/spec), translating natural language requests into kubectl operations.
667
-
668
- ### Modular Structure
669
-
670
- ```
671
- kubectl_mcp_tool/
672
- ├── mcp_server.py # Main server (FastMCP, transports)
673
- ├── tools/ # 127 MCP tools organized by category
674
- │ ├── pods.py # Pod management & diagnostics
675
- │ ├── deployments.py # Deployments, StatefulSets, DaemonSets
676
- │ ├── core.py # Namespaces, ConfigMaps, Secrets
677
- │ ├── cluster.py # Context/cluster management
678
- │ ├── networking.py # Services, Ingress, NetworkPolicies
679
- │ ├── storage.py # PVCs, StorageClasses, PVs
680
- │ ├── security.py # RBAC, ServiceAccounts, PodSecurity
681
- │ ├── helm.py # Complete Helm v3 operations
682
- │ ├── operations.py # kubectl apply/patch/describe/etc
683
- │ ├── diagnostics.py # Metrics, namespace comparison
684
- │ ├── cost.py # Resource optimization & cost analysis
685
- │ └── ui.py # MCP-UI interactive dashboards
686
- ├── resources/ # 8 MCP Resources for data exposure
687
- ├── prompts/ # 8 MCP Prompts for workflows
688
- └── cli/ # CLI interface
689
- ```
690
-
691
- ## Multi-Cluster Support
692
-
693
- ```bash
694
- # List contexts
695
- list_contexts
696
-
697
- # Switch cluster
698
- switch_context --context_name production
699
-
700
- # Get context details
701
- get_context_details --context_name staging
702
- ```
703
-
704
- ## Development & Testing
705
-
706
- ### Setup Development Environment
707
-
708
- ```bash
709
- # Clone the repository
710
- git clone https://github.com/rohitg00/kubectl-mcp-server.git
711
- cd kubectl-mcp-server
712
-
713
- # Create virtual environment
714
- python -m venv venv
715
- source venv/bin/activate # On Windows: venv\Scripts\activate
716
-
717
- # Install development dependencies
718
- pip install -r requirements-dev.txt
719
- ```
720
-
721
- ### Running Tests
722
-
723
- ```bash
724
- # Run all tests
725
- pytest tests/ -v
726
-
727
- # Run specific test file
728
- pytest tests/test_tools.py -v
729
-
730
- # Run with coverage
731
- pytest tests/ --cov=kubectl_mcp_tool --cov-report=html
732
-
733
- # Run only unit tests
734
- pytest tests/ -v -m unit
735
- ```
736
-
737
- ### Test Structure
738
-
739
- ```
740
- tests/
741
- ├── __init__.py # Test package
742
- ├── conftest.py # Shared fixtures and mocks
743
- ├── test_tools.py # Unit tests for 121 MCP tools
744
- ├── test_resources.py # Tests for 8 MCP Resources
745
- ├── test_prompts.py # Tests for 8 MCP Prompts
746
- └── test_server.py # Server initialization tests
747
- ```
748
-
749
- **138 tests covering**: tool registration, resource exposure, prompt generation, server initialization, non-destructive mode, secret masking, error handling, and transport methods.
750
-
751
- ### Code Quality
752
-
753
- ```bash
754
- # Format code
755
- black kubectl_mcp_tool tests
756
-
757
- # Sort imports
758
- isort kubectl_mcp_tool tests
759
-
760
- # Lint
761
- flake8 kubectl_mcp_tool tests
762
-
763
- # Type checking
764
- mypy kubectl_mcp_tool
765
- ```
766
-
767
- ## Contributing
768
-
769
- Contributions are welcome! Please feel free to submit a Pull Request.
770
-
771
- ## License
772
-
773
- MIT License - see [LICENSE](LICENSE) for details.
774
-
775
- ## Links
776
-
777
- - [PyPI Package](https://pypi.org/project/kubectl-mcp-server/)
778
- - [npm Package](https://www.npmjs.com/package/kubectl-mcp-server)
779
- - [Docker Hub](https://hub.docker.com/r/rohitghumare64/kubectl-mcp-server)
780
- - [GitHub Issues](https://github.com/rohitg00/kubectl-mcp-server/issues)