From e2defb63fb64822dea067cd37141555400e75222 Mon Sep 17 00:00:00 2001 From: shhhhhhjokerist <104197119+shhhhhhjokerist@users.noreply.github.com> Date: Tue, 10 Nov 2026 11:24:19 +0800 Subject: [PATCH] fix: mark the granular label/assignee replace tools as destructive update_issue_labels and update_issue_assignees replace the current list, so labels or assignees that are not in the new list are removed, yet both set Annotations.DestructiveHint: false. A host that keys confirmation prompts off that hint can run a call that removes data without asking. Their descriptions already say "This replaces the current list", so this is an annotation-accuracy fix: set DestructiveHint: true while replace stays the default behaviour. Annotations are static, so the hint remains correct if PR #2742 later makes add/remove explicit operations available on the same tool. Refs #3760. --- .../__toolsnaps__/update_issue_assignees.snap | 2 +- .../__toolsnaps__/update_issue_labels.snap | 2 +- pkg/github/granular_tools_test.go | 25 +++++++++++++++++++ pkg/github/issues_granular.go | 4 +-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/pkg/github/__toolsnaps__/update_issue_assignees.snap b/pkg/github/__toolsnaps__/update_issue_assignees.snap index 088992dc3b..4e563189d8 100644 --- a/pkg/github/__toolsnaps__/update_issue_assignees.snap +++ b/pkg/github/__toolsnaps__/update_issue_assignees.snap @@ -1,6 +1,6 @@ { "annotations": { - "destructiveHint": false, + "destructiveHint": true, "idempotentHint": false, "openWorldHint": true, "readOnlyHint": false, diff --git a/pkg/github/__toolsnaps__/update_issue_labels.snap b/pkg/github/__toolsnaps__/update_issue_labels.snap index c0cfa73ad8..a780d3a172 100644 --- a/pkg/github/__toolsnaps__/update_issue_labels.snap +++ b/pkg/github/__toolsnaps__/update_issue_labels.snap @@ -1,6 +1,6 @@ { "annotations": { - "destructiveHint": false, + "destructiveHint": true, "idempotentHint": false, "openWorldHint": true, "readOnlyHint": false, diff --git a/pkg/github/granular_tools_test.go b/pkg/github/granular_tools_test.go index 460a192766..046fd5f53d 100644 --- a/pkg/github/granular_tools_test.go +++ b/pkg/github/granular_tools_test.go @@ -76,6 +76,31 @@ func TestGranularToolSnaps(t *testing.T) { } } +func TestGranularReplaceToolsAreDestructive(t *testing.T) { + // update_issue_labels and update_issue_assignees replace the current list, + // so entries that are not in it are removed. Hosts key confirmation prompts + // off destructiveHint, so a replace-semantics tool must not claim to be + // non-destructive. + tests := []struct { + name string + construct func(translations.TranslationHelperFunc) inventory.ServerTool + }{ + {name: "update_issue_labels", construct: GranularUpdateIssueLabels}, + {name: "update_issue_assignees", construct: GranularUpdateIssueAssignees}, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + tool := tc.construct(translations.NullTranslationHelper).Tool + require.NotNil(t, tool.Annotations) + require.NotNil(t, tool.Annotations.DestructiveHint, "the hint must be stated explicitly") + assert.True(t, *tool.Annotations.DestructiveHint) + // The description is what documents the replace semantics. + assert.Contains(t, tool.Description, "replaces") + }) + } +} + func TestIssuesGranularToolset(t *testing.T) { t.Run("toolset contains expected granular tools", func(t *testing.T) { tools := granularToolsForToolset(ToolsetMetadataIssues.ID, FeatureFlagIssuesGranular) diff --git a/pkg/github/issues_granular.go b/pkg/github/issues_granular.go index eab4a204cd..c1604ee93f 100644 --- a/pkg/github/issues_granular.go +++ b/pkg/github/issues_granular.go @@ -235,7 +235,7 @@ func GranularUpdateIssueAssignees(t translations.TranslationHelperFunc) inventor Annotations: &mcp.ToolAnnotations{ Title: t("TOOL_UPDATE_ISSUE_ASSIGNEES_USER_TITLE", "Update Issue Assignees"), ReadOnlyHint: false, - DestructiveHint: new(false), + DestructiveHint: new(true), // replacing the assignee list removes assignees that are not in it OpenWorldHint: new(true), }, InputSchema: &jsonschema.Schema{ @@ -370,7 +370,7 @@ func GranularUpdateIssueLabels(t translations.TranslationHelperFunc) inventory.S Annotations: &mcp.ToolAnnotations{ Title: t("TOOL_UPDATE_ISSUE_LABELS_USER_TITLE", "Update Issue Labels"), ReadOnlyHint: false, - DestructiveHint: new(false), + DestructiveHint: new(true), // replacing the label list removes labels that are not in it OpenWorldHint: new(true), }, InputSchema: &jsonschema.Schema{