Skip to content

Commit 4735fd2

Browse files
committed
feat: add readonly hint annotations to all MCP tools
1 parent a3c8b60 commit 4735fd2

21 files changed

+21
-0
lines changed

internal/infra/mcp/tools/tool_generate_sysql.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func (h *ToolGenerateSysql) RegisterInServer(s *server.MCPServer) {
5353
),
5454
),
5555
mcp.WithOutputSchema[map[string]any](),
56+
mcp.WithReadOnlyHintAnnotation(true),
5657
WithRequiredPermissions("sage.exec"),
5758
)
5859
s.AddTool(tool, h.handle)

internal/infra/mcp/tools/tool_get_event_info.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (h *ToolGetEventInfo) RegisterInServer(s *server.MCPServer) {
4343
mcp.Required(),
4444
),
4545
mcp.WithOutputSchema[map[string]any](),
46+
mcp.WithReadOnlyHintAnnotation(true),
4647
WithRequiredPermissions("policy-events.read"),
4748
)
4849

internal/infra/mcp/tools/tool_get_event_process_tree.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func (h *ToolGetEventProcessTree) RegisterInServer(s *server.MCPServer) {
6161
mcp.Required(),
6262
),
6363
mcp.WithOutputSchema[map[string]any](),
64+
mcp.WithReadOnlyHintAnnotation(true),
6465
WithRequiredPermissions("policy-events.read"),
6566
)
6667

internal/infra/mcp/tools/tool_kubernetes_list_clusters.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func (t *KubernetesListClusters) RegisterInServer(s *server.MCPServer) {
3030
mcp.DefaultNumber(10),
3131
),
3232
mcp.WithOutputSchema[map[string]any](),
33+
mcp.WithReadOnlyHintAnnotation(true),
3334
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.
3435
)
3536
s.AddTool(tool, t.handle)

internal/infra/mcp/tools/tool_kubernetes_list_cronjobs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (t *KubernetesListCronjobs) RegisterInServer(s *server.MCPServer) {
3333
mcp.DefaultNumber(10),
3434
),
3535
mcp.WithOutputSchema[map[string]any](),
36+
mcp.WithReadOnlyHintAnnotation(true),
3637
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.
3738
)
3839
s.AddTool(tool, t.handle)

internal/infra/mcp/tools/tool_kubernetes_list_nodes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func (t *KubernetesListNodes) RegisterInServer(s *server.MCPServer) {
3232
mcp.DefaultNumber(10),
3333
),
3434
mcp.WithOutputSchema[map[string]any](),
35+
mcp.WithReadOnlyHintAnnotation(true),
3536
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.
3637
)
3738
s.AddTool(tool, t.handle)

internal/infra/mcp/tools/tool_kubernetes_list_pod_containers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func (t *KubernetesListPodContainers) RegisterInServer(s *server.MCPServer) {
3838
mcp.DefaultNumber(10),
3939
),
4040
mcp.WithOutputSchema[map[string]any](),
41+
mcp.WithReadOnlyHintAnnotation(true),
4142
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.
4243
)
4344
s.AddTool(tool, t.handle)

internal/infra/mcp/tools/tool_kubernetes_list_workloads.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func (t *KubernetesListWorkloads) RegisterInServer(s *server.MCPServer) {
4242
mcp.DefaultNumber(10),
4343
),
4444
mcp.WithOutputSchema[map[string]any](),
45+
mcp.WithReadOnlyHintAnnotation(true),
4546
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.
4647
)
4748
s.AddTool(tool, t.handle)

internal/infra/mcp/tools/tool_list_runtime_events.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ You can specify the severity of the events based on the following cases:
9999
),
100100
),
101101
mcp.WithOutputSchema[map[string]any](),
102+
mcp.WithReadOnlyHintAnnotation(true),
102103
WithRequiredPermissions("policy-events.read"),
103104
)
104105

internal/infra/mcp/tools/tool_run_sysql.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (h *ToolRunSysql) RegisterInServer(s *server.MCPServer) {
6060
),
6161
),
6262
mcp.WithOutputSchema[map[string]any](),
63+
mcp.WithReadOnlyHintAnnotation(true),
6364
WithRequiredPermissions("sage.exec", "risks.read"),
6465
)
6566
s.AddTool(tool, h.handle)

0 commit comments

Comments
 (0)