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