Skip to content

Commit cf9dad9

Browse files
committed
Adding GraphQL-Features: update_issue_suggestions
1 parent cfa16b2 commit cf9dad9

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

pkg/github/projects.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strconv"
1111
"time"
1212

13+
ghcontext "github.com/github/github-mcp-server/pkg/context"
1314
ghErrors "github.com/github/github-mcp-server/pkg/errors"
1415
"github.com/github/github-mcp-server/pkg/ifc"
1516
"github.com/github/github-mcp-server/pkg/inventory"
@@ -1272,7 +1273,10 @@ func updateProjectItem(ctx context.Context, client *github.Client, gqlClient *gi
12721273
return utils.NewToolResultError(resolveErr.Error()), nil, nil
12731274
}
12741275

1275-
response, mutationErr := SetIssueFieldValues(ctx, gqlClient, SetIssueFieldValueInput{
1276+
// The setIssueFieldValue mutation is gated behind the update_issue_suggestions
1277+
// GraphQL feature flag, matching the set_issue_fields tool.
1278+
ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "update_issue_suggestions")
1279+
response, mutationErr := SetIssueFieldValues(ctxWithFeatures, gqlClient, SetIssueFieldValueInput{
12761280
IssueID: issueID,
12771281
IssueFields: []IssueFieldCreateOrUpdateInput{*issueField},
12781282
})

pkg/github/projects_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/github/github-mcp-server/internal/githubv4mock"
1010
"github.com/github/github-mcp-server/internal/toolsnaps"
1111
ghErrors "github.com/github/github-mcp-server/pkg/errors"
12+
"github.com/github/github-mcp-server/pkg/http/headers"
13+
transportpkg "github.com/github/github-mcp-server/pkg/http/transport"
1214
"github.com/github/github-mcp-server/pkg/inventory"
1315
"github.com/github/github-mcp-server/pkg/translations"
1416
gogithub "github.com/google/go-github/v89/github"
@@ -1340,7 +1342,7 @@ func Test_ProjectItemReads_FieldNamesIncludeIssueFieldValues(t *testing.T) {
13401342
}
13411343

13421344
func Test_ProjectsWrite_UpdateProjectItem_AttachedIssueFieldDispatch(t *testing.T) {
1343-
gqlClient := githubv4.NewClient(githubv4mock.NewMockedHTTPClient(
1345+
mockClient := githubv4mock.NewMockedHTTPClient(
13441346
githubv4mock.NewQueryMatcher(
13451347
projectFieldsTestQuery{},
13461348
fieldsQueryVars("octo-org", 1),
@@ -1367,7 +1369,12 @@ func Test_ProjectsWrite_UpdateProjectItem_AttachedIssueFieldDispatch(t *testing.
13671369
"issue": map[string]any{"id": "ISSUE_1", "url": "https://github.com/octo-org/repo/issues/1"},
13681370
}}),
13691371
),
1370-
))
1372+
)
1373+
1374+
spy := &headerCaptureTransport{inner: mockClient.Transport}
1375+
gqlClient := githubv4.NewClient(&http.Client{
1376+
Transport: &transportpkg.GraphQLFeaturesTransport{Transport: spy},
1377+
})
13711378
restClient := mustNewGHClient(t, MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
13721379
GetOrgsProjectsV2ItemsByProjectByItemID: mockResponse(t, http.StatusOK, issueProjectItemFixture("Issue")),
13731380
}))
@@ -1384,6 +1391,9 @@ func Test_ProjectsWrite_UpdateProjectItem_AttachedIssueFieldDispatch(t *testing.
13841391
require.NoError(t, err)
13851392
require.False(t, result.IsError, getTextResult(t, result).Text)
13861393
assert.JSONEq(t, `{"id":"ISSUE_1","url":"https://github.com/octo-org/repo/issues/1"}`, getTextResult(t, result).Text)
1394+
// The last request captured is the mutation; the preceding field/metadata
1395+
// queries do not require the update_issue_suggestions feature flag.
1396+
assert.Equal(t, "update_issue_suggestions", spy.captured.Get(headers.GraphQLFeaturesHeader))
13871397
}
13881398

13891399
func Test_BuildIssueFieldUpdate(t *testing.T) {

0 commit comments

Comments
 (0)