diff --git a/README.md b/README.md index b710f4a..a70d2dc 100644 --- a/README.md +++ b/README.md @@ -108,82 +108,82 @@ The server dynamically filters the available tools based on the permissions asso - **Required Permission**: `sage.exec`, `risks.read` - **Sample Prompt**: "Run this query: MATCH CloudResource WHERE type = 'aws_s3_bucket' LIMIT 10" -- **`kubernetes_list_clusters`** +- **`k8s_list_clusters`** - **Description**: Lists the cluster information for all clusters or just the cluster specified. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "List all kubernetes clusters" or "Show me info for cluster 'production-gke'" -- **`kubernetes_list_nodes`** +- **`k8s_list_nodes`** - **Description**: Lists the node information for all nodes, all nodes from a cluster or just the node specified. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "List all kubernetes nodes in the cluster 'production-gke'" or "Show me info for node 'node-123'" -- **`kubernetes_list_workloads`** +- **`k8s_list_workloads`** - **Description**: Lists all the workloads that are in a particular state, desired, ready, running or unavailable. The LLM can filter by cluster, namespace, workload name or type. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "List all desired workloads in the cluster 'production-gke' and namespace 'default'" -- **`kubernetes_list_pod_containers`** +- **`k8s_list_pod_containers`** - **Description**: Retrieves information from a particular pod and container. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show me info for pod 'my-pod' in cluster 'production-gke'" -- **`kubernetes_list_cronjobs`** +- **`k8s_list_cronjobs`** - **Description**: Retrieves information from the cronjobs in the cluster. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "List all cronjobs in cluster 'prod' and namespace 'default'" -- **`troubleshoot_kubernetes_list_top_unavailable_pods`** +- **`k8s_list_top_unavailable_pods`** - **Description**: Shows the top N pods with the highest number of unavailable or unready replicas in a Kubernetes cluster, ordered from highest to lowest. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 20 unavailable pods in cluster 'production'" -- **`troubleshoot_kubernetes_list_top_restarted_pods`** +- **`k8s_list_top_restarted_pods`** - **Description**: Lists the pods with the highest number of container restarts in the specified scope (cluster, namespace, workload, or individual pod). By default, it returns the top 10. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 10 pods with the most container restarts in cluster 'production'" -- **`troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods`** +- **`k8s_list_top_http_errors_in_pods`** - **Description**: Lists the pods with the highest rate of HTTP 4xx and 5xx errors over a specified time interval, allowing filtering by cluster, namespace, workload type, and workload name. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 20 pods with the most HTTP errors in cluster 'production'" -- **`troubleshoot_kubernetes_list_top_network_errors_in_pods`** +- **`k8s_list_top_network_errors_in_pods`** - **Description**: Shows the top network errors by pod over a given interval, aggregated by cluster, namespace, workload type, and workload name. The result is an average rate of network errors per second. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 10 pods with the most network errors in cluster 'production'" -- **`troubleshoot_kubernetes_list_count_pods_per_cluster`** +- **`k8s_list_count_pods_per_cluster`** - **Description**: List the count of running Kubernetes Pods grouped by cluster and namespace. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "List the count of running Kubernetes Pods in cluster 'production'" -- **`troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota`** +- **`k8s_list_underutilized_pods_cpu_quota`** - **Description**: List Kubernetes pods with CPU usage below 25% of the quota limit. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 10 underutilized pods by CPU quota in cluster 'production'" -- **`troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota`** +- **`k8s_list_underutilized_pods_memory_quota`** - **Description**: List Kubernetes pods with memory usage below 25% of the limit. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 10 underutilized pods by memory quota in cluster 'production'" -- **`troubleshoot_kubernetes_list_top_cpu_consumed_by_workload`** +- **`k8s_list_top_cpu_consumed_workload`** - **Description**: Identifies the Kubernetes workloads (all containers) consuming the most CPU (in cores). - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 10 workloads consuming the most CPU in cluster 'production'" -- **`troubleshoot_kubernetes_list_top_cpu_consumed_by_container`** +- **`k8s_list_top_cpu_consumed_container`** - **Description**: Identifies the Kubernetes containers consuming the most CPU (in cores). - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 10 containers consuming the most CPU in cluster 'production'" -- **`troubleshoot_kubernetes_list_top_memory_consumed_by_workload`** +- **`k8s_list_top_memory_consumed_workload`** - **Description**: Lists memory-intensive workloads (all containers). - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 10 workloads consuming the most memory in cluster 'production'" -- **`troubleshoot_kubernetes_list_top_memory_consumed_by_container`** +- **`k8s_list_top_memory_consumed_container`** - **Description**: Lists memory-intensive containers. - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "Show the top 10 containers consuming the most memory in cluster 'production'" diff --git a/cmd/server/main.go b/cmd/server/main.go index 401e0dc..c85e88a 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -95,22 +95,22 @@ func setupHandler(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *mcp tools.NewToolRunSysql(sysdigClient), tools.NewToolGenerateSysql(sysdigClient), - tools.NewKubernetesListClusters(sysdigClient), - tools.NewKubernetesListNodes(sysdigClient), - tools.NewKubernetesListCronjobs(sysdigClient), - tools.NewKubernetesListWorkloads(sysdigClient), - tools.NewKubernetesListPodContainers(sysdigClient), - tools.NewTroubleshootKubernetesListTopUnavailablePods(sysdigClient), - tools.NewTroubleshootKubernetesListTopRestartedPods(sysdigClient), - tools.NewTroubleshootKubernetesListTop400500HttpErrorsInPods(sysdigClient), - tools.NewTroubleshootKubernetesListTopNetworkErrorsInPods(sysdigClient), - tools.NewTroubleshootKubernetesListCountPodsPerCluster(sysdigClient), - tools.NewTroubleshootKubernetesListUnderutilizedPodsByCPUQuota(sysdigClient), - tools.NewTroubleshootKubernetesListTopCPUConsumedByWorkload(sysdigClient), - tools.NewTroubleshootKubernetesListTopCPUConsumedByContainer(sysdigClient), - tools.NewTroubleshootKubernetesListUnderutilizedPodsByMemoryQuota(sysdigClient), - tools.NewTroubleshootKubernetesListTopMemoryConsumedByWorkload(sysdigClient), - tools.NewTroubleshootKubernetesListTopMemoryConsumedByContainer(sysdigClient), + tools.NewK8sListClusters(sysdigClient), + tools.NewK8sListNodes(sysdigClient), + tools.NewK8sListCronjobs(sysdigClient), + tools.NewK8sListWorkloads(sysdigClient), + tools.NewK8sListPodContainers(sysdigClient), + tools.NewK8sListTopUnavailablePods(sysdigClient), + tools.NewK8sListTopRestartedPods(sysdigClient), + tools.NewK8sListTopHttpErrorsInPods(sysdigClient), + tools.NewK8sListTopNetworkErrorsInPods(sysdigClient), + tools.NewK8sListCountPodsPerCluster(sysdigClient), + tools.NewK8sListUnderutilizedPodsCPUQuota(sysdigClient), + tools.NewK8sListTopCPUConsumedWorkload(sysdigClient), + tools.NewK8sListTopCPUConsumedContainer(sysdigClient), + tools.NewK8sListUnderutilizedPodsMemoryQuota(sysdigClient), + tools.NewK8sListTopMemoryConsumedWorkload(sysdigClient), + tools.NewK8sListTopMemoryConsumedContainer(sysdigClient), ) return handler } diff --git a/internal/infra/mcp/tools/README.md b/internal/infra/mcp/tools/README.md index 61d8879..a40a70f 100644 --- a/internal/infra/mcp/tools/README.md +++ b/internal/infra/mcp/tools/README.md @@ -7,24 +7,24 @@ The handler filters tools dynamically based on the Sysdig user's permissions. Ea | `generate_sysql` | `tool_generate_sysql.go` | Convert natural language to SysQL via Sysdig Sage. | `sage.exec` (does not work with Service Accounts) | “Create a SysQL to list S3 buckets.” | | `get_event_info` | `tool_get_event_info.go` | Pull full payload for a single policy event. | `policy-events.read` | “Fetch event `abc123` details.” | | `get_event_process_tree` | `tool_get_event_process_tree.go` | Retrieve the process tree for an event when available. | `policy-events.read` | “Show the process tree behind event `abc123`.” | -| `kubernetes_list_clusters` | `tool_kubernetes_list_clusters.go` | Lists Kubernetes cluster information. | `metrics-data.read` | "List all Kubernetes clusters" | -| `kubernetes_list_cronjobs` | `tool_kubernetes_list_cronjobs.go` | Retrieves information from the cronjobs in the cluster. | `metrics-data.read` | "List all cronjobs in cluster 'prod' and namespace 'default'" | -| `kubernetes_list_nodes` | `tool_kubernetes_list_nodes.go` | Lists Kubernetes node information. | `metrics-data.read` | "List all Kubernetes nodes in the cluster 'production-gke'" | -| `kubernetes_list_pod_containers` | `tool_kubernetes_list_pod_containers.go` | Retrieves information from a particular pod and container. | `metrics-data.read` | "Show me info for pod 'my-pod' in cluster 'production-gke'" | -| `kubernetes_list_workloads` | `tool_kubernetes_list_workloads.go` | Lists Kubernetes workload information. | `metrics-data.read` | "List all desired workloads in the cluster 'production-gke' and namespace 'default'" | +| `k8s_list_clusters` | `tool_k8s_list_clusters.go` | Lists Kubernetes cluster information. | `metrics-data.read` | "List all Kubernetes clusters" | +| `k8s_list_cronjobs` | `tool_k8s_list_cronjobs.go` | Retrieves information from the cronjobs in the cluster. | `metrics-data.read` | "List all cronjobs in cluster 'prod' and namespace 'default'" | +| `k8s_list_nodes` | `tool_k8s_list_nodes.go` | Lists Kubernetes node information. | `metrics-data.read` | "List all Kubernetes nodes in the cluster 'production-gke'" | +| `k8s_list_pod_containers` | `tool_k8s_list_pod_containers.go` | Retrieves information from a particular pod and container. | `metrics-data.read` | "Show me info for pod 'my-pod' in cluster 'production-gke'" | +| `k8s_list_workloads` | `tool_k8s_list_workloads.go` | Lists Kubernetes workload information. | `metrics-data.read` | "List all desired workloads in the cluster 'production-gke' and namespace 'default'" | | `list_runtime_events` | `tool_list_runtime_events.go` | Query runtime events with filters, cursor, scope. | `policy-events.read` | “Show high severity runtime events from last 2h.” | | `run_sysql` | `tool_run_sysql.go` | Execute caller-supplied Sysdig SysQL queries safely. | `sage.exec`, `risks.read` | “Run the following SysQL…”. | -| `troubleshoot_kubernetes_list_count_pods_per_cluster` | `tool_troubleshoot_kubernetes_list_count_pods_per_cluster.go` | List the count of running Kubernetes Pods grouped by cluster and namespace. | `metrics-data.read` | "List the count of running Kubernetes Pods in cluster 'production'" | -| `troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods` | `tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods.go` | Lists the pods with the highest rate of HTTP 4xx and 5xx errors over a specified time interval. | `metrics-data.read` | "Show the top 20 pods with the most HTTP errors in cluster 'production'" | -| `troubleshoot_kubernetes_list_top_cpu_consumed_by_container` | `tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container.go` | Identifies the Kubernetes containers consuming the most CPU (in cores). | `metrics-data.read` | "Show the top 10 containers consuming the most CPU in cluster 'production'" | -| `troubleshoot_kubernetes_list_top_cpu_consumed_by_workload` | `tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload.go` | Identifies the Kubernetes workloads (all containers) consuming the most CPU (in cores). | `metrics-data.read` | "Show the top 10 workloads consuming the most CPU in cluster 'production'" | -| `troubleshoot_kubernetes_list_top_memory_consumed_by_container` | `tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container.go` | Lists memory-intensive containers. | `metrics-data.read` | "Show the top 10 containers consuming the most memory in cluster 'production'" | -| `troubleshoot_kubernetes_list_top_memory_consumed_by_workload` | `tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload.go` | Lists memory-intensive workloads (all containers). | `metrics-data.read` | "Show the top 10 workloads consuming the most memory in cluster 'production'" | -| `troubleshoot_kubernetes_list_top_network_errors_in_pods` | `tool_troubleshoot_kubernetes_list_top_network_errors_in_pods.go` | Shows the top network errors by pod over a given interval. | `metrics-data.read` | "Show the top 10 pods with the most network errors in cluster 'production'" | -| `troubleshoot_kubernetes_list_top_restarted_pods` | `tool_troubleshoot_kubernetes_list_top_restarted_pods.go` | Lists the pods with the highest number of container restarts. | `metrics-data.read` | "Show the top 10 pods with the most container restarts in cluster 'production'" | -| `troubleshoot_kubernetes_list_top_unavailable_pods` | `tool_troubleshoot_kubernetes_list_top_unavailable_pods.go` | Shows the top N pods with the highest number of unavailable or unready replicas. | `metrics-data.read` | "Show the top 20 unavailable pods in cluster 'production'" | -| `troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota` | `tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota.go` | List Kubernetes pods with CPU usage below 25% of the quota limit. | `metrics-data.read` | "Show the top 10 underutilized pods by CPU quota in cluster 'production'" | -| `troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota` | `tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota.go` | List Kubernetes pods with memory usage below 25% of the limit. | `metrics-data.read` | "Show the top 10 underutilized pods by memory quota in cluster 'production'" | +| `k8s_list_count_pods_per_cluster` | `tool_k8s_list_count_pods_per_cluster.go` | List the count of running Kubernetes Pods grouped by cluster and namespace. | `metrics-data.read` | "List the count of running Kubernetes Pods in cluster 'production'" | +| `k8s_list_top_http_errors_in_pods` | `tool_k8s_list_top_http_errors_in_pods.go` | Lists the pods with the highest rate of HTTP 4xx and 5xx errors over a specified time interval. | `metrics-data.read` | "Show the top 20 pods with the most HTTP errors in cluster 'production'" | +| `k8s_list_top_cpu_consumed_container` | `tool_k8s_list_top_cpu_consumed_container.go` | Identifies the Kubernetes containers consuming the most CPU (in cores). | `metrics-data.read` | "Show the top 10 containers consuming the most CPU in cluster 'production'" | +| `k8s_list_top_cpu_consumed_workload` | `tool_k8s_list_top_cpu_consumed_workload.go` | Identifies the Kubernetes workloads (all containers) consuming the most CPU (in cores). | `metrics-data.read` | "Show the top 10 workloads consuming the most CPU in cluster 'production'" | +| `k8s_list_top_memory_consumed_container` | `tool_k8s_list_top_memory_consumed_container.go` | Lists memory-intensive containers. | `metrics-data.read` | "Show the top 10 containers consuming the most memory in cluster 'production'" | +| `k8s_list_top_memory_consumed_workload` | `tool_k8s_list_top_memory_consumed_workload.go` | Lists memory-intensive workloads (all containers). | `metrics-data.read` | "Show the top 10 workloads consuming the most memory in cluster 'production'" | +| `k8s_list_top_network_errors_in_pods` | `tool_k8s_list_top_network_errors_in_pods.go` | Shows the top network errors by pod over a given interval. | `metrics-data.read` | "Show the top 10 pods with the most network errors in cluster 'production'" | +| `k8s_list_top_restarted_pods` | `tool_k8s_list_top_restarted_pods.go` | Lists the pods with the highest number of container restarts. | `metrics-data.read` | "Show the top 10 pods with the most container restarts in cluster 'production'" | +| `k8s_list_top_unavailable_pods` | `tool_k8s_list_top_unavailable_pods.go` | Shows the top N pods with the highest number of unavailable or unready replicas. | `metrics-data.read` | "Show the top 20 unavailable pods in cluster 'production'" | +| `k8s_list_underutilized_pods_cpu_quota` | `tool_k8s_list_underutilized_pods_cpu_quota.go` | List Kubernetes pods with CPU usage below 25% of the quota limit. | `metrics-data.read` | "Show the top 10 underutilized pods by CPU quota in cluster 'production'" | +| `k8s_list_underutilized_pods_memory_quota` | `tool_k8s_list_underutilized_pods_memory_quota.go` | List Kubernetes pods with memory usage below 25% of the limit. | `metrics-data.read` | "Show the top 10 underutilized pods by memory quota in cluster 'production'" | # Adding a New Tool diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_clusters.go b/internal/infra/mcp/tools/tool_k8s_list_clusters.go similarity index 80% rename from internal/infra/mcp/tools/tool_kubernetes_list_clusters.go rename to internal/infra/mcp/tools/tool_k8s_list_clusters.go index f314dad..85ac4ef 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_clusters.go +++ b/internal/infra/mcp/tools/tool_k8s_list_clusters.go @@ -11,18 +11,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type KubernetesListClusters struct { +type K8sListClusters struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListClusters(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListClusters { - return &KubernetesListClusters{ +func NewK8sListClusters(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListClusters { + return &K8sListClusters{ SysdigClient: sysdigClient, } } -func (t *KubernetesListClusters) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_clusters", +func (t *K8sListClusters) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_clusters", mcp.WithDescription("Lists the cluster information for all clusters or just the cluster specified."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithNumber("limit", @@ -37,7 +37,7 @@ func (t *KubernetesListClusters) RegisterInServer(s *server.MCPServer) { s.AddTool(tool, t.handle) } -func (t *KubernetesListClusters) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListClusters) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") limit := mcp.ParseInt(request, "limit", 10) diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_clusters_test.go b/internal/infra/mcp/tools/tool_k8s_list_clusters_test.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_clusters_test.go rename to internal/infra/mcp/tools/tool_k8s_list_clusters_test.go index 85273f2..7eba6a7 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_clusters_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_clusters_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListClusters Tool", func() { var ( - tool *tools.KubernetesListClusters + tool *tools.K8sListClusters mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListClusters Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListClusters(mockSysdig) + tool = tools.NewK8sListClusters(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_clusters")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_clusters")).NotTo(BeNil()) }) When("listing all clusters", func() { @@ -52,10 +52,10 @@ var _ = Describe("KubernetesListClusters Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_clusters", + "k8s_list_clusters", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_clusters", + Name: "k8s_list_clusters", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListClusters Tool", func() { }, ), Entry(nil, - "kubernetes_list_clusters", + "k8s_list_clusters", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_clusters", + Name: "k8s_list_clusters", Arguments: map[string]any{"limit": "20"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("KubernetesListClusters Tool", func() { }, ), Entry(nil, - "kubernetes_list_clusters", + "k8s_list_clusters", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_clusters", + Name: "k8s_list_clusters", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("KubernetesListClusters Tool", func() { }, ), Entry(nil, - "kubernetes_list_clusters", + "k8s_list_clusters", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_clusters", + Name: "k8s_list_clusters", Arguments: map[string]any{"cluster_name": "my_cluster", "limit": "20"}, }, }, diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster.go b/internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster.go similarity index 80% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster.go rename to internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster.go index 03d254d..3ec4ab0 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster.go +++ b/internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListCountPodsPerCluster struct { +type K8sListCountPodsPerCluster struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListCountPodsPerCluster(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListCountPodsPerCluster { - return &TroubleshootKubernetesListCountPodsPerCluster{ +func NewK8sListCountPodsPerCluster(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListCountPodsPerCluster { + return &K8sListCountPodsPerCluster{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListCountPodsPerCluster) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_count_pods_per_cluster", +func (t *K8sListCountPodsPerCluster) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_count_pods_per_cluster", mcp.WithDescription("List the count of running Kubernetes Pods grouped by cluster and namespace."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -39,7 +39,7 @@ func (t *TroubleshootKubernetesListCountPodsPerCluster) RegisterInServer(s *serv s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListCountPodsPerCluster) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListCountPodsPerCluster) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") limit := mcp.ParseInt(request, "limit", 20) diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster_test.go b/internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster_test.go similarity index 76% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster_test.go rename to internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster_test.go index f5be1f0..9306984 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListCountPodsPerCluster Tool", func() { +var _ = Describe("KubernetesListCountPodsPerCluster Tool", func() { var ( - tool *tools.TroubleshootKubernetesListCountPodsPerCluster + tool *tools.K8sListCountPodsPerCluster mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("TroubleshootKubernetesListCountPodsPerCluster Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListCountPodsPerCluster(mockSysdig) + tool = tools.NewK8sListCountPodsPerCluster(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_count_pods_per_cluster")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_count_pods_per_cluster")).NotTo(BeNil()) }) When("counting pods", func() { @@ -52,10 +52,10 @@ var _ = Describe("TroubleshootKubernetesListCountPodsPerCluster Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "troubleshoot_kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "k8s_list_count_pods_per_cluster", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("TroubleshootKubernetesListCountPodsPerCluster Tool", func() { }, ), Entry(nil, - "troubleshoot_kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "k8s_list_count_pods_per_cluster", Arguments: map[string]any{"limit": "10"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("TroubleshootKubernetesListCountPodsPerCluster Tool", func() { }, ), Entry(nil, - "troubleshoot_kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "k8s_list_count_pods_per_cluster", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("TroubleshootKubernetesListCountPodsPerCluster Tool", func() { }, ), Entry(nil, - "troubleshoot_kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "k8s_list_count_pods_per_cluster", Arguments: map[string]any{"namespace_name": "my_namespace"}, }, }, @@ -104,10 +104,10 @@ var _ = Describe("TroubleshootKubernetesListCountPodsPerCluster Tool", func() { }, ), Entry(nil, - "troubleshoot_kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "k8s_list_count_pods_per_cluster", Arguments: map[string]any{"cluster_name": "my_cluster", "namespace_name": "my_namespace"}, }, }, diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_cronjobs.go b/internal/infra/mcp/tools/tool_k8s_list_cronjobs.go similarity index 86% rename from internal/infra/mcp/tools/tool_kubernetes_list_cronjobs.go rename to internal/infra/mcp/tools/tool_k8s_list_cronjobs.go index 80574b0..15199e5 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_cronjobs.go +++ b/internal/infra/mcp/tools/tool_k8s_list_cronjobs.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type KubernetesListCronjobs struct { +type K8sListCronjobs struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListCronjobs(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListCronjobs { - return &KubernetesListCronjobs{ +func NewK8sListCronjobs(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListCronjobs { + return &K8sListCronjobs{ SysdigClient: sysdigClient, } } -func (t *KubernetesListCronjobs) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_cronjobs", +func (t *K8sListCronjobs) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_cronjobs", mcp.WithDescription("Retrieves information from the cronjobs in the cluster."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -40,7 +40,7 @@ func (t *KubernetesListCronjobs) RegisterInServer(s *server.MCPServer) { s.AddTool(tool, t.handle) } -func (t *KubernetesListCronjobs) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListCronjobs) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") cronjobName := mcp.ParseString(request, "cronjob_name", "") diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_cronjobs_test.go b/internal/infra/mcp/tools/tool_k8s_list_cronjobs_test.go similarity index 84% rename from internal/infra/mcp/tools/tool_kubernetes_list_cronjobs_test.go rename to internal/infra/mcp/tools/tool_k8s_list_cronjobs_test.go index ec6001c..9455e4a 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_cronjobs_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_cronjobs_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListCronjobs Tool", func() { var ( - tool *tools.KubernetesListCronjobs + tool *tools.K8sListCronjobs mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListCronjobs Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListCronjobs(mockSysdig) + tool = tools.NewK8sListCronjobs(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_cronjobs")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_cronjobs")).NotTo(BeNil()) }) When("listing cronjobs", func() { @@ -52,10 +52,10 @@ var _ = Describe("KubernetesListCronjobs Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_cronjobs", + "k8s_list_cronjobs", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_cronjobs", + Name: "k8s_list_cronjobs", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListCronjobs Tool", func() { }, ), Entry(nil, - "kubernetes_list_cronjobs", + "k8s_list_cronjobs", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_cronjobs", + Name: "k8s_list_cronjobs", Arguments: map[string]any{"limit": "20"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("KubernetesListCronjobs Tool", func() { }, ), Entry(nil, - "kubernetes_list_cronjobs", + "k8s_list_cronjobs", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_cronjobs", + Name: "k8s_list_cronjobs", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("KubernetesListCronjobs Tool", func() { }, ), Entry(nil, - "kubernetes_list_cronjobs", + "k8s_list_cronjobs", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_cronjobs", + Name: "k8s_list_cronjobs", Arguments: map[string]any{"namespace_name": "my_namespace"}, }, }, @@ -104,10 +104,10 @@ var _ = Describe("KubernetesListCronjobs Tool", func() { }, ), Entry(nil, - "kubernetes_list_cronjobs", + "k8s_list_cronjobs", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_cronjobs", + Name: "k8s_list_cronjobs", Arguments: map[string]any{"cronjob_name": "my_cronjob"}, }, }, @@ -117,10 +117,10 @@ var _ = Describe("KubernetesListCronjobs Tool", func() { }, ), Entry(nil, - "kubernetes_list_cronjobs", + "k8s_list_cronjobs", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_cronjobs", + Name: "k8s_list_cronjobs", Arguments: map[string]any{"cluster_name": "my_cluster", "namespace_name": "my_namespace", "cronjob_name": "my_cronjob"}, }, }, diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_nodes.go b/internal/infra/mcp/tools/tool_k8s_list_nodes.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_nodes.go rename to internal/infra/mcp/tools/tool_k8s_list_nodes.go index 20af225..1aa9c81 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_nodes.go +++ b/internal/infra/mcp/tools/tool_k8s_list_nodes.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type KubernetesListNodes struct { +type K8sListNodes struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListNodes(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListNodes { - return &KubernetesListNodes{ +func NewK8sListNodes(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListNodes { + return &K8sListNodes{ SysdigClient: sysdigClient, } } -func (t *KubernetesListNodes) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_nodes", +func (t *K8sListNodes) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_nodes", mcp.WithDescription("Lists the information from all nodes, all nodes from a cluster or a specific node with some name."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("node_name", mcp.Description("The name of the node to filter by.")), @@ -39,7 +39,7 @@ func (t *KubernetesListNodes) RegisterInServer(s *server.MCPServer) { s.AddTool(tool, t.handle) } -func (t *KubernetesListNodes) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListNodes) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") nodeName := mcp.ParseString(request, "node_name", "") limit := mcp.ParseInt(request, "limit", 10) diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_nodes_test.go b/internal/infra/mcp/tools/tool_k8s_list_nodes_test.go similarity index 84% rename from internal/infra/mcp/tools/tool_kubernetes_list_nodes_test.go rename to internal/infra/mcp/tools/tool_k8s_list_nodes_test.go index 624372c..72ea46e 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_nodes_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_nodes_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListNodes Tool", func() { var ( - tool *tools.KubernetesListNodes + tool *tools.K8sListNodes mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListNodes Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListNodes(mockSysdig) + tool = tools.NewK8sListNodes(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_nodes")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_nodes")).NotTo(BeNil()) }) When("listing nodes", func() { @@ -52,10 +52,10 @@ var _ = Describe("KubernetesListNodes Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_nodes", + "k8s_list_nodes", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_nodes", + Name: "k8s_list_nodes", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListNodes Tool", func() { }, ), Entry(nil, - "kubernetes_list_nodes", + "k8s_list_nodes", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_nodes", + Name: "k8s_list_nodes", Arguments: map[string]any{"limit": "20"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("KubernetesListNodes Tool", func() { }, ), Entry(nil, - "kubernetes_list_nodes", + "k8s_list_nodes", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_nodes", + Name: "k8s_list_nodes", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("KubernetesListNodes Tool", func() { }, ), Entry(nil, - "kubernetes_list_nodes", + "k8s_list_nodes", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_nodes", + Name: "k8s_list_nodes", Arguments: map[string]any{"node_name": "my_node"}, }, }, @@ -104,10 +104,10 @@ var _ = Describe("KubernetesListNodes Tool", func() { }, ), Entry(nil, - "kubernetes_list_nodes", + "k8s_list_nodes", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_nodes", + Name: "k8s_list_nodes", Arguments: map[string]any{"cluster_name": "my_cluster", "node_name": "my_node"}, }, }, @@ -117,10 +117,10 @@ var _ = Describe("KubernetesListNodes Tool", func() { }, ), Entry(nil, - "kubernetes_list_nodes", + "k8s_list_nodes", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_nodes", + Name: "k8s_list_nodes", Arguments: map[string]any{"cluster_name": "my_cluster", "limit": "20"}, }, }, diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_pod_containers.go b/internal/infra/mcp/tools/tool_k8s_list_pod_containers.go similarity index 89% rename from internal/infra/mcp/tools/tool_kubernetes_list_pod_containers.go rename to internal/infra/mcp/tools/tool_k8s_list_pod_containers.go index da192c8..5a42a65 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_pod_containers.go +++ b/internal/infra/mcp/tools/tool_k8s_list_pod_containers.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type KubernetesListPodContainers struct { +type K8sListPodContainers struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListPodContainers(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListPodContainers { - return &KubernetesListPodContainers{ +func NewK8sListPodContainers(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListPodContainers { + return &K8sListPodContainers{ SysdigClient: sysdigClient, } } -func (t *KubernetesListPodContainers) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_pod_containers", +func (t *K8sListPodContainers) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_pod_containers", mcp.WithDescription("Retrieves information from a particular pod and container."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -45,7 +45,7 @@ func (t *KubernetesListPodContainers) RegisterInServer(s *server.MCPServer) { s.AddTool(tool, t.handle) } -func (t *KubernetesListPodContainers) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListPodContainers) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") workloadType := mcp.ParseString(request, "workload_type", "") diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_pod_containers_test.go b/internal/infra/mcp/tools/tool_k8s_list_pod_containers_test.go similarity index 82% rename from internal/infra/mcp/tools/tool_kubernetes_list_pod_containers_test.go rename to internal/infra/mcp/tools/tool_k8s_list_pod_containers_test.go index 4442624..70c99a2 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_pod_containers_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_pod_containers_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListPodContainers Tool", func() { var ( - tool *tools.KubernetesListPodContainers + tool *tools.K8sListPodContainers mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListPodContainers(mockSysdig) + tool = tools.NewK8sListPodContainers(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_pod_containers")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_pod_containers")).NotTo(BeNil()) }) When("listing pod containers", func() { @@ -52,10 +52,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{"limit": "20"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{"namespace_name": "my_namespace"}, }, }, @@ -104,10 +104,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{"workload_type": "my_workload_type"}, }, }, @@ -117,10 +117,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{"workload_name": "my_workload_name"}, }, }, @@ -130,10 +130,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{"pod_name": "my_pod_name"}, }, }, @@ -143,10 +143,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{"container_name": "my_container_name"}, }, }, @@ -156,10 +156,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{"image_pullstring": "my_image"}, }, }, @@ -169,10 +169,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{"node_name": "my_node_name"}, }, }, @@ -182,10 +182,10 @@ var _ = Describe("KubernetesListPodContainers Tool", func() { }, ), Entry(nil, - "kubernetes_list_pod_containers", + "k8s_list_pod_containers", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_pod_containers", + Name: "k8s_list_pod_containers", Arguments: map[string]any{ "cluster_name": "my_cluster", "namespace_name": "my_namespace", diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container.go b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container.go similarity index 83% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container.go rename to internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container.go index d27415c..da42d23 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopCPUConsumedByContainer struct { +type K8sListTopCPUConsumedContainer struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopCPUConsumedByContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopCPUConsumedByContainer { - return &TroubleshootKubernetesListTopCPUConsumedByContainer{ +func NewK8sListTopCPUConsumedContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopCPUConsumedContainer { + return &K8sListTopCPUConsumedContainer{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopCPUConsumedByContainer) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_cpu_consumed_by_container", +func (t *K8sListTopCPUConsumedContainer) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_top_cpu_consumed_container", mcp.WithDescription("Identifies the Kubernetes containers consuming the most CPU (in cores)."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -41,7 +41,7 @@ func (t *TroubleshootKubernetesListTopCPUConsumedByContainer) RegisterInServer(s s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListTopCPUConsumedByContainer) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListTopCPUConsumedContainer) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") workloadType := mcp.ParseString(request, "workload_type", "") diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container_test.go similarity index 78% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container_test.go index 6fbaf8d..04ada33 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListTopCPUConsumedByContainer Tool", func() { +var _ = Describe("KubernetesListTopCPUConsumedContainer Tool", func() { var ( - tool *tools.TroubleshootKubernetesListTopCPUConsumedByContainer + tool *tools.K8sListTopCPUConsumedContainer mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("TroubleshootKubernetesListTopCPUConsumedByContainer Tool", fun BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListTopCPUConsumedByContainer(mockSysdig) + tool = tools.NewK8sListTopCPUConsumedContainer(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_top_cpu_consumed_by_container")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_top_cpu_consumed_container")).NotTo(BeNil()) }) When("listing top cpu consumed by container", func() { @@ -51,10 +51,10 @@ var _ = Describe("TroubleshootKubernetesListTopCPUConsumedByContainer Tool", fun Expect(ok).To(BeTrue()) Expect(resultData.Text).To(ContainSubstring(`"status":"success"`)) }, - Entry("with no params", context.Background(), "troubleshoot_kubernetes_list_top_cpu_consumed_by_container", + Entry("with no params", context.Background(), "k8s_list_top_cpu_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_container", + Name: "k8s_list_top_cpu_consumed_container", Arguments: map[string]any{}, }, }, @@ -62,10 +62,10 @@ var _ = Describe("TroubleshootKubernetesListTopCPUConsumedByContainer Tool", fun Query: `topk(20, sum by (kube_cluster_name, kube_namespace_name, kube_workload_type, kube_workload_name, container_label_io_kubernetes_container_name)(sysdig_container_cpu_cores_used))`, }, ), - Entry("with all params", context.Background(), "troubleshoot_kubernetes_list_top_cpu_consumed_by_container", + Entry("with all params", context.Background(), "k8s_list_top_cpu_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_container", + Name: "k8s_list_top_cpu_consumed_container", Arguments: map[string]any{ "cluster_name": "test-cluster", "namespace_name": "test-namespace", diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload.go b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload.go similarity index 83% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload.go rename to internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload.go index 5e07810..99c03ca 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopCPUConsumedByWorkload struct { +type K8sListTopCPUConsumedWorkload struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopCPUConsumedByWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopCPUConsumedByWorkload { - return &TroubleshootKubernetesListTopCPUConsumedByWorkload{ +func NewK8sListTopCPUConsumedWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopCPUConsumedWorkload { + return &K8sListTopCPUConsumedWorkload{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopCPUConsumedByWorkload) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", +func (t *K8sListTopCPUConsumedWorkload) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_top_cpu_consumed_workload", mcp.WithDescription("Identifies the Kubernetes workloads (all containers) consuming the most CPU (in cores)."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -41,7 +41,7 @@ func (t *TroubleshootKubernetesListTopCPUConsumedByWorkload) RegisterInServer(s s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListTopCPUConsumedByWorkload) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListTopCPUConsumedWorkload) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") workloadType := mcp.ParseString(request, "workload_type", "") diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload_test.go similarity index 79% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload_test.go index f93f388..a1e4082 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListTopCPUConsumedByWorkload Tool", func() { +var _ = Describe("KubernetesListTopCPUConsumedWorkload Tool", func() { var ( - tool *tools.TroubleshootKubernetesListTopCPUConsumedByWorkload + tool *tools.K8sListTopCPUConsumedWorkload mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("TroubleshootKubernetesListTopCPUConsumedByWorkload Tool", func BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListTopCPUConsumedByWorkload(mockSysdig) + tool = tools.NewK8sListTopCPUConsumedWorkload(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_top_cpu_consumed_by_workload")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_top_cpu_consumed_workload")).NotTo(BeNil()) }) When("listing top cpu consumed by workload", func() { @@ -52,10 +52,10 @@ var _ = Describe("TroubleshootKubernetesListTopCPUConsumedByWorkload Tool", func Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", + "k8s_list_top_cpu_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", + Name: "k8s_list_top_cpu_consumed_workload", Arguments: map[string]any{}, }, }, @@ -64,10 +64,10 @@ var _ = Describe("TroubleshootKubernetesListTopCPUConsumedByWorkload Tool", func }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", + "k8s_list_top_cpu_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", + Name: "k8s_list_top_cpu_consumed_workload", Arguments: map[string]any{ "cluster_name": "prod", "namespace_name": "default", @@ -80,10 +80,10 @@ var _ = Describe("TroubleshootKubernetesListTopCPUConsumedByWorkload Tool", func }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", + "k8s_list_top_cpu_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", + Name: "k8s_list_top_cpu_consumed_workload", Arguments: map[string]any{ "cluster_name": "prod", "namespace_name": "default", diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods.go b/internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods.go similarity index 86% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods.go rename to internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods.go index 4729e10..90d9dd9 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods.go @@ -13,18 +13,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTop400500HttpErrorsInPods struct { +type K8sListTopHttpErrorsInPods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTop400500HttpErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTop400500HttpErrorsInPods { - return &TroubleshootKubernetesListTop400500HttpErrorsInPods{ +func NewK8sListTopHttpErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopHttpErrorsInPods { + return &K8sListTopHttpErrorsInPods{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTop400500HttpErrorsInPods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", +func (t *K8sListTopHttpErrorsInPods) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_top_http_errors_in_pods", mcp.WithDescription("Lists the pods with the highest rate of HTTP 4xx and 5xx errors over a specified time interval, allowing filtering by cluster, namespace, workload type, and workload name."), mcp.WithString("interval", mcp.Description("Time interval for the query (e.g. '1h', '30m'). Default is '1h'.")), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), @@ -43,7 +43,7 @@ func (t *TroubleshootKubernetesListTop400500HttpErrorsInPods) RegisterInServer(s s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListTop400500HttpErrorsInPods) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListTopHttpErrorsInPods) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { interval := mcp.ParseString(request, "interval", "1h") clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods_test.go similarity index 79% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods_test.go index 70d0cbe..4c302e2 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListTop400500HttpErrorsInPods Tool", func() { +var _ = Describe("KubernetesListTopHttpErrorsInPods Tool", func() { var ( - tool *tools.TroubleshootKubernetesListTop400500HttpErrorsInPods + tool *tools.K8sListTopHttpErrorsInPods mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -28,14 +28,14 @@ var _ = Describe("TroubleshootKubernetesListTop400500HttpErrorsInPods Tool", fun BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListTop400500HttpErrorsInPods(mockSysdig) + tool = tools.NewK8sListTopHttpErrorsInPods(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) ctx = context.Background() }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_top_http_errors_in_pods")).NotTo(BeNil()) }) When("listing top http errors", func() { @@ -54,10 +54,10 @@ var _ = Describe("TroubleshootKubernetesListTop400500HttpErrorsInPods Tool", fun Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry("default params", - "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + "k8s_list_top_http_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + Name: "k8s_list_top_http_errors_in_pods", Arguments: map[string]any{}, }, }, @@ -67,10 +67,10 @@ var _ = Describe("TroubleshootKubernetesListTop400500HttpErrorsInPods Tool", fun }, ), Entry("with custom params", - "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + "k8s_list_top_http_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + Name: "k8s_list_top_http_errors_in_pods", Arguments: map[string]any{ "interval": "30m", "cluster_name": "prod-cluster", @@ -85,10 +85,10 @@ var _ = Describe("TroubleshootKubernetesListTop400500HttpErrorsInPods Tool", fun }, ), Entry("with all params", - "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + "k8s_list_top_http_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + Name: "k8s_list_top_http_errors_in_pods", Arguments: map[string]any{ "interval": "2h", "cluster_name": "dev", @@ -107,10 +107,10 @@ var _ = Describe("TroubleshootKubernetesListTop400500HttpErrorsInPods Tool", fun ) It("returns error for invalid interval", func() { - serverTool := mcpServer.GetTool("troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods") + serverTool := mcpServer.GetTool("k8s_list_top_http_errors_in_pods") request := mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + Name: "k8s_list_top_http_errors_in_pods", Arguments: map[string]any{"interval": "invalid"}, }, } diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container.go b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container.go similarity index 82% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container.go rename to internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container.go index f705a61..72ece7b 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopMemoryConsumedByContainer struct { +type K8sListTopMemoryConsumedContainer struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopMemoryConsumedByContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopMemoryConsumedByContainer { - return &TroubleshootKubernetesListTopMemoryConsumedByContainer{ +func NewK8sListTopMemoryConsumedContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopMemoryConsumedContainer { + return &K8sListTopMemoryConsumedContainer{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopMemoryConsumedByContainer) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_memory_consumed_by_container", +func (t *K8sListTopMemoryConsumedContainer) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_top_memory_consumed_container", mcp.WithDescription("Lists memory-intensive containers."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -41,7 +41,7 @@ func (t *TroubleshootKubernetesListTopMemoryConsumedByContainer) RegisterInServe s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListTopMemoryConsumedByContainer) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListTopMemoryConsumedContainer) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") workloadType := mcp.ParseString(request, "workload_type", "") diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container_test.go similarity index 80% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container_test.go index c04aff4..25e28ef 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByContainer Tool", func() { +var _ = Describe("KubernetesListTopMemoryConsumedContainer Tool", func() { var ( - tool *tools.TroubleshootKubernetesListTopMemoryConsumedByContainer + tool *tools.K8sListTopMemoryConsumedContainer mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByContainer Tool", BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListTopMemoryConsumedByContainer(mockSysdig) + tool = tools.NewK8sListTopMemoryConsumedContainer(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_top_memory_consumed_by_container")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_top_memory_consumed_container")).NotTo(BeNil()) }) When("listing top memory consumed by container", func() { @@ -52,10 +52,10 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByContainer Tool", Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "troubleshoot_kubernetes_list_top_memory_consumed_by_container", + "k8s_list_top_memory_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_container", + Name: "k8s_list_top_memory_consumed_container", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByContainer Tool", }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_memory_consumed_by_container", + "k8s_list_top_memory_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_container", + Name: "k8s_list_top_memory_consumed_container", Arguments: map[string]any{ "cluster_name": "prod", "namespace_name": "default", @@ -82,10 +82,10 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByContainer Tool", }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_memory_consumed_by_container", + "k8s_list_top_memory_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_container", + Name: "k8s_list_top_memory_consumed_container", Arguments: map[string]any{ "cluster_name": "prod", "namespace_name": "default", diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload.go b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload.go similarity index 83% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload.go rename to internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload.go index 9284b77..1ec7158 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopMemoryConsumedByWorkload struct { +type K8sListTopMemoryConsumedWorkload struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopMemoryConsumedByWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopMemoryConsumedByWorkload { - return &TroubleshootKubernetesListTopMemoryConsumedByWorkload{ +func NewK8sListTopMemoryConsumedWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopMemoryConsumedWorkload { + return &K8sListTopMemoryConsumedWorkload{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopMemoryConsumedByWorkload) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_memory_consumed_by_workload", +func (t *K8sListTopMemoryConsumedWorkload) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_top_memory_consumed_workload", mcp.WithDescription("Lists memory-intensive workloads (all containers)."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -41,7 +41,7 @@ func (t *TroubleshootKubernetesListTopMemoryConsumedByWorkload) RegisterInServer s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListTopMemoryConsumedByWorkload) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListTopMemoryConsumedWorkload) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") workloadType := mcp.ParseString(request, "workload_type", "") diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload_test.go similarity index 78% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload_test.go index c3b39d9..7ddefb3 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByWorkload Tool", func() { +var _ = Describe("KubernetesListTopMemoryConsumedWorkload Tool", func() { var ( - tool *tools.TroubleshootKubernetesListTopMemoryConsumedByWorkload + tool *tools.K8sListTopMemoryConsumedWorkload mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByWorkload Tool", f BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListTopMemoryConsumedByWorkload(mockSysdig) + tool = tools.NewK8sListTopMemoryConsumedWorkload(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_top_memory_consumed_by_workload")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_top_memory_consumed_workload")).NotTo(BeNil()) }) When("listing top memory consumed by workload", func() { @@ -52,10 +52,10 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByWorkload Tool", f Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "k8s_list_top_memory_consumed_workload", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByWorkload Tool", f }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "k8s_list_top_memory_consumed_workload", Arguments: map[string]any{"limit": "10"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByWorkload Tool", f }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "k8s_list_top_memory_consumed_workload", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByWorkload Tool", f }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "k8s_list_top_memory_consumed_workload", Arguments: map[string]any{"cluster_name": "my_cluster", "namespace_name": "my_namespace"}, }, }, @@ -104,10 +104,10 @@ var _ = Describe("TroubleshootKubernetesListTopMemoryConsumedByWorkload Tool", f }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "k8s_list_top_memory_consumed_workload", Arguments: map[string]any{ "cluster_name": "my_cluster", "namespace_name": "my_namespace", diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_network_errors_in_pods.go b/internal/infra/mcp/tools/tool_k8s_list_top_network_errors_in_pods.go similarity index 85% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_network_errors_in_pods.go rename to internal/infra/mcp/tools/tool_k8s_list_top_network_errors_in_pods.go index 7b6cb54..6703a2e 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_network_errors_in_pods.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_network_errors_in_pods.go @@ -13,18 +13,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopNetworkErrorsInPods struct { +type K8sListTopNetworkErrorsInPods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopNetworkErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopNetworkErrorsInPods { - return &TroubleshootKubernetesListTopNetworkErrorsInPods{ +func NewK8sListTopNetworkErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopNetworkErrorsInPods { + return &K8sListTopNetworkErrorsInPods{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopNetworkErrorsInPods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_network_errors_in_pods", +func (t *K8sListTopNetworkErrorsInPods) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_top_network_errors_in_pods", mcp.WithDescription("Shows the top network errors by pod over a given interval, aggregated by cluster, namespace, workload type, and workload name. The result is an average rate of network errors per second."), mcp.WithString("interval", mcp.Description("Time interval for the query (e.g. '1h', '30m'). Default is '1h'.")), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), @@ -43,7 +43,7 @@ func (t *TroubleshootKubernetesListTopNetworkErrorsInPods) RegisterInServer(s *s s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListTopNetworkErrorsInPods) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListTopNetworkErrorsInPods) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { interval := mcp.ParseString(request, "interval", "1h") clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_network_errors_in_pods_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_network_errors_in_pods_test.go similarity index 80% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_network_errors_in_pods_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_network_errors_in_pods_test.go index e1d4b8d..14eb200 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_network_errors_in_pods_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_network_errors_in_pods_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListTopNetworkErrorsInPods Tool", func() { +var _ = Describe("KubernetesListTopNetworkErrorsInPods Tool", func() { var ( - tool *tools.TroubleshootKubernetesListTopNetworkErrorsInPods + tool *tools.K8sListTopNetworkErrorsInPods mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -28,14 +28,14 @@ var _ = Describe("TroubleshootKubernetesListTopNetworkErrorsInPods Tool", func() BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListTopNetworkErrorsInPods(mockSysdig) + tool = tools.NewK8sListTopNetworkErrorsInPods(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) ctx = context.Background() }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_top_network_errors_in_pods")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_top_network_errors_in_pods")).NotTo(BeNil()) }) When("listing top network errors", func() { @@ -54,10 +54,10 @@ var _ = Describe("TroubleshootKubernetesListTopNetworkErrorsInPods Tool", func() Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry("default params", - "troubleshoot_kubernetes_list_top_network_errors_in_pods", + "k8s_list_top_network_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_network_errors_in_pods", + Name: "k8s_list_top_network_errors_in_pods", Arguments: map[string]any{}, }, }, @@ -67,10 +67,10 @@ var _ = Describe("TroubleshootKubernetesListTopNetworkErrorsInPods Tool", func() }, ), Entry("with custom params", - "troubleshoot_kubernetes_list_top_network_errors_in_pods", + "k8s_list_top_network_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_network_errors_in_pods", + Name: "k8s_list_top_network_errors_in_pods", Arguments: map[string]any{ "interval": "30m", "cluster_name": "prod-cluster", @@ -85,10 +85,10 @@ var _ = Describe("TroubleshootKubernetesListTopNetworkErrorsInPods Tool", func() }, ), Entry("with all params", - "troubleshoot_kubernetes_list_top_network_errors_in_pods", + "k8s_list_top_network_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_network_errors_in_pods", + Name: "k8s_list_top_network_errors_in_pods", Arguments: map[string]any{ "interval": "2h", "cluster_name": "dev", @@ -107,10 +107,10 @@ var _ = Describe("TroubleshootKubernetesListTopNetworkErrorsInPods Tool", func() ) It("returns error for invalid interval", func() { - serverTool := mcpServer.GetTool("troubleshoot_kubernetes_list_top_network_errors_in_pods") + serverTool := mcpServer.GetTool("k8s_list_top_network_errors_in_pods") request := mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_network_errors_in_pods", + Name: "k8s_list_top_network_errors_in_pods", Arguments: map[string]any{"interval": "invalid"}, }, } @@ -128,12 +128,12 @@ var _ = Describe("TroubleshootKubernetesListTopNetworkErrorsInPods Tool", func() request := mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_network_errors_in_pods", + Name: "k8s_list_top_network_errors_in_pods", Arguments: map[string]any{}, }, } - serverTool := mcpServer.GetTool("troubleshoot_kubernetes_list_top_network_errors_in_pods") + serverTool := mcpServer.GetTool("k8s_list_top_network_errors_in_pods") res, err := serverTool.Handler(ctx, request) Expect(err).ToNot(HaveOccurred()) Expect(res.IsError).To(BeTrue()) diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_restarted_pods.go b/internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods.go similarity index 85% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_restarted_pods.go rename to internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods.go index d25d402..22e04ad 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_restarted_pods.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopRestartedPods struct { +type K8sListTopRestartedPods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopRestartedPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopRestartedPods { - return &TroubleshootKubernetesListTopRestartedPods{ +func NewK8sListTopRestartedPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopRestartedPods { + return &K8sListTopRestartedPods{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopRestartedPods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_restarted_pods", +func (t *K8sListTopRestartedPods) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_top_restarted_pods", mcp.WithDescription("Lists the pods with the highest number of container restarts in the specified scope (cluster, namespace, workload, or individual pod). By default, it returns the top 10."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -42,7 +42,7 @@ func (t *TroubleshootKubernetesListTopRestartedPods) RegisterInServer(s *server. s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListTopRestartedPods) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListTopRestartedPods) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") workloadType := mcp.ParseString(request, "workload_type", "") diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_restarted_pods_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods_test.go similarity index 79% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_restarted_pods_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods_test.go index 57682bd..1043c45 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_restarted_pods_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListTopRestartedPods Tool", func() { +var _ = Describe("KubernetesListTopRestartedPods Tool", func() { var ( - tool *tools.TroubleshootKubernetesListTopRestartedPods + tool *tools.K8sListTopRestartedPods mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("TroubleshootKubernetesListTopRestartedPods Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListTopRestartedPods(mockSysdig) + tool = tools.NewK8sListTopRestartedPods(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_top_restarted_pods")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_top_restarted_pods")).NotTo(BeNil()) }) When("listing top restarted pods", func() { @@ -52,10 +52,10 @@ var _ = Describe("TroubleshootKubernetesListTopRestartedPods Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "troubleshoot_kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "k8s_list_top_restarted_pods", Arguments: map[string]any{}, }, }, @@ -64,10 +64,10 @@ var _ = Describe("TroubleshootKubernetesListTopRestartedPods Tool", func() { }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "k8s_list_top_restarted_pods", Arguments: map[string]any{"limit": "20"}, }, }, @@ -76,10 +76,10 @@ var _ = Describe("TroubleshootKubernetesListTopRestartedPods Tool", func() { }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "k8s_list_top_restarted_pods", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -88,10 +88,10 @@ var _ = Describe("TroubleshootKubernetesListTopRestartedPods Tool", func() { }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "k8s_list_top_restarted_pods", Arguments: map[string]any{"namespace_name": "my_namespace"}, }, }, @@ -100,10 +100,10 @@ var _ = Describe("TroubleshootKubernetesListTopRestartedPods Tool", func() { }, ), Entry(nil, - "troubleshoot_kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "k8s_list_top_restarted_pods", Arguments: map[string]any{ "cluster_name": "my_cluster", "namespace_name": "my_namespace", diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_unavailable_pods.go b/internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods.go similarity index 86% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_unavailable_pods.go rename to internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods.go index 949879b..41feb87 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_unavailable_pods.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopUnavailablePods struct { +type K8sListTopUnavailablePods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopUnavailablePods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopUnavailablePods { - return &TroubleshootKubernetesListTopUnavailablePods{ +func NewK8sListTopUnavailablePods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopUnavailablePods { + return &K8sListTopUnavailablePods{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopUnavailablePods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_unavailable_pods", +func (t *K8sListTopUnavailablePods) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_top_unavailable_pods", mcp.WithDescription("Shows the top N pods with the highest number of unavailable or unready replicas in a Kubernetes cluster, ordered from highest to lowest."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -41,7 +41,7 @@ func (t *TroubleshootKubernetesListTopUnavailablePods) RegisterInServer(s *serve s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListTopUnavailablePods) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListTopUnavailablePods) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") workloadType := mcp.ParseString(request, "workload_type", "") diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_unavailable_pods_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods_test.go similarity index 86% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_unavailable_pods_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods_test.go index 22c039f..297a064 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_unavailable_pods_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListTopUnavailablePods Tool", func() { +var _ = Describe("KubernetesListTopUnavailablePods Tool", func() { var ( - tool *tools.TroubleshootKubernetesListTopUnavailablePods + tool *tools.K8sListTopUnavailablePods mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("TroubleshootKubernetesListTopUnavailablePods Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListTopUnavailablePods(mockSysdig) + tool = tools.NewK8sListTopUnavailablePods(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_top_unavailable_pods")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_top_unavailable_pods")).NotTo(BeNil()) }) When("querying top unavailable pods", func() { @@ -52,10 +52,10 @@ var _ = Describe("TroubleshootKubernetesListTopUnavailablePods Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry("default params", - "troubleshoot_kubernetes_list_top_unavailable_pods", + "k8s_list_top_unavailable_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_unavailable_pods", + Name: "k8s_list_top_unavailable_pods", Arguments: map[string]any{}, }, }, @@ -83,10 +83,10 @@ var _ = Describe("TroubleshootKubernetesListTopUnavailablePods Tool", func() { }, ), Entry("with specific limit and cluster", - "troubleshoot_kubernetes_list_top_unavailable_pods", + "k8s_list_top_unavailable_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_unavailable_pods", + Name: "k8s_list_top_unavailable_pods", Arguments: map[string]any{ "limit": 5, "cluster_name": "my-cluster", @@ -117,10 +117,10 @@ var _ = Describe("TroubleshootKubernetesListTopUnavailablePods Tool", func() { }, ), Entry("with all filters", - "troubleshoot_kubernetes_list_top_unavailable_pods", + "k8s_list_top_unavailable_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_unavailable_pods", + Name: "k8s_list_top_unavailable_pods", Arguments: map[string]any{ "limit": 10, "cluster_name": "my-cluster", diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota.go b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota.go similarity index 80% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota.go rename to internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota.go index f572f3a..4525c3d 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota.go +++ b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListUnderutilizedPodsByCPUQuota struct { +type K8sListUnderutilizedPodsCPUQuota struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListUnderutilizedPodsByCPUQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListUnderutilizedPodsByCPUQuota { - return &TroubleshootKubernetesListUnderutilizedPodsByCPUQuota{ +func NewK8sListUnderutilizedPodsCPUQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListUnderutilizedPodsCPUQuota { + return &K8sListUnderutilizedPodsCPUQuota{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListUnderutilizedPodsByCPUQuota) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", +func (t *K8sListUnderutilizedPodsCPUQuota) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_underutilized_pods_cpu_quota", mcp.WithDescription("List Kubernetes pods with CPU usage below 25% of the quota limit."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -39,7 +39,7 @@ func (t *TroubleshootKubernetesListUnderutilizedPodsByCPUQuota) RegisterInServer s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListUnderutilizedPodsByCPUQuota) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListUnderutilizedPodsCPUQuota) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") limit := mcp.ParseInt(request, "limit", 10) diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota_test.go b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota_test.go similarity index 79% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota_test.go rename to internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota_test.go index f40a5c0..2e1956e 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByCPUQuota Tool", func() { +var _ = Describe("KubernetesListUnderutilizedPodsCPUQuota Tool", func() { var ( - tool *tools.TroubleshootKubernetesListUnderutilizedPodsByCPUQuota + tool *tools.K8sListUnderutilizedPodsCPUQuota mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByCPUQuota Tool", f BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListUnderutilizedPodsByCPUQuota(mockSysdig) + tool = tools.NewK8sListUnderutilizedPodsCPUQuota(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_underutilized_pods_cpu_quota")).NotTo(BeNil()) }) When("listing underutilized pods", func() { @@ -52,10 +52,10 @@ var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByCPUQuota Tool", f Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "k8s_list_underutilized_pods_cpu_quota", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByCPUQuota Tool", f }, ), Entry(nil, - "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "k8s_list_underutilized_pods_cpu_quota", Arguments: map[string]any{"limit": "20"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByCPUQuota Tool", f }, ), Entry(nil, - "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "k8s_list_underutilized_pods_cpu_quota", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByCPUQuota Tool", f }, ), Entry(nil, - "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "k8s_list_underutilized_pods_cpu_quota", Arguments: map[string]any{"namespace_name": "my_namespace"}, }, }, @@ -104,10 +104,10 @@ var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByCPUQuota Tool", f }, ), Entry(nil, - "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "k8s_list_underutilized_pods_cpu_quota", Arguments: map[string]any{"cluster_name": "my_cluster", "namespace_name": "my_namespace"}, }, }, diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota.go b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota.go similarity index 79% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota.go rename to internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota.go index 7f59ad8..bfd2251 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota.go +++ b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota struct { +type K8sListUnderutilizedPodsMemoryQuota struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListUnderutilizedPodsByMemoryQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota { - return &TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota{ +func NewK8sListUnderutilizedPodsMemoryQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListUnderutilizedPodsMemoryQuota { + return &K8sListUnderutilizedPodsMemoryQuota{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota", +func (t *K8sListUnderutilizedPodsMemoryQuota) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_underutilized_pods_memory_quota", mcp.WithDescription("List Kubernetes pods with memory usage below 25% of the limit."), mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")), mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")), @@ -39,7 +39,7 @@ func (t *TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota) RegisterInSer s.AddTool(tool, t.handle) } -func (t *TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListUnderutilizedPodsMemoryQuota) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") limit := mcp.ParseInt(request, "limit", 10) diff --git a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota_test.go b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota_test.go similarity index 80% rename from internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota_test.go rename to internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota_test.go index f87c14b..542f8a9 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota_test.go @@ -16,9 +16,9 @@ import ( "go.uber.org/mock/gomock" ) -var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota Tool", func() { +var _ = Describe("KubernetesListUnderutilizedPodsMemoryQuota Tool", func() { var ( - tool *tools.TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota + tool *tools.K8sListUnderutilizedPodsMemoryQuota mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota Tool" BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewTroubleshootKubernetesListUnderutilizedPodsByMemoryQuota(mockSysdig) + tool = tools.NewK8sListUnderutilizedPodsMemoryQuota(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_underutilized_pods_memory_quota")).NotTo(BeNil()) }) When("listing underutilized pods", func() { @@ -52,10 +52,10 @@ var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota Tool" Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota", + "k8s_list_underutilized_pods_memory_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota", + Name: "k8s_list_underutilized_pods_memory_quota", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota Tool" }, ), Entry(nil, - "troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota", + "k8s_list_underutilized_pods_memory_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota", + Name: "k8s_list_underutilized_pods_memory_quota", Arguments: map[string]any{ "cluster_name": "test-cluster", "namespace_name": "test-namespace", diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_workloads.go b/internal/infra/mcp/tools/tool_k8s_list_workloads.go similarity index 88% rename from internal/infra/mcp/tools/tool_kubernetes_list_workloads.go rename to internal/infra/mcp/tools/tool_k8s_list_workloads.go index 2f9d2be..0d3b9a5 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_workloads.go +++ b/internal/infra/mcp/tools/tool_k8s_list_workloads.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type KubernetesListWorkloads struct { +type K8sListWorkloads struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListWorkloads(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListWorkloads { - return &KubernetesListWorkloads{ +func NewK8sListWorkloads(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListWorkloads { + return &K8sListWorkloads{ SysdigClient: sysdigClient, } } -func (t *KubernetesListWorkloads) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_workloads", +func (t *K8sListWorkloads) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("k8s_list_workloads", mcp.WithDescription("Lists all the workloads that are in a particular state, desired, ready, running or unavailable. The LLM can filter by cluster, namespace, workload name or type."), mcp.WithString("status", mcp.Description("The status of the workload."), @@ -49,7 +49,7 @@ func (t *KubernetesListWorkloads) RegisterInServer(s *server.MCPServer) { s.AddTool(tool, t.handle) } -func (t *KubernetesListWorkloads) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { +func (t *K8sListWorkloads) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { status := mcp.ParseString(request, "status", "") clusterName := mcp.ParseString(request, "cluster_name", "") namespaceName := mcp.ParseString(request, "namespace_name", "") diff --git a/internal/infra/mcp/tools/tool_kubernetes_list_workloads_test.go b/internal/infra/mcp/tools/tool_k8s_list_workloads_test.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_workloads_test.go rename to internal/infra/mcp/tools/tool_k8s_list_workloads_test.go index db7f62b..c8d27af 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_workloads_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_workloads_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListWorkloads Tool", func() { var ( - tool *tools.KubernetesListWorkloads + tool *tools.K8sListWorkloads mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListWorkloads Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListWorkloads(mockSysdig) + tool = tools.NewK8sListWorkloads(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_workloads")).NotTo(BeNil()) + Expect(mcpServer.GetTool("k8s_list_workloads")).NotTo(BeNil()) }) When("listing workloads", func() { @@ -52,10 +52,10 @@ var _ = Describe("KubernetesListWorkloads Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_workloads", + "k8s_list_workloads", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_workloads", + Name: "k8s_list_workloads", Arguments: map[string]any{"status": "desired"}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListWorkloads Tool", func() { }, ), Entry(nil, - "kubernetes_list_workloads", + "k8s_list_workloads", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_workloads", + Name: "k8s_list_workloads", Arguments: map[string]any{"status": "ready", "limit": "20"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("KubernetesListWorkloads Tool", func() { }, ), Entry(nil, - "kubernetes_list_workloads", + "k8s_list_workloads", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_workloads", + Name: "k8s_list_workloads", Arguments: map[string]any{"status": "running", "cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("KubernetesListWorkloads Tool", func() { }, ), Entry(nil, - "kubernetes_list_workloads", + "k8s_list_workloads", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_workloads", + Name: "k8s_list_workloads", Arguments: map[string]any{"status": "unavailable", "namespace_name": "my_namespace"}, }, }, @@ -104,10 +104,10 @@ var _ = Describe("KubernetesListWorkloads Tool", func() { }, ), Entry(nil, - "kubernetes_list_workloads", + "k8s_list_workloads", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_workloads", + Name: "k8s_list_workloads", Arguments: map[string]any{"status": "desired", "workload_name": "my_workload"}, }, }, @@ -117,10 +117,10 @@ var _ = Describe("KubernetesListWorkloads Tool", func() { }, ), Entry(nil, - "kubernetes_list_workloads", + "k8s_list_workloads", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_workloads", + Name: "k8s_list_workloads", Arguments: map[string]any{"status": "ready", "workload_type": "deployment"}, }, }, @@ -130,10 +130,10 @@ var _ = Describe("KubernetesListWorkloads Tool", func() { }, ), Entry(nil, - "kubernetes_list_workloads", + "k8s_list_workloads", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_workloads", + Name: "k8s_list_workloads", Arguments: map[string]any{ "status": "running", "cluster_name": "my_cluster",