From 78d4cfbff99200660124fa08e6ab0800ddbbbadf Mon Sep 17 00:00:00 2001 From: syf Date: Wed, 24 Jun 2026 19:13:11 +0800 Subject: [PATCH] fix(labels): add DestructiveHint to label_write tool The label_write delete method removes labels repository-wide but the tool only advertised ReadOnlyHint:false. Set DestructiveHint:true so MCP clients can warn before destructive label deletions, matching projects_write. Fixes #2723 Co-authored-by: Cursor --- pkg/github/__toolsnaps__/label_write.snap | 1 + pkg/github/labels.go | 5 +++-- pkg/github/labels_test.go | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/github/__toolsnaps__/label_write.snap b/pkg/github/__toolsnaps__/label_write.snap index de4b98bef7..0617052990 100644 --- a/pkg/github/__toolsnaps__/label_write.snap +++ b/pkg/github/__toolsnaps__/label_write.snap @@ -1,5 +1,6 @@ { "annotations": { + "destructiveHint": 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..29ae3d5323 100644 --- a/pkg/github/labels.go +++ b/pkg/github/labels.go @@ -226,8 +226,9 @@ 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), }, InputSchema: &jsonschema.Schema{ Type: "object", diff --git a/pkg/github/labels_test.go b/pkg/github/labels_test.go index 88102ba3c9..c3434b240b 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") + assert.NotNil(t, tool.Annotations.DestructiveHint) + assert.True(t, *tool.Annotations.DestructiveHint, "label_write delete removes labels repository-wide") tests := []struct { name string