Skip to content

Commit 4c69e5d

Browse files
committed
fix(tools): replace promql.exec with metrics-data.read
1 parent 3d822d0 commit 4c69e5d

18 files changed

+48
-48
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,82 +110,82 @@ The server dynamically filters the available tools based on the permissions asso
110110

111111
- **`kubernetes_list_clusters`**
112112
- **Description**: Lists the cluster information for all clusters or just the cluster specified.
113-
- **Required Permission**: `promql.exec`
113+
- **Required Permission**: `metrics-data.read`
114114
- **Sample Prompt**: "List all kubernetes clusters" or "Show me info for cluster 'production-gke'"
115115

116116
- **`kubernetes_list_nodes`**
117117
- **Description**: Lists the node information for all nodes, all nodes from a cluster or just the node specified.
118-
- **Required Permission**: `promql.exec`
118+
- **Required Permission**: `metrics-data.read`
119119
- **Sample Prompt**: "List all kubernetes nodes in the cluster 'production-gke'" or "Show me info for node 'node-123'"
120120

121121
- **`kubernetes_list_workloads`**
122122
- **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.
123-
- **Required Permission**: `promql.exec`
123+
- **Required Permission**: `metrics-data.read`
124124
- **Sample Prompt**: "List all desired workloads in the cluster 'production-gke' and namespace 'default'"
125125

126126
- **`kubernetes_list_pod_containers`**
127127
- **Description**: Retrieves information from a particular pod and container.
128-
- **Required Permission**: `promql.exec`
128+
- **Required Permission**: `metrics-data.read`
129129
- **Sample Prompt**: "Show me info for pod 'my-pod' in cluster 'production-gke'"
130130

131131
- **`kubernetes_list_cronjobs`**
132132
- **Description**: Retrieves information from the cronjobs in the cluster.
133-
- **Required Permission**: `promql.exec`
133+
- **Required Permission**: `metrics-data.read`
134134
- **Sample Prompt**: "List all cronjobs in cluster 'prod' and namespace 'default'"
135135

136136
- **`troubleshoot_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.
138-
- **Required Permission**: `promql.exec`
138+
- **Required Permission**: `metrics-data.read`
139139
- **Sample Prompt**: "Show the top 20 unavailable pods in cluster 'production'"
140140

141141
- **`troubleshoot_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.
143-
- **Required Permission**: `promql.exec`
143+
- **Required Permission**: `metrics-data.read`
144144
- **Sample Prompt**: "Show the top 10 pods with the most container restarts in cluster 'production'"
145145

146146
- **`troubleshoot_kubernetes_list_top_400_500_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.
148-
- **Required Permission**: `promql.exec`
148+
- **Required Permission**: `metrics-data.read`
149149
- **Sample Prompt**: "Show the top 20 pods with the most HTTP errors in cluster 'production'"
150150

151151
- **`troubleshoot_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.
153-
- **Required Permission**: `promql.exec`
153+
- **Required Permission**: `metrics-data.read`
154154
- **Sample Prompt**: "Show the top 10 pods with the most network errors in cluster 'production'"
155155

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

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

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

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

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

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

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

191191
## Requirements

