Skip to content

Commit cce33d8

Browse files
committed
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.
1 parent 68b3f90 commit cce33d8

25 files changed

+227
-227
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,57 +133,57 @@ The server dynamically filters the available tools based on the permissions asso
133133
- **Required Permission**: `metrics-data.read`
134134
- **Sample Prompt**: "List all cronjobs in cluster 'prod' and namespace 'default'"
135135

136-
- **`troubleshoot_kubernetes_list_top_unavailable_pods`**
136+
- **`kubernetes_list_top_unavailable_pods`**
137137
- **Description**: Shows the top N pods with the highest number of unavailable or unready replicas in a Kubernetes cluster, ordered from highest to lowest.
138138
- **Required Permission**: `metrics-data.read`
139139
- **Sample Prompt**: "Show the top 20 unavailable pods in cluster 'production'"
140140

141-
- **`troubleshoot_kubernetes_list_top_restarted_pods`**
141+
- **`kubernetes_list_top_restarted_pods`**
142142
- **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.
143143
- **Required Permission**: `metrics-data.read`
144144
- **Sample Prompt**: "Show the top 10 pods with the most container restarts in cluster 'production'"
145145

146-
- **`troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods`**
146+
- **`kubernetes_list_top_http_errors_in_pods`**
147147
- **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.
148148
- **Required Permission**: `metrics-data.read`
149149
- **Sample Prompt**: "Show the top 20 pods with the most HTTP errors in cluster 'production'"
150150

151-
- **`troubleshoot_kubernetes_list_top_network_errors_in_pods`**
151+
- **`kubernetes_list_top_network_errors_in_pods`**
152152
- **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.
153153
- **Required Permission**: `metrics-data.read`
154154
- **Sample Prompt**: "Show the top 10 pods with the most network errors in cluster 'production'"
155155

156-
- **`troubleshoot_kubernetes_list_count_pods_per_cluster`**
156+
- **`kubernetes_list_count_pods_per_cluster`**
157157
- **Description**: List the count of running Kubernetes Pods grouped by cluster and namespace.
158158
- **Required Permission**: `metrics-data.read`
159159
- **Sample Prompt**: "List the count of running Kubernetes Pods in cluster 'production'"
160160

161-
- **`troubleshoot_kubernetes_list_underutilized_pods_by_cpu_quota`**
161+
- **`kubernetes_list_underutilized_pods_cpu_quota`**
162162
- **Description**: List Kubernetes pods with CPU usage below 25% of the quota limit.
163163
- **Required Permission**: `metrics-data.read`
164164
- **Sample Prompt**: "Show the top 10 underutilized pods by CPU quota in cluster 'production'"
165165

166-
- **`troubleshoot_kubernetes_list_underutilized_pods_by_memory_quota`**
166+
- **`kubernetes_list_underutilized_pods_memory_quota`**
167167
- **Description**: List Kubernetes pods with memory usage below 25% of the limit.
168168
- **Required Permission**: `metrics-data.read`
169169
- **Sample Prompt**: "Show the top 10 underutilized pods by memory quota in cluster 'production'"
170170

171-
- **`troubleshoot_kubernetes_list_top_cpu_consumed_by_workload`**
171+
- **`kubernetes_list_top_cpu_consumed_workload`**
172172
- **Description**: Identifies the Kubernetes workloads (all containers) consuming the most CPU (in cores).
173173
- **Required Permission**: `metrics-data.read`
174174
- **Sample Prompt**: "Show the top 10 workloads consuming the most CPU in cluster 'production'"
175175

176-
- **`troubleshoot_kubernetes_list_top_cpu_consumed_by_container`**
176+
- **`kubernetes_list_top_cpu_consumed_container`**
177177
- **Description**: Identifies the Kubernetes containers consuming the most CPU (in cores).
178178
- **Required Permission**: `metrics-data.read`
179179
- **Sample Prompt**: "Show the top 10 containers consuming the most CPU in cluster 'production'"
180180

181-
- **`troubleshoot_kubernetes_list_top_memory_consumed_by_workload`**
181+
- **`kubernetes_list_top_memory_consumed_workload`**
182182
- **Description**: Lists memory-intensive workloads (all containers).
183183
- **Required Permission**: `metrics-data.read`
184184
- **Sample Prompt**: "Show the top 10 workloads consuming the most memory in cluster 'production'"
185185

186-
- **`troubleshoot_kubernetes_list_top_memory_consumed_by_container`**
186+
- **`kubernetes_list_top_memory_consumed_container`**
187187
- **Description**: Lists memory-intensive containers.
188188
- **Required Permission**: `metrics-data.read`
189189
- **Sample Prompt**: "Show the top 10 containers consuming the most memory in cluster 'production'"

