Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/github/__toolsnaps__/update_issue_assignees.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"annotations": {
"destructiveHint": false,
"destructiveHint": true,
"idempotentHint": false,
"openWorldHint": true,
"readOnlyHint": false,
Expand Down
2 changes: 1 addition & 1 deletion pkg/github/__toolsnaps__/update_issue_labels.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"annotations": {
"destructiveHint": false,
"destructiveHint": true,
"idempotentHint": false,
"openWorldHint": true,
"readOnlyHint": false,
Expand Down
25 changes: 25 additions & 0 deletions pkg/github/granular_tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/github/issues_granular.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down