From a68a212746ca21197065e4e84567bd3159ed8af0 Mon Sep 17 00:00:00 2001 From: axelray-dev <110029405+axelray-dev@users.noreply.github.com> Date: Fri, 19 Jun 2026 00:51:39 +0800 Subject: [PATCH] fix: add DestructiveHint and OpenWorldHint to label_write annotations The label_write tool supports a delete method that permanently removes a label and all its associations from every issue/PR in the repository. However, it only set ReadOnlyHint: false and did not signal the destructive nature of this operation to MCP clients. Add DestructiveHint: true and OpenWorldHint: true to match the pattern used by other destructive tools in the codebase (actions_run_trigger, projects_write, discussion_comment_write, remove_sub_issue). Fixes #2723 --- pkg/github/__toolsnaps__/label_write.snap | 2 ++ pkg/github/labels.go | 6 ++++-- pkg/github/labels_test.go | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/github/__toolsnaps__/label_write.snap b/pkg/github/__toolsnaps__/label_write.snap index de4b98bef7..ffd81a4421 100644 --- a/pkg/github/__toolsnaps__/label_write.snap +++ b/pkg/github/__toolsnaps__/label_write.snap @@ -1,5 +1,7 @@ { "annotations": { + "destructiveHint": true, + "openWorldHint": true, "title": "Write operations on repository labels" }, "description": "Perform write operations on repository labels. To set labels on issues, use the 'update_issue' tool.", diff --git a/pkg/github/labels.go b/pkg/github/labels.go index 0e49968496..5c16e15fda 100644 --- a/pkg/github/labels.go +++ b/pkg/github/labels.go @@ -226,8 +226,10 @@ func LabelWrite(t translations.TranslationHelperFunc) inventory.ServerTool { Name: "label_write", Description: t("TOOL_LABEL_WRITE_DESCRIPTION", "Perform write operations on repository labels. To set labels on issues, use the 'update_issue' tool."), Annotations: &mcp.ToolAnnotations{ - Title: t("TOOL_LABEL_WRITE_TITLE", "Write operations on repository labels"), - ReadOnlyHint: false, + Title: t("TOOL_LABEL_WRITE_TITLE", "Write operations on repository labels"), + ReadOnlyHint: false, + DestructiveHint: jsonschema.Ptr(true), + OpenWorldHint: jsonschema.Ptr(true), }, InputSchema: &jsonschema.Schema{ Type: "object", diff --git a/pkg/github/labels_test.go b/pkg/github/labels_test.go index 88102ba3c9..139a552c97 100644 --- a/pkg/github/labels_test.go +++ b/pkg/github/labels_test.go @@ -247,6 +247,8 @@ func TestWriteLabel(t *testing.T) { assert.Equal(t, "label_write", tool.Name) assert.NotEmpty(t, tool.Description) assert.False(t, tool.Annotations.ReadOnlyHint, "label_write tool should not be read-only") + require.NotNil(t, tool.Annotations.DestructiveHint, "label_write tool should have DestructiveHint set") + assert.True(t, *tool.Annotations.DestructiveHint, "label_write tool should be marked as destructive") tests := []struct { name string