cmd/server/main.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,17 @@ func setupHandler(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *mcp
100100
tools.NewKubernetesListCronjobs(sysdigClient),
101101
tools.NewKubernetesListWorkloads(sysdigClient),
102102
tools.NewKubernetesListPodContainers(sysdigClient),
103-
tools.NewTroubleshootKubernetesListTopUnavailablePods(sysdigClient),
104-
tools.NewTroubleshootKubernetesListTopRestartedPods(sysdigClient),
105-
tools.NewTroubleshootKubernetesListTop400500HttpErrorsInPods(sysdigClient),
106-
tools.NewTroubleshootKubernetesListTopNetworkErrorsInPods(sysdigClient),
107-
tools.NewTroubleshootKubernetesListCountPodsPerCluster(sysdigClient),
108-
tools.NewTroubleshootKubernetesListUnderutilizedPodsByCPUQuota(sysdigClient),
109-
tools.NewTroubleshootKubernetesListTopCPUConsumedByWorkload(sysdigClient),
110-
tools.NewTroubleshootKubernetesListTopCPUConsumedByContainer(sysdigClient),
111-
tools.NewTroubleshootKubernetesListUnderutilizedPodsByMemoryQuota(sysdigClient),
112-
tools.NewTroubleshootKubernetesListTopMemoryConsumedByWorkload(sysdigClient),
113-
tools.NewTroubleshootKubernetesListTopMemoryConsumedByContainer(sysdigClient),
103+
tools.NewKubernetesListTopUnavailablePods(sysdigClient),
104+
tools.NewKubernetesListTopRestartedPods(sysdigClient),
105+
tools.NewKubernetesListTopHttpErrorsInPods(sysdigClient),
106+
tools.NewKubernetesListTopNetworkErrorsInPods(sysdigClient),
107+
tools.NewKubernetesListCountPodsPerCluster(sysdigClient),
108+
tools.NewKubernetesListUnderutilizedPodsCPUQuota(sysdigClient),
109+
tools.NewKubernetesListTopCPUConsumedWorkload(sysdigClient),
110+
tools.NewKubernetesListTopCPUConsumedContainer(sysdigClient),
111+
tools.NewKubernetesListUnderutilizedPodsMemoryQuota(sysdigClient),
112+
tools.NewKubernetesListTopMemoryConsumedWorkload(sysdigClient),
113+
tools.NewKubernetesListTopMemoryConsumedContainer(sysdigClient),
114114
)
115115
return handler
116116
}

internal/infra/mcp/tools/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ The handler filters tools dynamically based on the Sysdig user's permissions. Ea
1414
| `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'" |
1515
| `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.” |
1616
| `run_sysql` | `tool_run_sysql.go` | Execute caller-supplied Sysdig SysQL queries safely. | `sage.exec`, `risks.read` | “Run the following SysQL…”. |
17-
| `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'" |
18-
| `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'" |
19-
| `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'" |
20-
| `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'" |
21-
| `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'" |
22-
| `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'" |
23-
| `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'" |
24-
| `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'" |
25-
| `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'" |
26-
| `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'" |
27-
| `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'" |
17+
| `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'" |
18+
| `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'" |
19+
| `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'" |
20+
| `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'" |
21+
| `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'" |
22+
| `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'" |
23+
| `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'" |
24+
| `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'" |
25+
| `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'" |
26+
| `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'" |
27+
| `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'" |
2828

2929
# Adding a New Tool
3030

internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster.go renamed to internal/infra/mcp/tools/tool_kubernetes_list_count_pods_per_cluster.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ import (
1212
"github.com/sysdiglabs/sysdig-mcp-server/internal/infra/sysdig"
1313
)
1414

15-
type TroubleshootKubernetesListCountPodsPerCluster struct {
15+
type KubernetesListCountPodsPerCluster struct {
1616
SysdigClient sysdig.ExtendedClientWithResponsesInterface
1717
}
1818

19-
func NewTroubleshootKubernetesListCountPodsPerCluster(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *TroubleshootKubernetesListCountPodsPerCluster {
20-
return &TroubleshootKubernetesListCountPodsPerCluster{
19+
func NewKubernetesListCountPodsPerCluster(sysdigClient sysdig.ExtendedClientWithResponsesInterface) *KubernetesListCountPodsPerCluster {
20+
return &KubernetesListCountPodsPerCluster{
2121
SysdigClient: sysdigClient,
2222
}
2323
}
2424

25-
func (t *TroubleshootKubernetesListCountPodsPerCluster) RegisterInServer(s *server.MCPServer) {
26-
tool := mcp.NewTool("troubleshoot_kubernetes_list_count_pods_per_cluster",
25+
func (t *KubernetesListCountPodsPerCluster) RegisterInServer(s *server.MCPServer) {
26+
tool := mcp.NewTool("kubernetes_list_count_pods_per_cluster",
2727
mcp.WithDescription("List the count of running Kubernetes Pods grouped by cluster and namespace."),
2828
mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")),
2929
mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")),
@@ -39,7 +39,7 @@ func (t *TroubleshootKubernetesListCountPodsPerCluster) RegisterInServer(s *serv
3939
s.AddTool(tool, t.handle)
4040
}
4141

42-
func (t *TroubleshootKubernetesListCountPodsPerCluster) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
42+
func (t *KubernetesListCountPodsPerCluster) handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
4343
clusterName := mcp.ParseString(request, "cluster_name", "")
4444
namespaceName := mcp.ParseString(request, "namespace_name", "")
4545
limit := mcp.ParseInt(request, "limit", 20)

0 commit comments

Comments
 (0)