Skip to content

Commit aede8e7

Browse files
committed
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
1 parent 9430064 commit aede8e7

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

pkg/github/__toolsnaps__/label_write.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"annotations": {
3+
"destructiveHint": true,
4+
"openWorldHint": true,
35
"title": "Write operations on repository labels"
46
},
57
"description": "Perform write operations on repository labels. To set labels on issues, use the 'update_issue' tool.",

pkg/github/labels.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ func LabelWrite(t translations.TranslationHelperFunc) inventory.ServerTool {
226226
Name: "label_write",
227227
Description: t("TOOL_LABEL_WRITE_DESCRIPTION", "Perform write operations on repository labels. To set labels on issues, use the 'update_issue' tool."),
228228
Annotations: &mcp.ToolAnnotations{
229-
Title: t("TOOL_LABEL_WRITE_TITLE", "Write operations on repository labels"),
230-
ReadOnlyHint: false,
229+
Title: t("TOOL_LABEL_WRITE_TITLE", "Write operations on repository labels"),
230+
ReadOnlyHint: false,
231+
DestructiveHint: jsonschema.Ptr(true),
232+
OpenWorldHint: jsonschema.Ptr(true),
231233
},
232234
InputSchema: &jsonschema.Schema{
233235
Type: "object",

pkg/github/labels_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ func TestWriteLabel(t *testing.T) {
247247
assert.Equal(t, "label_write", tool.Name)
248248
assert.NotEmpty(t, tool.Description)
249249
assert.False(t, tool.Annotations.ReadOnlyHint, "label_write tool should not be read-only")
250+
require.NotNil(t, tool.Annotations.DestructiveHint, "label_write tool should have DestructiveHint set")
251+
assert.True(t, *tool.Annotations.DestructiveHint, "label_write tool should be marked as destructive")
250252

251253
tests := []struct {
252254
name string

0 commit comments

Comments
 (0)