kubectl-mcp-server 1.23.0__py3-none-any.whl → 1.23.1__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.
tests/test_tools.py CHANGED
@@ -2,7 +2,7 @@
2
2
  Unit tests for all MCP tools in kubectl-mcp-server.
3
3
 
4
4
  This module contains comprehensive tests for all Kubernetes tools
5
- provided by the MCP server (224 total with ecosystem tools).
5
+ provided by the MCP server.
6
6
  """
7
7
 
8
8
  import pytest
@@ -12,40 +12,37 @@ from unittest.mock import patch, MagicMock
12
12
  from datetime import datetime
13
13
 
14
14
 
15
- # Complete list of all 235 tools that must be registered (136 core + 6 UI + 93 ecosystem)
16
15
  EXPECTED_TOOLS = [
17
- # Pods (pods.py)
16
+ # Pods (pods.py) - 12 tools
18
17
  "get_pods", "get_logs", "get_pod_events", "check_pod_health", "exec_in_pod",
19
18
  "cleanup_pods", "run_pod", "get_pod_conditions", "get_previous_logs", "diagnose_pod_crash",
20
19
  "detect_pending_pods", "get_evicted_pods",
21
- # Deployments (deployments.py)
20
+ # Deployments (deployments.py) - 8 tools
22
21
  "get_deployments", "create_deployment", "scale_deployment", "restart_deployment",
23
22
  "get_statefulsets", "get_daemonsets", "get_replicasets", "get_jobs",
24
- # Core (core.py)
23
+ # Core (core.py) - 6 tools
25
24
  "get_namespaces", "get_configmaps", "get_secrets", "get_events",
26
25
  "get_resource_quotas", "get_limit_ranges",
27
- # Cluster (cluster.py) - includes multi-cluster config tools
26
+ # Cluster (cluster.py) - 22 tools
28
27
  "get_current_context", "switch_context", "list_contexts_tool",
29
28
  "get_context_details", "set_namespace_for_context", "get_cluster_info",
30
29
  "get_cluster_version", "get_nodes", "get_api_resources", "health_check",
31
30
  "kubeconfig_view", "get_api_versions", "check_crd_exists", "list_crds", "get_nodes_summary",
32
31
  "node_logs_tool", "node_stats_summary_tool", "node_top_tool",
33
- # Config management tools (cluster.py)
34
32
  "get_server_config_status", "enable_kubeconfig_watching", "disable_kubeconfig_watching",
35
33
  "set_server_stateless_mode",
36
- # Multi-cluster tools (cluster.py)
37
34
  "multi_cluster_query", "multi_cluster_health", "multi_cluster_pod_count",
38
- # Networking (networking.py)
35
+ # Networking (networking.py) - 8 tools
39
36
  "get_services", "get_endpoints", "get_ingress", "port_forward",
40
37
  "diagnose_network_connectivity", "check_dns_resolution", "trace_service_chain",
41
38
  "analyze_network_policies",
42
- # Storage (storage.py)
39
+ # Storage (storage.py) - 3 tools
43
40
  "get_pvcs", "get_persistent_volumes", "get_storage_classes",
44
- # Security (security.py)
41
+ # Security (security.py) - 10 tools
45
42
  "get_rbac_roles", "get_cluster_roles", "get_service_accounts",
46
43
  "audit_rbac_permissions", "check_secrets_security", "get_pod_security_info",
47
44
  "get_admission_webhooks", "get_crds", "get_priority_classes", "analyze_pod_security",
48
- # Helm (helm.py) - 37 tools
45
+ # Helm (helm.py) - 35 tools
49
46
  "helm_list", "helm_status", "helm_history", "helm_get_values", "helm_get_manifest",
50
47
  "helm_get_notes", "helm_get_hooks", "helm_get_all", "helm_show_chart",
51
48
  "helm_show_values", "helm_show_readme", "helm_show_crds", "helm_show_all",
@@ -55,77 +52,90 @@ EXPECTED_TOOLS = [
55
52
  "helm_template_apply", "helm_create", "helm_lint", "helm_package", "helm_pull",
56
53
  "helm_dependency_list", "helm_dependency_update", "helm_dependency_build",
57
54
  "helm_version", "helm_env",
58
- # Operations (operations.py)
55
+ # Operations (operations.py) - 15 tools
59
56
  "kubectl_apply", "kubectl_describe", "kubectl_patch", "kubectl_rollout",
60
57
  "kubectl_create", "delete_resource", "kubectl_cp", "backup_resource",
61
58
  "label_resource", "annotate_resource", "taint_node", "wait_for_condition",
62
59
  "node_management", "kubectl_generic", "kubectl_explain",
63
- # Diagnostics (diagnostics.py)
60
+ # Diagnostics (diagnostics.py) - 3 tools
64
61
  "compare_namespaces", "get_pod_metrics", "get_node_metrics",
65
- # Cost (cost.py)
62
+ # Cost (cost.py) - 9 tools
66
63
  "get_resource_recommendations", "get_idle_resources", "get_resource_quotas_usage",
67
64
  "get_cost_analysis", "get_overprovisioned_resources", "get_resource_trends",
68
65
  "get_namespace_cost_allocation", "optimize_resource_requests", "get_resource_usage",
69
- # Autoscaling (deployments.py)
66
+ # Autoscaling (deployments.py) - 2 tools
70
67
  "get_hpa", "get_pdb",
71
- # UI tools (ui.py) - 6 tools for MCP-UI interactive dashboards
72
- "show_pod_logs_ui", "show_pods_dashboard_ui", "show_resource_yaml_ui",
73
- "show_cluster_overview_ui", "show_events_timeline_ui", "render_k8s_dashboard_screenshot",
74
- # GitOps tools (gitops.py) - 7 tools for Flux and ArgoCD
68
+ # GitOps tools (gitops.py) - 7 tools
75
69
  "gitops_apps_list_tool", "gitops_app_get_tool", "gitops_app_sync_tool", "gitops_app_status_tool",
76
70
  "gitops_sources_list_tool", "gitops_source_get_tool", "gitops_detect_engine_tool",
77
71
  # Cert-Manager tools (certs.py) - 9 tools
78
72
  "certs_list_tool", "certs_get_tool", "certs_issuers_list_tool", "certs_issuer_get_tool",
79
73
  "certs_renew_tool", "certs_status_explain_tool", "certs_challenges_list_tool",
80
74
  "certs_requests_list_tool", "certs_detect_tool",
81
- # Policy tools (policy.py) - 6 tools for Kyverno and Gatekeeper
75
+ # Policy tools (policy.py) - 6 tools
82
76
  "policy_list_tool", "policy_get_tool", "policy_violations_list_tool", "policy_explain_denial_tool",
83
77
  "policy_audit_tool", "policy_detect_tool",
84
- # Backup tools (backup.py) - 11 tools for Velero
78
+ # Backup tools (backup.py) - 11 tools
85
79
  "backup_list_tool", "backup_get_tool", "backup_create_tool", "backup_delete_tool",
86
80
  "restore_list_tool", "restore_create_tool", "restore_get_tool", "backup_locations_list_tool",
87
81
  "backup_schedules_list_tool", "backup_schedule_create_tool", "backup_detect_tool",
88
- # KEDA tools (keda.py) - 7 tools for autoscaling
82
+ # KEDA tools (keda.py) - 7 tools
89
83
  "keda_scaledobjects_list_tool", "keda_scaledobject_get_tool", "keda_scaledjobs_list_tool",
90
84
  "keda_triggerauths_list_tool", "keda_triggerauth_get_tool", "keda_hpa_list_tool", "keda_detect_tool",
91
- # Cilium tools (cilium.py) - 8 tools for network observability
85
+ # Cilium tools (cilium.py) - 8 tools
92
86
  "cilium_policies_list_tool", "cilium_policy_get_tool", "cilium_endpoints_list_tool",
93
87
  "cilium_identities_list_tool", "cilium_nodes_list_tool", "cilium_status_tool",
94
88
  "hubble_flows_query_tool", "cilium_detect_tool",
95
- # Rollouts tools (rollouts.py) - 11 tools for progressive delivery
89
+ # Rollouts tools (rollouts.py) - 11 tools
96
90
  "rollouts_list_tool", "rollout_get_tool", "rollout_status_tool", "rollout_promote_tool",
97
91
  "rollout_abort_tool", "rollout_retry_tool", "rollout_restart_tool", "analysis_runs_list_tool",
98
92
  "flagger_canaries_list_tool", "flagger_canary_get_tool", "rollouts_detect_tool",
99
- # Cluster API tools (capi.py) - 11 tools for cluster lifecycle
93
+ # Cluster API tools (capi.py) - 11 tools
100
94
  "capi_clusters_list_tool", "capi_cluster_get_tool", "capi_machines_list_tool",
101
95
  "capi_machine_get_tool", "capi_machinedeployments_list_tool", "capi_machinedeployment_scale_tool",
102
96
  "capi_machinesets_list_tool", "capi_machinehealthchecks_list_tool", "capi_clusterclasses_list_tool",
103
97
  "capi_cluster_kubeconfig_tool", "capi_detect_tool",
104
- # KubeVirt tools (kubevirt.py) - 13 tools for VM management
98
+ # KubeVirt tools (kubevirt.py) - 13 tools
105
99
  "kubevirt_vms_list_tool", "kubevirt_vm_get_tool", "kubevirt_vmis_list_tool",
106
100
  "kubevirt_vm_start_tool", "kubevirt_vm_stop_tool", "kubevirt_vm_restart_tool",
107
101
  "kubevirt_vm_pause_tool", "kubevirt_vm_unpause_tool", "kubevirt_vm_migrate_tool",
108
102
  "kubevirt_datasources_list_tool", "kubevirt_instancetypes_list_tool",
109
103
  "kubevirt_datavolumes_list_tool", "kubevirt_detect_tool",
110
- # Istio/Kiali tools (kiali.py) - 10 tools for service mesh
104
+ # Istio/Kiali tools (kiali.py) - 10 tools
111
105
  "istio_virtualservices_list_tool", "istio_virtualservice_get_tool", "istio_destinationrules_list_tool",
112
106
  "istio_gateways_list_tool", "istio_peerauthentications_list_tool", "istio_authorizationpolicies_list_tool",
113
107
  "istio_proxy_status_tool", "istio_analyze_tool", "istio_sidecar_status_tool", "istio_detect_tool",
108
+ # vind tools (vind.py) - 14 tools
109
+ "vind_detect_tool", "vind_list_clusters_tool", "vind_status_tool", "vind_get_kubeconfig_tool",
110
+ "vind_logs_tool", "vind_create_cluster_tool", "vind_delete_cluster_tool", "vind_pause_tool",
111
+ "vind_resume_tool", "vind_connect_tool", "vind_disconnect_tool", "vind_upgrade_tool",
112
+ "vind_describe_tool", "vind_platform_start_tool",
113
+ # kind tools (kind.py) - 32 tools
114
+ "kind_detect_tool", "kind_version_tool", "kind_list_clusters_tool", "kind_get_nodes_tool",
115
+ "kind_get_kubeconfig_tool", "kind_export_logs_tool", "kind_cluster_info_tool", "kind_node_labels_tool",
116
+ "kind_create_cluster_tool", "kind_delete_cluster_tool", "kind_delete_all_clusters_tool",
117
+ "kind_load_image_tool", "kind_load_image_archive_tool", "kind_build_node_image_tool",
118
+ "kind_set_kubeconfig_tool", "kind_config_validate_tool", "kind_config_generate_tool",
119
+ "kind_config_show_tool", "kind_available_images_tool", "kind_registry_create_tool",
120
+ "kind_registry_connect_tool", "kind_registry_status_tool", "kind_node_exec_tool",
121
+ "kind_node_logs_tool", "kind_node_inspect_tool", "kind_node_restart_tool",
122
+ "kind_network_inspect_tool", "kind_port_mappings_tool", "kind_ingress_setup_tool",
123
+ "kind_cluster_status_tool", "kind_images_list_tool", "kind_provider_info_tool",
114
124
  ]
115
125
 
126
+ EXPECTED_TOOL_COUNT = len(EXPECTED_TOOLS)
127
+
116
128
 
117
129
  class TestAllToolsRegistered:
118
- """Comprehensive tests to verify all 235 tools are registered (136 core + 6 UI + 93 ecosystem)."""
130
+ """Comprehensive tests to verify all expected tools are registered."""
119
131
 
120
132
  @pytest.mark.unit
121
- def test_all_164_tools_registered(self):
122
- """Verify all 235 expected tools are registered (excluding optional browser tools)."""
133
+ def test_all_tools_registered(self):
134
+ """Verify all expected tools are registered (excluding optional browser tools)."""
123
135
  import os
124
136
  from kubectl_mcp_tool.mcp_server import MCPServer
125
137
 
126
- # Disable browser tools for this test
127
138
  with patch.dict(os.environ, {"MCP_BROWSER_ENABLED": "false"}):
128
- # Reload browser module to pick up env change
129
139
  import importlib
130
140
  import kubectl_mcp_tool.tools.browser as browser_module
131
141
  importlib.reload(browser_module)
@@ -140,14 +150,11 @@ class TestAllToolsRegistered:
140
150
  tools = asyncio.run(get_tools())
141
151
  tool_names = {t.name for t in tools}
142
152
 
143
- # Verify count (235 tools = 136 core + 6 UI + 93 ecosystem, browser tools disabled)
144
- assert len(tools) == 235, f"Expected 235 tools, got {len(tools)}"
153
+ assert len(tools) == EXPECTED_TOOL_COUNT, f"Expected {EXPECTED_TOOL_COUNT} tools, got {len(tools)}"
145
154
 
146
- # Check for missing tools
147
155
  missing_tools = set(EXPECTED_TOOLS) - tool_names
148
156
  assert not missing_tools, f"Missing tools: {missing_tools}"
149
157
 
150
- # Check for unexpected tools (tools not in expected list)
151
158
  unexpected_tools = tool_names - set(EXPECTED_TOOLS)
152
159
  assert not unexpected_tools, f"Unexpected tools: {unexpected_tools}"
153
160
 
@@ -176,8 +183,9 @@ class TestAllToolsRegistered:
176
183
  register_capi_tools,
177
184
  register_kubevirt_tools,
178
185
  register_istio_tools,
186
+ register_vind_tools,
187
+ register_kind_tools,
179
188
  )
180
- # All imports should succeed
181
189
  assert callable(register_helm_tools)
182
190
  assert callable(register_pod_tools)
183
191
  assert callable(register_core_tools)
@@ -189,18 +197,18 @@ class TestAllToolsRegistered:
189
197
  assert callable(register_operations_tools)
190
198
  assert callable(register_diagnostics_tools)
191
199
  assert callable(register_cost_tools)
192
- # Ecosystem tools
193
200
  assert callable(register_gitops_tools)
194
201
  assert callable(register_certs_tools)
195
202
  assert callable(register_policy_tools)
196
203
  assert callable(register_backup_tools)
197
- # Advanced ecosystem tools
198
204
  assert callable(register_keda_tools)
199
205
  assert callable(register_cilium_tools)
200
206
  assert callable(register_rollouts_tools)
201
207
  assert callable(register_capi_tools)
202
208
  assert callable(register_kubevirt_tools)
203
209
  assert callable(register_istio_tools)
210
+ assert callable(register_vind_tools)
211
+ assert callable(register_kind_tools)
204
212
 
205
213
  @pytest.mark.unit
206
214
  def test_all_tools_have_descriptions(self):