internal/infra/mcp/tools/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ The handler filters tools dynamically based on the Sysdig user's permissions. Ea
99
| `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`.” |
1010
| `run_sysql` | `tool_run_sysql.go` | Execute caller-supplied Sysdig SysQL queries safely. | `sage.exec`, `risks.read` | “Run the following SysQL…”. |
1111
| `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.” |
12-
| `kubernetes_list_clusters` | `tool_kubernetes_list_clusters.go` | Lists Kubernetes cluster information. | `promql.exec` | "List all Kubernetes clusters" |
13-
| `kubernetes_list_nodes` | `tool_kubernetes_list_nodes.go` | Lists Kubernetes node information. | `promql.exec` | "List all Kubernetes nodes in the cluster 'production-gke'" |
14-
| `kubernetes_list_workloads` | `tool_kubernetes_list_workloads.go` | Lists Kubernetes workload information. | `promql.exec` | "List all desired workloads in the cluster 'production-gke' and namespace 'default'" |
15-
| `kubernetes_list_pod_containers` | `tool_kubernetes_list_pod_containers.go` | Retrieves information from a particular pod and container. | `promql.exec` | "Show me info for pod 'my-pod' in cluster 'production-gke'" |
16-
| `kubernetes_list_cronjobs` | `tool_kubernetes_list_cronjobs.go` | Retrieves information from the cronjobs in the cluster. | `promql.exec` | "List all cronjobs in cluster 'prod' and namespace 'default'" |
17-
| `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. | `promql.exec` | "Show the top 20 unavailable pods in cluster 'production'" |
18-
| `troubleshoot_kubernetes_list_top_restarted_pods` | `tool_troubleshoot_kubernetes_list_top_restarted_pods.go` | Lists the pods with the highest number of container restarts. | `promql.exec` | "Show the top 10 pods with the most container restarts in cluster 'production'" |
19-
| `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. | `promql.exec` | "Show the top 20 pods with the most HTTP errors in cluster 'production'" |
20-
| `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. | `promql.exec` | "Show the top 10 pods with the most network errors in cluster 'production'" |
21-
| `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. | `promql.exec` | "List the count of running Kubernetes Pods in cluster 'production'" |
22-
| `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. | `promql.exec` | "Show the top 10 underutilized pods by CPU quota in cluster 'production'" |
23-
| `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. | `promql.exec` | "Show the top 10 underutilized pods by memory quota in cluster 'production'" |
24-
| `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). | `promql.exec` | "Show the top 10 workloads consuming the most CPU in cluster 'production'" |
25-
| `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). | `promql.exec` | "Show the top 10 containers consuming the most CPU in cluster 'production'" |
26-
| `troubleshoot_kubernetes_list_top_memory_consumed_by_workload` | `tool_troubleshoot_kubernetes_list_top_memory_consumed_by_workload.go` | Lists memory-intensive workloads (all containers). | `promql.exec` | "Show the top 10 workloads consuming the most memory in cluster 'production'" |
27-
| `troubleshoot_kubernetes_list_top_memory_consumed_by_container` | `tool_troubleshoot_kubernetes_list_top_memory_consumed_by_container.go` | Lists memory-intensive containers. | `promql.exec` | "Show the top 10 containers consuming the most memory in cluster 'production'" |
12+
| `kubernetes_list_clusters` | `tool_kubernetes_list_clusters.go` | Lists Kubernetes cluster information. | `metrics-data.read` | "List all Kubernetes clusters" |
13+
| `kubernetes_list_nodes` | `tool_kubernetes_list_nodes.go` | Lists Kubernetes node information. | `metrics-data.read` | "List all Kubernetes nodes in the cluster 'production-gke'" |
14+
| `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'" |
15+
| `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'" |
16+
| `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'" |
17+
| `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'" |
18+
| `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'" |
19+
| `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'" |
20+
| `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'" |
21+
| `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'" |
22+
| `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'" |
23+
| `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'" |
24+
| `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'" |
25+
| `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'" |
26+
| `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'" |
27+
| `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'" |
2828

2929
# Adding a New Tool
3030

internal/infra/mcp/tools/tool_kubernetes_list_clusters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (t *KubernetesListClusters) RegisterInServer(s *server.MCPServer) {
3232
mcp.WithOutputSchema[map[string]any](),
3333
mcp.WithReadOnlyHintAnnotation(true),
3434
mcp.WithDestructiveHintAnnotation(false),
35-
WithRequiredPermissions(), // FIXME(fede): Add the required permissions. It should be `promql.exec` but somehow the token does not have that permission even if you are able to execute queries.
35+
WithRequiredPermissions("metrics-data.read"),
3636
)
3737
s.AddTool(tool, t.handle)
3838
}

internal/infra/mcp/tools/tool_kubernetes_list_cronjobs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (t *KubernetesListCronjobs) RegisterInServer(s *server.MCPServer) {
3535
mcp.WithOutputSchema[map[string]any](),
3636
mcp.WithReadOnlyHintAnnotation(true),
3737
mcp.WithDestructiveHintAnnotation(false),
38-
WithRequiredPermissions(), // FIXME(fede): Add the required permissions. It should be `promql.exec` but somehow the token does not have that permission even if you are able to execute queries.
38+
WithRequiredPermissions("metrics-data.read"),
3939
)
4040
s.AddTool(tool, t.handle)
4141
}

internal/infra/mcp/tools/tool_kubernetes_list_nodes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (t *KubernetesListNodes) RegisterInServer(s *server.MCPServer) {
3434
mcp.WithOutputSchema[map[string]any](),
3535
mcp.WithReadOnlyHintAnnotation(true),
3636
mcp.WithDestructiveHintAnnotation(false),
37-
WithRequiredPermissions(), // FIXME(fede): Add the required permissions. It should be `promql.exec` but somehow the token does not have that permission even if you are able to execute queries.
37+
WithRequiredPermissions("metrics-data.read"),
3838
)
3939
s.AddTool(tool, t.handle)
4040
}

internal/infra/mcp/tools/tool_kubernetes_list_pod_containers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (t *KubernetesListPodContainers) RegisterInServer(s *server.MCPServer) {
4040
mcp.WithOutputSchema[map[string]any](),
4141
mcp.WithReadOnlyHintAnnotation(true),
4242
mcp.WithDestructiveHintAnnotation(false),
43-
WithRequiredPermissions(), // FIXME(fede): Add the required permissions. It should be `promql.exec` but somehow the token does not have that permission even if you are able to execute queries.
43+
WithRequiredPermissions("metrics-data.read"),
4444
)
4545
s.AddTool(tool, t.handle)
4646
}

internal/infra/mcp/tools/tool_kubernetes_list_workloads.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (t *KubernetesListWorkloads) RegisterInServer(s *server.MCPServer) {
4444
mcp.WithOutputSchema[map[string]any](),
4545
mcp.WithReadOnlyHintAnnotation(true),
4646
mcp.WithDestructiveHintAnnotation(false),
47-
WithRequiredPermissions(), // FIXME(fede): Add the required permissions. It should be `promql.exec` but somehow the token does not have that permission even if you are able to execute queries.
47+
WithRequiredPermissions("metrics-data.read"),
4848
)
4949
s.AddTool(tool, t.handle)
5050
}

internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_count_pods_per_cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (t *TroubleshootKubernetesListCountPodsPerCluster) RegisterInServer(s *serv
3434
mcp.WithOutputSchema[map[string]any](),
3535
mcp.WithReadOnlyHintAnnotation(true),
3636
mcp.WithDestructiveHintAnnotation(false),
37-
WithRequiredPermissions(), // FIXME(fede): Add the required permissions. It should be `promql.exec` but somehow the token does not have that permission even if you are able to execute queries.
37+
WithRequiredPermissions("metrics-data.read"),
3838
)
3939
s.AddTool(tool, t.handle)
4040
}

internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_400_500_http_errors_in_pods.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (t *TroubleshootKubernetesListTop400500HttpErrorsInPods) RegisterInServer(s
3838
mcp.WithOutputSchema[map[string]any](),
3939
mcp.WithReadOnlyHintAnnotation(true),
4040
mcp.WithDestructiveHintAnnotation(false),
41-
WithRequiredPermissions(), // FIXME(fede): Add the required permissions. It should be `promql.exec` but somehow the token does not have that permission even if you are able to execute queries.
41+
WithRequiredPermissions("metrics-data.read"),
4242
)
4343
s.AddTool(tool, t.handle)
4444
}

internal/infra/mcp/tools/tool_troubleshoot_kubernetes_list_top_cpu_consumed_by_container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (t *TroubleshootKubernetesListTopCPUConsumedByContainer) RegisterInServer(s
3636
mcp.WithOutputSchema[map[string]any](),
3737
mcp.WithReadOnlyHintAnnotation(true),
3838
mcp.WithDestructiveHintAnnotation(false),
39-
WithRequiredPermissions(), // FIXME(fede): Add the required permissions. It should be `promql.exec` but somehow the token does not have that permission even if you are able to execute queries.
39+
WithRequiredPermissions("metrics-data.read"),
4040
)
4141
s.AddTool(tool, t.handle)
4242
}

0 commit comments

Comments
 (0)