From cce33d8c3bbe91316090a390561ec17775c39530 Mon Sep 17 00:00:00 2001 From: Fede Barcelona Date: Tue, 2 Dec 2025 12:48:31 +0100 Subject: [PATCH 1/2] refactor: rename and simplify kubernetes troubleshooting tools Rename 'troubleshoot_kubernetes_' tools to 'kubernetes_' and simplify names by removing '_by_' infix and shortening '400_500_http_errors' to 'http_errors'. This improves readability and usability of the MCP tools. --- README.md | 22 +++++++-------- cmd/server/main.go | 22 +++++++-------- internal/infra/mcp/tools/README.md | 22 +++++++-------- ...kubernetes_list_count_pods_per_cluster.go} | 12 ++++---- ...netes_list_count_pods_per_cluster_test.go} | 28 +++++++++---------- ...rnetes_list_top_cpu_consumed_container.go} | 12 ++++---- ...s_list_top_cpu_consumed_container_test.go} | 16 +++++------ ...ernetes_list_top_cpu_consumed_workload.go} | 12 ++++---- ...es_list_top_cpu_consumed_workload_test.go} | 20 ++++++------- ...ubernetes_list_top_http_errors_in_pods.go} | 12 ++++---- ...etes_list_top_http_errors_in_pods_test.go} | 24 ++++++++-------- ...tes_list_top_memory_consumed_container.go} | 12 ++++---- ...ist_top_memory_consumed_container_test.go} | 20 ++++++------- ...etes_list_top_memory_consumed_workload.go} | 12 ++++---- ...list_top_memory_consumed_workload_test.go} | 28 +++++++++---------- ...rnetes_list_top_network_errors_in_pods.go} | 12 ++++---- ...s_list_top_network_errors_in_pods_test.go} | 28 +++++++++---------- ...ool_kubernetes_list_top_restarted_pods.go} | 12 ++++---- ...ubernetes_list_top_restarted_pods_test.go} | 28 +++++++++---------- ...l_kubernetes_list_top_unavailable_pods.go} | 12 ++++---- ...ernetes_list_top_unavailable_pods_test.go} | 20 ++++++------- ...etes_list_underutilized_pods_cpu_quota.go} | 12 ++++---- ...list_underutilized_pods_cpu_quota_test.go} | 28 +++++++++---------- ...s_list_underutilized_pods_memory_quota.go} | 12 ++++---- ...t_underutilized_pods_memory_quota_test.go} | 16 +++++------ 25 files changed, 227 insertions(+), 227 deletions(-) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_count_pods_per_cluster.go => tool_kubernetes_list_count_pods_per_cluster.go} (80%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_count_pods_per_cluster_test.go => tool_kubernetes_list_count_pods_per_cluster_test.go} (76%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container.go => tool_kubernetes_list_top_cpu_consumed_container.go} (83%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container_test.go => tool_kubernetes_list_top_cpu_consumed_container_test.go} (78%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload.go => tool_kubernetes_list_top_cpu_consumed_workload.go} (83%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload_test.go => tool_kubernetes_list_top_cpu_consumed_workload_test.go} (79%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods.go => tool_kubernetes_list_top_http_errors_in_pods.go} (86%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods_test.go => tool_kubernetes_list_top_http_errors_in_pods_test.go} (79%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container.go => tool_kubernetes_list_top_memory_consumed_container.go} (82%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container_test.go => tool_kubernetes_list_top_memory_consumed_container_test.go} (80%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload.go => tool_kubernetes_list_top_memory_consumed_workload.go} (83%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload_test.go => tool_kubernetes_list_top_memory_consumed_workload_test.go} (78%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_network_errors_in_pods.go => tool_kubernetes_list_top_network_errors_in_pods.go} (85%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_network_errors_in_pods_test.go => tool_kubernetes_list_top_network_errors_in_pods_test.go} (80%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_restarted_pods.go => tool_kubernetes_list_top_restarted_pods.go} (85%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_restarted_pods_test.go => tool_kubernetes_list_top_restarted_pods_test.go} (79%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_unavailable_pods.go => tool_kubernetes_list_top_unavailable_pods.go} (86%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_top_unavailable_pods_test.go => tool_kubernetes_list_top_unavailable_pods_test.go} (86%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota.go => tool_kubernetes_list_underutilized_pods_cpu_quota.go} (80%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota_test.go => tool_kubernetes_list_underutilized_pods_cpu_quota_test.go} (79%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota.go => tool_kubernetes_list_underutilized_pods_memory_quota.go} (79%) rename internal/infra/mcp/tools/{tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota_test.go => tool_kubernetes_list_underutilized_pods_memory_quota_test.go} (80%) diff --git a/README.md b/README.md index b710f4a..057549d 100644 --- a/README.md +++ b/README.md @@ -133,57 +133,57 @@ The server dynamically filters the available tools based on the permissions asso - **Required Permission**: `metrics-data.read` - **Sample Prompt**: "List all cronjobs in cluster 'prod' and namespace 'default'" -- **`troubleshoot_kubernetes_list_top_unavailable_pods`** +- **`kubernetes_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`** +- **`kubernetes_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`** +- **`kubernetes_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`** +- **`kubernetes_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`** +- **`kubernetes_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`** +- **`kubernetes_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`** +- **`kubernetes_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`** +- **`kubernetes_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`** +- **`kubernetes_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`** +- **`kubernetes_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`** +- **`kubernetes_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..3ad5a13 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -100,17 +100,17 @@ func setupHandler(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *mcp 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.NewKubernetesListTopUnavailablePods(sysdigClient), + tools.NewKubernetesListTopRestartedPods(sysdigClient), + tools.NewKubernetesListTopHttpErrorsInPods(sysdigClient), + tools.NewKubernetesListTopNetworkErrorsInPods(sysdigClient), + tools.NewKubernetesListCountPodsPerCluster(sysdigClient), + tools.NewKubernetesListUnderutilizedPodsCPUQuota(sysdigClient), + tools.NewKubernetesListTopCPUConsumedWorkload(sysdigClient), + tools.NewKubernetesListTopCPUConsumedContainer(sysdigClient), + tools.NewKubernetesListUnderutilizedPodsMemoryQuota(sysdigClient), + tools.NewKubernetesListTopMemoryConsumedWorkload(sysdigClient), + tools.NewKubernetesListTopMemoryConsumedContainer(sysdigClient), ) return handler } diff --git a/internal/infra/mcp/tools/README.md b/internal/infra/mcp/tools/README.md index 61d8879..fbd5b6f 100644 --- a/internal/infra/mcp/tools/README.md +++ b/internal/infra/mcp/tools/README.md @@ -14,17 +14,17 @@ The handler filters tools dynamically based on the Sysdig user's permissions. Ea | `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'" | | `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'" | +| `kubernetes_list_count_pods_per_cluster` | `tool_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'" | +| `kubernetes_list_top_http_errors_in_pods` | `tool_kubernetes_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'" | +| `kubernetes_list_top_cpu_consumed_container` | `tool_kubernetes_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'" | +| `kubernetes_list_top_cpu_consumed_workload` | `tool_kubernetes_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'" | +| `kubernetes_list_top_memory_consumed_container` | `tool_kubernetes_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'" | +| `kubernetes_list_top_memory_consumed_workload` | `tool_kubernetes_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'" | +| `kubernetes_list_top_network_errors_in_pods` | `tool_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'" | +| `kubernetes_list_top_restarted_pods` | `tool_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'" | +| `kubernetes_list_top_unavailable_pods` | `tool_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'" | +| `kubernetes_list_underutilized_pods_cpu_quota` | `tool_kubernetes_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'" | +| `kubernetes_list_underutilized_pods_memory_quota` | `tool_kubernetes_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_troubleshoot_kubernetes_list_count_pods_per_cluster.go b/internal/infra/mcp/tools/tool_kubernetes_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_kubernetes_list_count_pods_per_cluster.go index 03d254d..b57a53a 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster.go +++ b/internal/infra/mcp/tools/tool_kubernetes_list_count_pods_per_cluster.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListCountPodsPerCluster struct { +type KubernetesListCountPodsPerCluster struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListCountPodsPerCluster(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListCountPodsPerCluster { - return &TroubleshootKubernetesListCountPodsPerCluster{ +func NewKubernetesListCountPodsPerCluster(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListCountPodsPerCluster { + return &KubernetesListCountPodsPerCluster{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListCountPodsPerCluster) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_count_pods_per_cluster", +func (t *KubernetesListCountPodsPerCluster) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListCountPodsPerCluster) 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_kubernetes_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_kubernetes_list_count_pods_per_cluster_test.go index f5be1f0..b998309 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListCountPodsPerCluster 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.NewKubernetesListCountPodsPerCluster(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("kubernetes_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", + "kubernetes_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "kubernetes_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", + "kubernetes_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "kubernetes_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", + "kubernetes_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "kubernetes_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", + "kubernetes_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "kubernetes_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", + "kubernetes_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_count_pods_per_cluster", + Name: "kubernetes_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_troubleshoot_kubernetes_list_top_cpu_consumed_by_container.go b/internal/infra/mcp/tools/tool_kubernetes_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_kubernetes_list_top_cpu_consumed_container.go index d27415c..1b89220 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container.go +++ b/internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_container.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopCPUConsumedByContainer struct { +type KubernetesListTopCPUConsumedContainer struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopCPUConsumedByContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopCPUConsumedByContainer { - return &TroubleshootKubernetesListTopCPUConsumedByContainer{ +func NewKubernetesListTopCPUConsumedContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopCPUConsumedContainer { + return &KubernetesListTopCPUConsumedContainer{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopCPUConsumedByContainer) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_cpu_consumed_by_container", +func (t *KubernetesListTopCPUConsumedContainer) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListTopCPUConsumedContainer) 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_kubernetes_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_kubernetes_list_top_cpu_consumed_container_test.go index 6fbaf8d..34c4c58 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListTopCPUConsumedContainer 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.NewKubernetesListTopCPUConsumedContainer(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("kubernetes_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(), "kubernetes_list_top_cpu_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_container", + Name: "kubernetes_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(), "kubernetes_list_top_cpu_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_container", + Name: "kubernetes_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_kubernetes_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_kubernetes_list_top_cpu_consumed_workload.go index 5e07810..31781e1 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload.go +++ b/internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_workload.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopCPUConsumedByWorkload struct { +type KubernetesListTopCPUConsumedWorkload struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopCPUConsumedByWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopCPUConsumedByWorkload { - return &TroubleshootKubernetesListTopCPUConsumedByWorkload{ +func NewKubernetesListTopCPUConsumedWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopCPUConsumedWorkload { + return &KubernetesListTopCPUConsumedWorkload{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopCPUConsumedByWorkload) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", +func (t *KubernetesListTopCPUConsumedWorkload) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListTopCPUConsumedWorkload) 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_kubernetes_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_kubernetes_list_top_cpu_consumed_workload_test.go index f93f388..6c4f122 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_workload_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListTopCPUConsumedWorkload 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.NewKubernetesListTopCPUConsumedWorkload(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("kubernetes_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", + "kubernetes_list_top_cpu_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", + Name: "kubernetes_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", + "kubernetes_list_top_cpu_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", + Name: "kubernetes_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", + "kubernetes_list_top_cpu_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_cpu_consumed_by_workload", + Name: "kubernetes_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_kubernetes_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_kubernetes_list_top_http_errors_in_pods.go index 4729e10..d842e57 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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 KubernetesListTopHttpErrorsInPods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTop400500HttpErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTop400500HttpErrorsInPods { - return &TroubleshootKubernetesListTop400500HttpErrorsInPods{ +func NewKubernetesListTopHttpErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopHttpErrorsInPods { + return &KubernetesListTopHttpErrorsInPods{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTop400500HttpErrorsInPods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", +func (t *KubernetesListTopHttpErrorsInPods) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListTopHttpErrorsInPods) 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_kubernetes_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_kubernetes_list_top_http_errors_in_pods_test.go index 70d0cbe..132fe4a 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_kubernetes_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.KubernetesListTopHttpErrorsInPods 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.NewKubernetesListTopHttpErrorsInPods(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("kubernetes_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", + "kubernetes_list_top_http_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + Name: "kubernetes_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", + "kubernetes_list_top_http_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + Name: "kubernetes_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", + "kubernetes_list_top_http_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + Name: "kubernetes_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("kubernetes_list_top_http_errors_in_pods") request := mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods", + Name: "kubernetes_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_kubernetes_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_kubernetes_list_top_memory_consumed_container.go index f705a61..6b2346b 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container.go +++ b/internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_container.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopMemoryConsumedByContainer struct { +type KubernetesListTopMemoryConsumedContainer struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopMemoryConsumedByContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopMemoryConsumedByContainer { - return &TroubleshootKubernetesListTopMemoryConsumedByContainer{ +func NewKubernetesListTopMemoryConsumedContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopMemoryConsumedContainer { + return &KubernetesListTopMemoryConsumedContainer{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopMemoryConsumedByContainer) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_memory_consumed_by_container", +func (t *KubernetesListTopMemoryConsumedContainer) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListTopMemoryConsumedContainer) 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_kubernetes_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_kubernetes_list_top_memory_consumed_container_test.go index c04aff4..5952b99 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListTopMemoryConsumedContainer 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.NewKubernetesListTopMemoryConsumedContainer(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("kubernetes_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", + "kubernetes_list_top_memory_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_container", + Name: "kubernetes_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", + "kubernetes_list_top_memory_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_container", + Name: "kubernetes_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", + "kubernetes_list_top_memory_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_container", + Name: "kubernetes_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_kubernetes_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_kubernetes_list_top_memory_consumed_workload.go index 9284b77..34313e9 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload.go +++ b/internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_workload.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopMemoryConsumedByWorkload struct { +type KubernetesListTopMemoryConsumedWorkload struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopMemoryConsumedByWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopMemoryConsumedByWorkload { - return &TroubleshootKubernetesListTopMemoryConsumedByWorkload{ +func NewKubernetesListTopMemoryConsumedWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopMemoryConsumedWorkload { + return &KubernetesListTopMemoryConsumedWorkload{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopMemoryConsumedByWorkload) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_memory_consumed_by_workload", +func (t *KubernetesListTopMemoryConsumedWorkload) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListTopMemoryConsumedWorkload) 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_kubernetes_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_kubernetes_list_top_memory_consumed_workload_test.go index c3b39d9..817061b 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListTopMemoryConsumedWorkload 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.NewKubernetesListTopMemoryConsumedWorkload(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("kubernetes_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", + "kubernetes_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "kubernetes_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", + "kubernetes_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "kubernetes_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", + "kubernetes_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "kubernetes_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", + "kubernetes_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "kubernetes_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", + "kubernetes_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_memory_consumed_by_workload", + Name: "kubernetes_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_kubernetes_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_kubernetes_list_top_network_errors_in_pods.go index 7b6cb54..3d5aa38 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_network_errors_in_pods.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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 KubernetesListTopNetworkErrorsInPods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopNetworkErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopNetworkErrorsInPods { - return &TroubleshootKubernetesListTopNetworkErrorsInPods{ +func NewKubernetesListTopNetworkErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopNetworkErrorsInPods { + return &KubernetesListTopNetworkErrorsInPods{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopNetworkErrorsInPods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_network_errors_in_pods", +func (t *KubernetesListTopNetworkErrorsInPods) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListTopNetworkErrorsInPods) 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_kubernetes_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_kubernetes_list_top_network_errors_in_pods_test.go index e1d4b8d..538471d 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_network_errors_in_pods_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListTopNetworkErrorsInPods 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.NewKubernetesListTopNetworkErrorsInPods(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("kubernetes_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", + "kubernetes_list_top_network_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_network_errors_in_pods", + Name: "kubernetes_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", + "kubernetes_list_top_network_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_network_errors_in_pods", + Name: "kubernetes_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", + "kubernetes_list_top_network_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_network_errors_in_pods", + Name: "kubernetes_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("kubernetes_list_top_network_errors_in_pods") request := mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_network_errors_in_pods", + Name: "kubernetes_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: "kubernetes_list_top_network_errors_in_pods", Arguments: map[string]any{}, }, } - serverTool := mcpServer.GetTool("troubleshoot_kubernetes_list_top_network_errors_in_pods") + serverTool := mcpServer.GetTool("kubernetes_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_kubernetes_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_kubernetes_list_top_restarted_pods.go index d25d402..f298c01 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_restarted_pods.go +++ b/internal/infra/mcp/tools/tool_kubernetes_list_top_restarted_pods.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopRestartedPods struct { +type KubernetesListTopRestartedPods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopRestartedPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopRestartedPods { - return &TroubleshootKubernetesListTopRestartedPods{ +func NewKubernetesListTopRestartedPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopRestartedPods { + return &KubernetesListTopRestartedPods{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopRestartedPods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_restarted_pods", +func (t *KubernetesListTopRestartedPods) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListTopRestartedPods) 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_kubernetes_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_kubernetes_list_top_restarted_pods_test.go index 57682bd..36b288c 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_restarted_pods_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListTopRestartedPods 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.NewKubernetesListTopRestartedPods(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("kubernetes_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", + "kubernetes_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "kubernetes_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", + "kubernetes_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "kubernetes_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", + "kubernetes_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "kubernetes_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", + "kubernetes_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "kubernetes_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", + "kubernetes_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_restarted_pods", + Name: "kubernetes_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_kubernetes_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_kubernetes_list_top_unavailable_pods.go index 949879b..6d78b79 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_unavailable_pods.go +++ b/internal/infra/mcp/tools/tool_kubernetes_list_top_unavailable_pods.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListTopUnavailablePods struct { +type KubernetesListTopUnavailablePods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListTopUnavailablePods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListTopUnavailablePods { - return &TroubleshootKubernetesListTopUnavailablePods{ +func NewKubernetesListTopUnavailablePods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopUnavailablePods { + return &KubernetesListTopUnavailablePods{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListTopUnavailablePods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_top_unavailable_pods", +func (t *KubernetesListTopUnavailablePods) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListTopUnavailablePods) 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_kubernetes_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_kubernetes_list_top_unavailable_pods_test.go index 22c039f..11f8118 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_unavailable_pods_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListTopUnavailablePods 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.NewKubernetesListTopUnavailablePods(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("kubernetes_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", + "kubernetes_list_top_unavailable_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_unavailable_pods", + Name: "kubernetes_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", + "kubernetes_list_top_unavailable_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_unavailable_pods", + Name: "kubernetes_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", + "kubernetes_list_top_unavailable_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_top_unavailable_pods", + Name: "kubernetes_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_kubernetes_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_kubernetes_list_underutilized_pods_cpu_quota.go index f572f3a..92596dc 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota.go +++ b/internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_cpu_quota.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListUnderutilizedPodsByCPUQuota struct { +type KubernetesListUnderutilizedPodsCPUQuota struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListUnderutilizedPodsByCPUQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListUnderutilizedPodsByCPUQuota { - return &TroubleshootKubernetesListUnderutilizedPodsByCPUQuota{ +func NewKubernetesListUnderutilizedPodsCPUQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListUnderutilizedPodsCPUQuota { + return &KubernetesListUnderutilizedPodsCPUQuota{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListUnderutilizedPodsByCPUQuota) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", +func (t *KubernetesListUnderutilizedPodsCPUQuota) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListUnderutilizedPodsCPUQuota) 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_kubernetes_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_kubernetes_list_underutilized_pods_cpu_quota_test.go index f40a5c0..d451e4a 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListUnderutilizedPodsCPUQuota 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.NewKubernetesListUnderutilizedPodsCPUQuota(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("kubernetes_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", + "kubernetes_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "kubernetes_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", + "kubernetes_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "kubernetes_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", + "kubernetes_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "kubernetes_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", + "kubernetes_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "kubernetes_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", + "kubernetes_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota", + Name: "kubernetes_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_kubernetes_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_kubernetes_list_underutilized_pods_memory_quota.go index 7f59ad8..59a5acf 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota.go +++ b/internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_memory_quota.go @@ -12,18 +12,18 @@ import ( "github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig" ) -type TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota struct { +type KubernetesListUnderutilizedPodsMemoryQuota struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewTroubleshootKubernetesListUnderutilizedPodsByMemoryQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota { - return &TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota{ +func NewKubernetesListUnderutilizedPodsMemoryQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListUnderutilizedPodsMemoryQuota { + return &KubernetesListUnderutilizedPodsMemoryQuota{ SysdigClient: sysdigClient, } } -func (t *TroubleshootKubernetesListUnderutilizedPodsByMemoryQuota) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota", +func (t *KubernetesListUnderutilizedPodsMemoryQuota) RegisterInServer(s *server.MCPServer) { + tool := mcp.NewTool("kubernetes_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 *KubernetesListUnderutilizedPodsMemoryQuota) 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_kubernetes_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_kubernetes_list_underutilized_pods_memory_quota_test.go index f87c14b..9638191 100644 --- a/internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota_test.go +++ b/internal/infra/mcp/tools/tool_kubernetes_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.KubernetesListUnderutilizedPodsMemoryQuota 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.NewKubernetesListUnderutilizedPodsMemoryQuota(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("kubernetes_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", + "kubernetes_list_underutilized_pods_memory_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota", + Name: "kubernetes_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", + "kubernetes_list_underutilized_pods_memory_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota", + Name: "kubernetes_list_underutilized_pods_memory_quota", Arguments: map[string]any{ "cluster_name": "test-cluster", "namespace_name": "test-namespace", From 7f1b02d3da37faea34fa4a056cc98f4e0deb0a83 Mon Sep 17 00:00:00 2001 From: Fede Barcelona Date: Tue, 2 Dec 2025 12:59:51 +0100 Subject: [PATCH 2/2] refactor(tools): rename kubernetes_ tools to k8s_ --- README.md | 32 ++++++------ cmd/server/main.go | 32 ++++++------ internal/infra/mcp/tools/README.md | 32 ++++++------ ..._clusters.go => tool_k8s_list_clusters.go} | 12 ++--- ...test.go => tool_k8s_list_clusters_test.go} | 22 ++++---- ...> tool_k8s_list_count_pods_per_cluster.go} | 12 ++--- ...l_k8s_list_count_pods_per_cluster_test.go} | 26 +++++----- ..._cronjobs.go => tool_k8s_list_cronjobs.go} | 12 ++--- ...test.go => tool_k8s_list_cronjobs_test.go} | 30 +++++------ ...s_list_nodes.go => tool_k8s_list_nodes.go} | 12 ++--- ...es_test.go => tool_k8s_list_nodes_test.go} | 30 +++++------ ...ers.go => tool_k8s_list_pod_containers.go} | 12 ++--- ...o => tool_k8s_list_pod_containers_test.go} | 50 +++++++++---------- ...ol_k8s_list_top_cpu_consumed_container.go} | 12 ++--- ...s_list_top_cpu_consumed_container_test.go} | 14 +++--- ...ool_k8s_list_top_cpu_consumed_workload.go} | 12 ++--- ...8s_list_top_cpu_consumed_workload_test.go} | 18 +++---- ... tool_k8s_list_top_http_errors_in_pods.go} | 12 ++--- ..._k8s_list_top_http_errors_in_pods_test.go} | 22 ++++---- ...k8s_list_top_memory_consumed_container.go} | 12 ++--- ...ist_top_memory_consumed_container_test.go} | 18 +++---- ..._k8s_list_top_memory_consumed_workload.go} | 12 ++--- ...list_top_memory_consumed_workload_test.go} | 26 +++++----- ...ol_k8s_list_top_network_errors_in_pods.go} | 12 ++--- ...s_list_top_network_errors_in_pods_test.go} | 26 +++++----- ...go => tool_k8s_list_top_restarted_pods.go} | 12 ++--- ... tool_k8s_list_top_restarted_pods_test.go} | 26 +++++----- ... => tool_k8s_list_top_unavailable_pods.go} | 12 ++--- ...ool_k8s_list_top_unavailable_pods_test.go} | 18 +++---- ..._k8s_list_underutilized_pods_cpu_quota.go} | 12 ++--- ...list_underutilized_pods_cpu_quota_test.go} | 26 +++++----- ...s_list_underutilized_pods_memory_quota.go} | 12 ++--- ...t_underutilized_pods_memory_quota_test.go} | 14 +++--- ...orkloads.go => tool_k8s_list_workloads.go} | 12 ++--- ...est.go => tool_k8s_list_workloads_test.go} | 34 ++++++------- 35 files changed, 344 insertions(+), 344 deletions(-) rename internal/infra/mcp/tools/{tool_kubernetes_list_clusters.go => tool_k8s_list_clusters.go} (80%) rename internal/infra/mcp/tools/{tool_kubernetes_list_clusters_test.go => tool_k8s_list_clusters_test.go} (85%) rename internal/infra/mcp/tools/{tool_kubernetes_list_count_pods_per_cluster.go => tool_k8s_list_count_pods_per_cluster.go} (82%) rename internal/infra/mcp/tools/{tool_kubernetes_list_count_pods_per_cluster_test.go => tool_k8s_list_count_pods_per_cluster_test.go} (82%) rename internal/infra/mcp/tools/{tool_kubernetes_list_cronjobs.go => tool_k8s_list_cronjobs.go} (86%) rename internal/infra/mcp/tools/{tool_kubernetes_list_cronjobs_test.go => tool_k8s_list_cronjobs_test.go} (84%) rename internal/infra/mcp/tools/{tool_kubernetes_list_nodes.go => tool_k8s_list_nodes.go} (85%) rename internal/infra/mcp/tools/{tool_kubernetes_list_nodes_test.go => tool_k8s_list_nodes_test.go} (84%) rename internal/infra/mcp/tools/{tool_kubernetes_list_pod_containers.go => tool_k8s_list_pod_containers.go} (89%) rename internal/infra/mcp/tools/{tool_kubernetes_list_pod_containers_test.go => tool_k8s_list_pod_containers_test.go} (82%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_cpu_consumed_container.go => tool_k8s_list_top_cpu_consumed_container.go} (85%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_cpu_consumed_container_test.go => tool_k8s_list_top_cpu_consumed_container_test.go} (83%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_cpu_consumed_workload.go => tool_k8s_list_top_cpu_consumed_workload.go} (85%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_cpu_consumed_workload_test.go => tool_k8s_list_top_cpu_consumed_workload_test.go} (84%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_http_errors_in_pods.go => tool_k8s_list_top_http_errors_in_pods.go} (88%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_http_errors_in_pods_test.go => tool_k8s_list_top_http_errors_in_pods_test.go} (85%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_memory_consumed_container.go => tool_k8s_list_top_memory_consumed_container.go} (85%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_memory_consumed_container_test.go => tool_k8s_list_top_memory_consumed_container_test.go} (85%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_memory_consumed_workload.go => tool_k8s_list_top_memory_consumed_workload.go} (85%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_memory_consumed_workload_test.go => tool_k8s_list_top_memory_consumed_workload_test.go} (83%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_network_errors_in_pods.go => tool_k8s_list_top_network_errors_in_pods.go} (87%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_network_errors_in_pods_test.go => tool_k8s_list_top_network_errors_in_pods_test.go} (84%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_restarted_pods.go => tool_k8s_list_top_restarted_pods.go} (87%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_restarted_pods_test.go => tool_k8s_list_top_restarted_pods_test.go} (84%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_unavailable_pods.go => tool_k8s_list_top_unavailable_pods.go} (88%) rename internal/infra/mcp/tools/{tool_kubernetes_list_top_unavailable_pods_test.go => tool_k8s_list_top_unavailable_pods_test.go} (89%) rename internal/infra/mcp/tools/{tool_kubernetes_list_underutilized_pods_cpu_quota.go => tool_k8s_list_underutilized_pods_cpu_quota.go} (82%) rename internal/infra/mcp/tools/{tool_kubernetes_list_underutilized_pods_cpu_quota_test.go => tool_k8s_list_underutilized_pods_cpu_quota_test.go} (83%) rename internal/infra/mcp/tools/{tool_kubernetes_list_underutilized_pods_memory_quota.go => tool_k8s_list_underutilized_pods_memory_quota.go} (82%) rename internal/infra/mcp/tools/{tool_kubernetes_list_underutilized_pods_memory_quota_test.go => tool_k8s_list_underutilized_pods_memory_quota_test.go} (85%) rename internal/infra/mcp/tools/{tool_kubernetes_list_workloads.go => tool_k8s_list_workloads.go} (88%) rename internal/infra/mcp/tools/{tool_kubernetes_list_workloads_test.go => tool_k8s_list_workloads_test.go} (85%) diff --git a/README.md b/README.md index 057549d..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'" -- **`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'" -- **`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'" -- **`kubernetes_list_top_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'" -- **`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'" -- **`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'" -- **`kubernetes_list_underutilized_pods_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'" -- **`kubernetes_list_underutilized_pods_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'" -- **`kubernetes_list_top_cpu_consumed_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'" -- **`kubernetes_list_top_cpu_consumed_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'" -- **`kubernetes_list_top_memory_consumed_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'" -- **`kubernetes_list_top_memory_consumed_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 3ad5a13..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.NewKubernetesListTopUnavailablePods(sysdigClient), - tools.NewKubernetesListTopRestartedPods(sysdigClient), - tools.NewKubernetesListTopHttpErrorsInPods(sysdigClient), - tools.NewKubernetesListTopNetworkErrorsInPods(sysdigClient), - tools.NewKubernetesListCountPodsPerCluster(sysdigClient), - tools.NewKubernetesListUnderutilizedPodsCPUQuota(sysdigClient), - tools.NewKubernetesListTopCPUConsumedWorkload(sysdigClient), - tools.NewKubernetesListTopCPUConsumedContainer(sysdigClient), - tools.NewKubernetesListUnderutilizedPodsMemoryQuota(sysdigClient), - tools.NewKubernetesListTopMemoryConsumedWorkload(sysdigClient), - tools.NewKubernetesListTopMemoryConsumedContainer(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 fbd5b6f..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…”. | -| `kubernetes_list_count_pods_per_cluster` | `tool_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'" | -| `kubernetes_list_top_http_errors_in_pods` | `tool_kubernetes_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'" | -| `kubernetes_list_top_cpu_consumed_container` | `tool_kubernetes_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'" | -| `kubernetes_list_top_cpu_consumed_workload` | `tool_kubernetes_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'" | -| `kubernetes_list_top_memory_consumed_container` | `tool_kubernetes_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'" | -| `kubernetes_list_top_memory_consumed_workload` | `tool_kubernetes_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'" | -| `kubernetes_list_top_network_errors_in_pods` | `tool_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'" | -| `kubernetes_list_top_restarted_pods` | `tool_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'" | -| `kubernetes_list_top_unavailable_pods` | `tool_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'" | -| `kubernetes_list_underutilized_pods_cpu_quota` | `tool_kubernetes_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'" | -| `kubernetes_list_underutilized_pods_memory_quota` | `tool_kubernetes_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'" | +| `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_kubernetes_list_count_pods_per_cluster.go b/internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster.go similarity index 82% rename from internal/infra/mcp/tools/tool_kubernetes_list_count_pods_per_cluster.go rename to internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster.go index b57a53a..3ec4ab0 100644 --- a/internal/infra/mcp/tools/tool_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 KubernetesListCountPodsPerCluster struct { +type K8sListCountPodsPerCluster struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListCountPodsPerCluster(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListCountPodsPerCluster { - return &KubernetesListCountPodsPerCluster{ +func NewK8sListCountPodsPerCluster(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListCountPodsPerCluster { + return &K8sListCountPodsPerCluster{ SysdigClient: sysdigClient, } } -func (t *KubernetesListCountPodsPerCluster) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("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 *KubernetesListCountPodsPerCluster) RegisterInServer(s *server.MCPServer s.AddTool(tool, t.handle) } -func (t *KubernetesListCountPodsPerCluster) 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_kubernetes_list_count_pods_per_cluster_test.go b/internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster_test.go similarity index 82% rename from internal/infra/mcp/tools/tool_kubernetes_list_count_pods_per_cluster_test.go rename to internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster_test.go index b998309..9306984 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_count_pods_per_cluster_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_count_pods_per_cluster_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListCountPodsPerCluster Tool", func() { var ( - tool *tools.KubernetesListCountPodsPerCluster + tool *tools.K8sListCountPodsPerCluster mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListCountPodsPerCluster Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListCountPodsPerCluster(mockSysdig) + tool = tools.NewK8sListCountPodsPerCluster(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("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("KubernetesListCountPodsPerCluster Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_count_pods_per_cluster", + Name: "k8s_list_count_pods_per_cluster", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListCountPodsPerCluster Tool", func() { }, ), Entry(nil, - "kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListCountPodsPerCluster Tool", func() { }, ), Entry(nil, - "kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListCountPodsPerCluster Tool", func() { }, ), Entry(nil, - "kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListCountPodsPerCluster Tool", func() { }, ), Entry(nil, - "kubernetes_list_count_pods_per_cluster", + "k8s_list_count_pods_per_cluster", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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_kubernetes_list_top_cpu_consumed_container.go b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_container.go rename to internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container.go index 1b89220..da42d23 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_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 KubernetesListTopCPUConsumedContainer struct { +type K8sListTopCPUConsumedContainer struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListTopCPUConsumedContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopCPUConsumedContainer { - return &KubernetesListTopCPUConsumedContainer{ +func NewK8sListTopCPUConsumedContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopCPUConsumedContainer { + return &K8sListTopCPUConsumedContainer{ SysdigClient: sysdigClient, } } -func (t *KubernetesListTopCPUConsumedContainer) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_top_cpu_consumed_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 *KubernetesListTopCPUConsumedContainer) RegisterInServer(s *server.MCPSe s.AddTool(tool, t.handle) } -func (t *KubernetesListTopCPUConsumedContainer) 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_kubernetes_list_top_cpu_consumed_container_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container_test.go similarity index 83% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_container_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container_test.go index 34c4c58..04ada33 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_container_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_container_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListTopCPUConsumedContainer Tool", func() { var ( - tool *tools.KubernetesListTopCPUConsumedContainer + tool *tools.K8sListTopCPUConsumedContainer mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListTopCPUConsumedContainer Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListTopCPUConsumedContainer(mockSysdig) + tool = tools.NewK8sListTopCPUConsumedContainer(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_top_cpu_consumed_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("KubernetesListTopCPUConsumedContainer Tool", func() { Expect(ok).To(BeTrue()) Expect(resultData.Text).To(ContainSubstring(`"status":"success"`)) }, - Entry("with no params", context.Background(), "kubernetes_list_top_cpu_consumed_container", + Entry("with no params", context.Background(), "k8s_list_top_cpu_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_cpu_consumed_container", + Name: "k8s_list_top_cpu_consumed_container", Arguments: map[string]any{}, }, }, @@ -62,10 +62,10 @@ var _ = Describe("KubernetesListTopCPUConsumedContainer Tool", func() { 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(), "kubernetes_list_top_cpu_consumed_container", + Entry("with all params", context.Background(), "k8s_list_top_cpu_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_cpu_consumed_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_kubernetes_list_top_cpu_consumed_workload.go b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_workload.go rename to internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload.go index 31781e1..99c03ca 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_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 KubernetesListTopCPUConsumedWorkload struct { +type K8sListTopCPUConsumedWorkload struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListTopCPUConsumedWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopCPUConsumedWorkload { - return &KubernetesListTopCPUConsumedWorkload{ +func NewK8sListTopCPUConsumedWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopCPUConsumedWorkload { + return &K8sListTopCPUConsumedWorkload{ SysdigClient: sysdigClient, } } -func (t *KubernetesListTopCPUConsumedWorkload) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_top_cpu_consumed_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 *KubernetesListTopCPUConsumedWorkload) RegisterInServer(s *server.MCPSer s.AddTool(tool, t.handle) } -func (t *KubernetesListTopCPUConsumedWorkload) 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_kubernetes_list_top_cpu_consumed_workload_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload_test.go similarity index 84% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_workload_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload_test.go index 6c4f122..a1e4082 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_cpu_consumed_workload_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_cpu_consumed_workload_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListTopCPUConsumedWorkload Tool", func() { var ( - tool *tools.KubernetesListTopCPUConsumedWorkload + tool *tools.K8sListTopCPUConsumedWorkload mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListTopCPUConsumedWorkload Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListTopCPUConsumedWorkload(mockSysdig) + tool = tools.NewK8sListTopCPUConsumedWorkload(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_top_cpu_consumed_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("KubernetesListTopCPUConsumedWorkload Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_top_cpu_consumed_workload", + "k8s_list_top_cpu_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_cpu_consumed_workload", + Name: "k8s_list_top_cpu_consumed_workload", Arguments: map[string]any{}, }, }, @@ -64,10 +64,10 @@ var _ = Describe("KubernetesListTopCPUConsumedWorkload Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_cpu_consumed_workload", + "k8s_list_top_cpu_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_cpu_consumed_workload", + Name: "k8s_list_top_cpu_consumed_workload", Arguments: map[string]any{ "cluster_name": "prod", "namespace_name": "default", @@ -80,10 +80,10 @@ var _ = Describe("KubernetesListTopCPUConsumedWorkload Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_cpu_consumed_workload", + "k8s_list_top_cpu_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_cpu_consumed_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_kubernetes_list_top_http_errors_in_pods.go b/internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods.go similarity index 88% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_http_errors_in_pods.go rename to internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods.go index d842e57..90d9dd9 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_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 KubernetesListTopHttpErrorsInPods struct { +type K8sListTopHttpErrorsInPods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListTopHttpErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopHttpErrorsInPods { - return &KubernetesListTopHttpErrorsInPods{ +func NewK8sListTopHttpErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopHttpErrorsInPods { + return &K8sListTopHttpErrorsInPods{ SysdigClient: sysdigClient, } } -func (t *KubernetesListTopHttpErrorsInPods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_top_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 *KubernetesListTopHttpErrorsInPods) RegisterInServer(s *server.MCPServer s.AddTool(tool, t.handle) } -func (t *KubernetesListTopHttpErrorsInPods) 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_kubernetes_list_top_http_errors_in_pods_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods_test.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_http_errors_in_pods_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods_test.go index 132fe4a..4c302e2 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_http_errors_in_pods_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_http_errors_in_pods_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListTopHttpErrorsInPods Tool", func() { var ( - tool *tools.KubernetesListTopHttpErrorsInPods + tool *tools.K8sListTopHttpErrorsInPods mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -28,14 +28,14 @@ var _ = Describe("KubernetesListTopHttpErrorsInPods Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListTopHttpErrorsInPods(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("kubernetes_list_top_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("KubernetesListTopHttpErrorsInPods Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry("default params", - "kubernetes_list_top_http_errors_in_pods", + "k8s_list_top_http_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_http_errors_in_pods", + Name: "k8s_list_top_http_errors_in_pods", Arguments: map[string]any{}, }, }, @@ -67,10 +67,10 @@ var _ = Describe("KubernetesListTopHttpErrorsInPods Tool", func() { }, ), Entry("with custom params", - "kubernetes_list_top_http_errors_in_pods", + "k8s_list_top_http_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_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("KubernetesListTopHttpErrorsInPods Tool", func() { }, ), Entry("with all params", - "kubernetes_list_top_http_errors_in_pods", + "k8s_list_top_http_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_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("KubernetesListTopHttpErrorsInPods Tool", func() { ) It("returns error for invalid interval", func() { - serverTool := mcpServer.GetTool("kubernetes_list_top_http_errors_in_pods") + serverTool := mcpServer.GetTool("k8s_list_top_http_errors_in_pods") request := mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_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_kubernetes_list_top_memory_consumed_container.go b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_container.go rename to internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container.go index 6b2346b..72ece7b 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_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 KubernetesListTopMemoryConsumedContainer struct { +type K8sListTopMemoryConsumedContainer struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListTopMemoryConsumedContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopMemoryConsumedContainer { - return &KubernetesListTopMemoryConsumedContainer{ +func NewK8sListTopMemoryConsumedContainer(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopMemoryConsumedContainer { + return &K8sListTopMemoryConsumedContainer{ SysdigClient: sysdigClient, } } -func (t *KubernetesListTopMemoryConsumedContainer) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_top_memory_consumed_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 *KubernetesListTopMemoryConsumedContainer) RegisterInServer(s *server.MC s.AddTool(tool, t.handle) } -func (t *KubernetesListTopMemoryConsumedContainer) 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_kubernetes_list_top_memory_consumed_container_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container_test.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_container_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container_test.go index 5952b99..25e28ef 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_container_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_container_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListTopMemoryConsumedContainer Tool", func() { var ( - tool *tools.KubernetesListTopMemoryConsumedContainer + tool *tools.K8sListTopMemoryConsumedContainer mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListTopMemoryConsumedContainer Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListTopMemoryConsumedContainer(mockSysdig) + tool = tools.NewK8sListTopMemoryConsumedContainer(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_top_memory_consumed_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("KubernetesListTopMemoryConsumedContainer Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_top_memory_consumed_container", + "k8s_list_top_memory_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_memory_consumed_container", + Name: "k8s_list_top_memory_consumed_container", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListTopMemoryConsumedContainer Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_memory_consumed_container", + "k8s_list_top_memory_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_memory_consumed_container", + Name: "k8s_list_top_memory_consumed_container", Arguments: map[string]any{ "cluster_name": "prod", "namespace_name": "default", @@ -82,10 +82,10 @@ var _ = Describe("KubernetesListTopMemoryConsumedContainer Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_memory_consumed_container", + "k8s_list_top_memory_consumed_container", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_memory_consumed_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_kubernetes_list_top_memory_consumed_workload.go b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_workload.go rename to internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload.go index 34313e9..1ec7158 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_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 KubernetesListTopMemoryConsumedWorkload struct { +type K8sListTopMemoryConsumedWorkload struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListTopMemoryConsumedWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopMemoryConsumedWorkload { - return &KubernetesListTopMemoryConsumedWorkload{ +func NewK8sListTopMemoryConsumedWorkload(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopMemoryConsumedWorkload { + return &K8sListTopMemoryConsumedWorkload{ SysdigClient: sysdigClient, } } -func (t *KubernetesListTopMemoryConsumedWorkload) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_top_memory_consumed_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 *KubernetesListTopMemoryConsumedWorkload) RegisterInServer(s *server.MCP s.AddTool(tool, t.handle) } -func (t *KubernetesListTopMemoryConsumedWorkload) 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_kubernetes_list_top_memory_consumed_workload_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload_test.go similarity index 83% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_workload_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload_test.go index 817061b..7ddefb3 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_memory_consumed_workload_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_memory_consumed_workload_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListTopMemoryConsumedWorkload Tool", func() { var ( - tool *tools.KubernetesListTopMemoryConsumedWorkload + tool *tools.K8sListTopMemoryConsumedWorkload mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListTopMemoryConsumedWorkload Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListTopMemoryConsumedWorkload(mockSysdig) + tool = tools.NewK8sListTopMemoryConsumedWorkload(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_top_memory_consumed_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("KubernetesListTopMemoryConsumedWorkload Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_top_memory_consumed_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_memory_consumed_workload", + Name: "k8s_list_top_memory_consumed_workload", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListTopMemoryConsumedWorkload Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_memory_consumed_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_memory_consumed_workload", + Name: "k8s_list_top_memory_consumed_workload", Arguments: map[string]any{"limit": "10"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("KubernetesListTopMemoryConsumedWorkload Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_memory_consumed_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_memory_consumed_workload", + Name: "k8s_list_top_memory_consumed_workload", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("KubernetesListTopMemoryConsumedWorkload Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_memory_consumed_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_memory_consumed_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("KubernetesListTopMemoryConsumedWorkload Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_memory_consumed_workload", + "k8s_list_top_memory_consumed_workload", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_memory_consumed_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_kubernetes_list_top_network_errors_in_pods.go b/internal/infra/mcp/tools/tool_k8s_list_top_network_errors_in_pods.go similarity index 87% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_network_errors_in_pods.go rename to internal/infra/mcp/tools/tool_k8s_list_top_network_errors_in_pods.go index 3d5aa38..6703a2e 100644 --- a/internal/infra/mcp/tools/tool_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 KubernetesListTopNetworkErrorsInPods struct { +type K8sListTopNetworkErrorsInPods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListTopNetworkErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopNetworkErrorsInPods { - return &KubernetesListTopNetworkErrorsInPods{ +func NewK8sListTopNetworkErrorsInPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopNetworkErrorsInPods { + return &K8sListTopNetworkErrorsInPods{ SysdigClient: sysdigClient, } } -func (t *KubernetesListTopNetworkErrorsInPods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("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 *KubernetesListTopNetworkErrorsInPods) RegisterInServer(s *server.MCPSer s.AddTool(tool, t.handle) } -func (t *KubernetesListTopNetworkErrorsInPods) 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_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 84% rename from internal/infra/mcp/tools/tool_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 538471d..14eb200 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_network_errors_in_pods_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_network_errors_in_pods_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListTopNetworkErrorsInPods Tool", func() { var ( - tool *tools.KubernetesListTopNetworkErrorsInPods + tool *tools.K8sListTopNetworkErrorsInPods mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -28,14 +28,14 @@ var _ = Describe("KubernetesListTopNetworkErrorsInPods Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListTopNetworkErrorsInPods(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("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("KubernetesListTopNetworkErrorsInPods Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry("default params", - "kubernetes_list_top_network_errors_in_pods", + "k8s_list_top_network_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListTopNetworkErrorsInPods Tool", func() { }, ), Entry("with custom params", - "kubernetes_list_top_network_errors_in_pods", + "k8s_list_top_network_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListTopNetworkErrorsInPods Tool", func() { }, ), Entry("with all params", - "kubernetes_list_top_network_errors_in_pods", + "k8s_list_top_network_errors_in_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListTopNetworkErrorsInPods Tool", func() { ) It("returns error for invalid interval", func() { - serverTool := mcpServer.GetTool("kubernetes_list_top_network_errors_in_pods") + serverTool := mcpServer.GetTool("k8s_list_top_network_errors_in_pods") request := mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListTopNetworkErrorsInPods Tool", func() { request := mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_network_errors_in_pods", + Name: "k8s_list_top_network_errors_in_pods", Arguments: map[string]any{}, }, } - serverTool := mcpServer.GetTool("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_kubernetes_list_top_restarted_pods.go b/internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods.go similarity index 87% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_restarted_pods.go rename to internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods.go index f298c01..22e04ad 100644 --- a/internal/infra/mcp/tools/tool_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 KubernetesListTopRestartedPods struct { +type K8sListTopRestartedPods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListTopRestartedPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopRestartedPods { - return &KubernetesListTopRestartedPods{ +func NewK8sListTopRestartedPods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopRestartedPods { + return &K8sListTopRestartedPods{ SysdigClient: sysdigClient, } } -func (t *KubernetesListTopRestartedPods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("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 *KubernetesListTopRestartedPods) RegisterInServer(s *server.MCPServer) { s.AddTool(tool, t.handle) } -func (t *KubernetesListTopRestartedPods) 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_kubernetes_list_top_restarted_pods_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods_test.go similarity index 84% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_restarted_pods_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods_test.go index 36b288c..1043c45 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_restarted_pods_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_restarted_pods_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListTopRestartedPods Tool", func() { var ( - tool *tools.KubernetesListTopRestartedPods + tool *tools.K8sListTopRestartedPods mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListTopRestartedPods Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListTopRestartedPods(mockSysdig) + tool = tools.NewK8sListTopRestartedPods(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("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("KubernetesListTopRestartedPods Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_restarted_pods", + Name: "k8s_list_top_restarted_pods", Arguments: map[string]any{}, }, }, @@ -64,10 +64,10 @@ var _ = Describe("KubernetesListTopRestartedPods Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_restarted_pods", + Name: "k8s_list_top_restarted_pods", Arguments: map[string]any{"limit": "20"}, }, }, @@ -76,10 +76,10 @@ var _ = Describe("KubernetesListTopRestartedPods Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListTopRestartedPods Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListTopRestartedPods Tool", func() { }, ), Entry(nil, - "kubernetes_list_top_restarted_pods", + "k8s_list_top_restarted_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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_kubernetes_list_top_unavailable_pods.go b/internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods.go similarity index 88% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_unavailable_pods.go rename to internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods.go index 6d78b79..41feb87 100644 --- a/internal/infra/mcp/tools/tool_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 KubernetesListTopUnavailablePods struct { +type K8sListTopUnavailablePods struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListTopUnavailablePods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListTopUnavailablePods { - return &KubernetesListTopUnavailablePods{ +func NewK8sListTopUnavailablePods(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListTopUnavailablePods { + return &K8sListTopUnavailablePods{ SysdigClient: sysdigClient, } } -func (t *KubernetesListTopUnavailablePods) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("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 *KubernetesListTopUnavailablePods) RegisterInServer(s *server.MCPServer) s.AddTool(tool, t.handle) } -func (t *KubernetesListTopUnavailablePods) 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_kubernetes_list_top_unavailable_pods_test.go b/internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods_test.go similarity index 89% rename from internal/infra/mcp/tools/tool_kubernetes_list_top_unavailable_pods_test.go rename to internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods_test.go index 11f8118..297a064 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_top_unavailable_pods_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_top_unavailable_pods_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListTopUnavailablePods Tool", func() { var ( - tool *tools.KubernetesListTopUnavailablePods + tool *tools.K8sListTopUnavailablePods mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListTopUnavailablePods Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListTopUnavailablePods(mockSysdig) + tool = tools.NewK8sListTopUnavailablePods(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("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("KubernetesListTopUnavailablePods Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry("default params", - "kubernetes_list_top_unavailable_pods", + "k8s_list_top_unavailable_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_top_unavailable_pods", + Name: "k8s_list_top_unavailable_pods", Arguments: map[string]any{}, }, }, @@ -83,10 +83,10 @@ var _ = Describe("KubernetesListTopUnavailablePods Tool", func() { }, ), Entry("with specific limit and cluster", - "kubernetes_list_top_unavailable_pods", + "k8s_list_top_unavailable_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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("KubernetesListTopUnavailablePods Tool", func() { }, ), Entry("with all filters", - "kubernetes_list_top_unavailable_pods", + "k8s_list_top_unavailable_pods", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "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_kubernetes_list_underutilized_pods_cpu_quota.go b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota.go similarity index 82% rename from internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_cpu_quota.go rename to internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota.go index 92596dc..4525c3d 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_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 KubernetesListUnderutilizedPodsCPUQuota struct { +type K8sListUnderutilizedPodsCPUQuota struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListUnderutilizedPodsCPUQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListUnderutilizedPodsCPUQuota { - return &KubernetesListUnderutilizedPodsCPUQuota{ +func NewK8sListUnderutilizedPodsCPUQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListUnderutilizedPodsCPUQuota { + return &K8sListUnderutilizedPodsCPUQuota{ SysdigClient: sysdigClient, } } -func (t *KubernetesListUnderutilizedPodsCPUQuota) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_underutilized_pods_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 *KubernetesListUnderutilizedPodsCPUQuota) RegisterInServer(s *server.MCP s.AddTool(tool, t.handle) } -func (t *KubernetesListUnderutilizedPodsCPUQuota) 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_kubernetes_list_underutilized_pods_cpu_quota_test.go b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota_test.go similarity index 83% rename from internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_cpu_quota_test.go rename to internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota_test.go index d451e4a..2e1956e 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_cpu_quota_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_cpu_quota_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListUnderutilizedPodsCPUQuota Tool", func() { var ( - tool *tools.KubernetesListUnderutilizedPodsCPUQuota + tool *tools.K8sListUnderutilizedPodsCPUQuota mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListUnderutilizedPodsCPUQuota Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListUnderutilizedPodsCPUQuota(mockSysdig) + tool = tools.NewK8sListUnderutilizedPodsCPUQuota(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_underutilized_pods_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("KubernetesListUnderutilizedPodsCPUQuota Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_underutilized_pods_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_underutilized_pods_cpu_quota", + Name: "k8s_list_underutilized_pods_cpu_quota", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListUnderutilizedPodsCPUQuota Tool", func() { }, ), Entry(nil, - "kubernetes_list_underutilized_pods_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_underutilized_pods_cpu_quota", + Name: "k8s_list_underutilized_pods_cpu_quota", Arguments: map[string]any{"limit": "20"}, }, }, @@ -78,10 +78,10 @@ var _ = Describe("KubernetesListUnderutilizedPodsCPUQuota Tool", func() { }, ), Entry(nil, - "kubernetes_list_underutilized_pods_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_underutilized_pods_cpu_quota", + Name: "k8s_list_underutilized_pods_cpu_quota", Arguments: map[string]any{"cluster_name": "my_cluster"}, }, }, @@ -91,10 +91,10 @@ var _ = Describe("KubernetesListUnderutilizedPodsCPUQuota Tool", func() { }, ), Entry(nil, - "kubernetes_list_underutilized_pods_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_underutilized_pods_cpu_quota", + Name: "k8s_list_underutilized_pods_cpu_quota", Arguments: map[string]any{"namespace_name": "my_namespace"}, }, }, @@ -104,10 +104,10 @@ var _ = Describe("KubernetesListUnderutilizedPodsCPUQuota Tool", func() { }, ), Entry(nil, - "kubernetes_list_underutilized_pods_cpu_quota", + "k8s_list_underutilized_pods_cpu_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_underutilized_pods_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_kubernetes_list_underutilized_pods_memory_quota.go b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota.go similarity index 82% rename from internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_memory_quota.go rename to internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota.go index 59a5acf..bfd2251 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_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 KubernetesListUnderutilizedPodsMemoryQuota struct { +type K8sListUnderutilizedPodsMemoryQuota struct { SysdigClient sysdig.ExtendedClientWithResponsesInterface } -func NewKubernetesListUnderutilizedPodsMemoryQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListUnderutilizedPodsMemoryQuota { - return &KubernetesListUnderutilizedPodsMemoryQuota{ +func NewK8sListUnderutilizedPodsMemoryQuota(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *K8sListUnderutilizedPodsMemoryQuota { + return &K8sListUnderutilizedPodsMemoryQuota{ SysdigClient: sysdigClient, } } -func (t *KubernetesListUnderutilizedPodsMemoryQuota) RegisterInServer(s *server.MCPServer) { - tool := mcp.NewTool("kubernetes_list_underutilized_pods_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 *KubernetesListUnderutilizedPodsMemoryQuota) RegisterInServer(s *server. s.AddTool(tool, t.handle) } -func (t *KubernetesListUnderutilizedPodsMemoryQuota) 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_kubernetes_list_underutilized_pods_memory_quota_test.go b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota_test.go similarity index 85% rename from internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_memory_quota_test.go rename to internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota_test.go index 9638191..542f8a9 100644 --- a/internal/infra/mcp/tools/tool_kubernetes_list_underutilized_pods_memory_quota_test.go +++ b/internal/infra/mcp/tools/tool_k8s_list_underutilized_pods_memory_quota_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("KubernetesListUnderutilizedPodsMemoryQuota Tool", func() { var ( - tool *tools.KubernetesListUnderutilizedPodsMemoryQuota + tool *tools.K8sListUnderutilizedPodsMemoryQuota mockSysdig *mocks.MockExtendedClientWithResponsesInterface mcpServer *server.MCPServer ctrl *gomock.Controller @@ -27,13 +27,13 @@ var _ = Describe("KubernetesListUnderutilizedPodsMemoryQuota Tool", func() { BeforeEach(func() { ctrl = gomock.NewController(GinkgoT()) mockSysdig = mocks.NewMockExtendedClientWithResponsesInterface(ctrl) - tool = tools.NewKubernetesListUnderutilizedPodsMemoryQuota(mockSysdig) + tool = tools.NewK8sListUnderutilizedPodsMemoryQuota(mockSysdig) mcpServer = server.NewMCPServer("test", "test") tool.RegisterInServer(mcpServer) }) It("should register successfully in the server", func() { - Expect(mcpServer.GetTool("kubernetes_list_underutilized_pods_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("KubernetesListUnderutilizedPodsMemoryQuota Tool", func() { Expect(resultData.Text).To(MatchJSON(`{"status":"success"}`)) }, Entry(nil, - "kubernetes_list_underutilized_pods_memory_quota", + "k8s_list_underutilized_pods_memory_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_underutilized_pods_memory_quota", + Name: "k8s_list_underutilized_pods_memory_quota", Arguments: map[string]any{}, }, }, @@ -65,10 +65,10 @@ var _ = Describe("KubernetesListUnderutilizedPodsMemoryQuota Tool", func() { }, ), Entry(nil, - "kubernetes_list_underutilized_pods_memory_quota", + "k8s_list_underutilized_pods_memory_quota", mcp.CallToolRequest{ Params: mcp.CallToolParams{ - Name: "kubernetes_list_underutilized_pods_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",