diff --git a/internal/ghmcp/server_test.go b/internal/ghmcp/server_test.go index 1d6f844c41..8a811314f9 100644 --- a/internal/ghmcp/server_test.go +++ b/internal/ghmcp/server_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + ghcontext "github.com/github/github-mcp-server/v2/pkg/context" "github.com/github/github-mcp-server/v2/pkg/github" "github.com/github/github-mcp-server/v2/pkg/observability" "github.com/github/github-mcp-server/v2/pkg/observability/metrics" @@ -36,7 +37,7 @@ func TestCreateGitHubClientsGraphQLUserAgent(t *testing.T) { var query struct { Viewer struct{ Login string } } - require.NoError(t, clients.gql.Query(t.Context(), &query, nil)) + require.NoError(t, clients.gql.Query(ghcontext.WithGraphQLFeatures(t.Context(), "test_feature"), &query, nil)) want := "github-mcp-server/v1.2.3" if insiders { want += " (insiders)" @@ -44,6 +45,7 @@ func TestCreateGitHubClientsGraphQLUserAgent(t *testing.T) { header := <-headers assert.Equal(t, want, header.Get("User-Agent")) assert.Equal(t, "Bearer fixture-token", header.Get("Authorization")) + assert.Equal(t, "test_feature", header.Get("GraphQL-Features")) }) } } @@ -235,7 +237,6 @@ func TestStdioGraphQLUserAgent(t *testing.T) { case header := <-headers: assert.Equal(t, tt.want, header.Get("User-Agent")) assert.Equal(t, "Bearer fixture-token", header.Get("Authorization")) - assert.Equal(t, "issue_fields, repo_issue_fields", header.Get("GraphQL-Features")) case <-ctx.Done(): t.Fatal("GraphQL request did not reach the local HTTP server") } diff --git a/pkg/github/issue_fields.go b/pkg/github/issue_fields.go index 9937f74bfd..93a2a04a48 100644 --- a/pkg/github/issue_fields.go +++ b/pkg/github/issue_fields.go @@ -6,7 +6,6 @@ import ( "fmt" "strconv" - ghcontext "github.com/github/github-mcp-server/v2/pkg/context" ghErrors "github.com/github/github-mcp-server/v2/pkg/errors" "github.com/github/github-mcp-server/v2/pkg/ifc" "github.com/github/github-mcp-server/v2/pkg/inventory" @@ -171,14 +170,13 @@ func ListIssueFields(t translations.TranslationHelperFunc) inventory.ServerTool // If repo is provided, fields are scoped to that repository (inherited from its // organization); otherwise fields are returned directly from the organization. func fetchIssueFields(ctx context.Context, gqlClient *githubv4.Client, owner, repo string) ([]IssueField, error) { - ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "issue_fields", "repo_issue_fields") if repo != "" { var query issueFieldsRepoQuery vars := map[string]any{ "owner": githubv4.String(owner), "name": githubv4.String(repo), } - if err := gqlClient.Query(ctxWithFeatures, &query, vars); err != nil { + if err := gqlClient.Query(ctx, &query, vars); err != nil { return nil, err } return issueFieldsFromNodes(query.Repository.IssueFields.Nodes), nil @@ -188,7 +186,7 @@ func fetchIssueFields(ctx context.Context, gqlClient *githubv4.Client, owner, re vars := map[string]any{ "login": githubv4.String(owner), } - if err := gqlClient.Query(ctxWithFeatures, &query, vars); err != nil { + if err := gqlClient.Query(ctx, &query, vars); err != nil { return nil, err } return issueFieldsFromNodes(query.Organization.IssueFields.Nodes), nil diff --git a/pkg/github/issues.go b/pkg/github/issues.go index 30005854aa..5a5932335e 100644 --- a/pkg/github/issues.go +++ b/pkg/github/issues.go @@ -12,7 +12,6 @@ import ( "strings" "time" - ghcontext "github.com/github/github-mcp-server/v2/pkg/context" ghErrors "github.com/github/github-mcp-server/v2/pkg/errors" "github.com/github/github-mcp-server/v2/pkg/ifc" "github.com/github/github-mcp-server/v2/pkg/inventory" @@ -310,13 +309,12 @@ func resolveIssueRequestFieldValues(ctx context.Context, gqlClient *githubv4.Cli return nil, nil, nil } - ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "issue_fields", "repo_issue_fields") var query issueFieldWriteMetadataQuery vars := map[string]any{ "owner": githubv4.String(owner), "repo": githubv4.String(repo), } - if err := gqlClient.Query(ctxWithFeatures, &query, vars); err != nil { + if err := gqlClient.Query(ctx, &query, vars); err != nil { return nil, nil, fmt.Errorf("failed to query issue fields metadata: %w", err) } @@ -406,8 +404,6 @@ func resolveIssueRequestFieldValues(ctx context.Context, gqlClient *githubv4.Cli // fetchExistingIssueFieldValues retrieves the current field values for an issue // as IssueRequestFieldValue entries, ready to be merged before an update. func fetchExistingIssueFieldValues(ctx context.Context, gqlClient *githubv4.Client, owner, repo string, issueNumber int) ([]*github.IssueRequestFieldValue, error) { - ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "issue_fields", "repo_issue_fields") - var query struct { Repository struct { Issue struct { @@ -424,7 +420,7 @@ func fetchExistingIssueFieldValues(ctx context.Context, gqlClient *githubv4.Clie "number": githubv4.Int(issueNumber), // #nosec G115 - issue numbers are always small positive integers } - if err := gqlClient.Query(ctxWithFeatures, &query, vars); err != nil { + if err := gqlClient.Query(ctx, &query, vars); err != nil { return nil, fmt.Errorf("failed to fetch existing issue field values: %w", err) } @@ -2655,11 +2651,11 @@ var issueWriteFormParams = map[string]struct{}{ } // issueWriteAwaitingFormResult builds the "awaiting form submission" stub -// returned when issue_write hands off to the MCP App form. The body is shared -// by IssueWrite and LegacyIssueWrite. The result is marked IsError=true so -// agents that bail on error don't claim success or chain dependent tool calls -// while the user is still interacting with the form; the host renders the UI -// regardless because rendering is keyed off the tool's _meta.ui resourceUri. +// returned when issue_write hands off to the MCP App form. The result is +// marked IsError=true so agents that bail on error don't claim success or +// chain dependent tool calls while the user is still interacting with the +// form; the host renders the UI regardless because rendering is keyed off the +// tool's _meta.ui resourceUri. func issueWriteAwaitingFormResult(method, owner, repo string, issueNumber int) *mcp.CallToolResult { var msg string if method == "update" { @@ -2684,12 +2680,7 @@ func issueWriteAwaitingFormResult(method, owner, repo string, issueNumber int) * return utils.NewToolResultAwaitingFormSubmission(msg) } -// IssueWrite is the FeatureFlagIssueFields-enabled variant of issue_write -// (with the issue_fields parameter). LegacyIssueWrite is served when the flag -// is off. Both register under the tool name "issue_write"; exactly one is -// active at a time via mutually exclusive feature-flag annotations. When the -// flag is removed, delete LegacyIssueWrite outright and drop the feature-flag -// fields on IssueWrite. +// IssueWrite creates the consolidated issue_write tool. func IssueWrite(t translations.TranslationHelperFunc) inventory.ServerTool { st := NewTool[IssueWriteInput, *IssueWriteOutput]( ToolsetMetadataIssues, @@ -3958,11 +3949,7 @@ func ListIssues(t translations.TranslationHelperFunc) inventory.ServerTool { } issueQuery := getIssueQueryType(hasLabels, hasSince) - // The list_issues query references the issue_fields-gated IssueFieldValueFilter - // input type unconditionally, so we always opt into the feature via header. This - // is a no-op once the flags are globally rolled out. - ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "issue_fields", "repo_issue_fields") - issueFieldsErr := client.Query(ctxWithFeatures, issueQuery, vars) + issueFieldsErr := client.Query(ctx, issueQuery, vars) var resp MinimalIssuesResponse var isPrivate bool diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index 79eeb22100..b12782b038 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -4375,15 +4375,13 @@ func Test_ListIssues_FieldFilters(t *testing.T) { require.False(t, res.IsError, getTextResult(t, res).Text) }) - t.Run("sends GraphQL-Features: issue_fields, repo_issue_fields header", func(t *testing.T) { + t.Run("does not send a GraphQL-Features header", func(t *testing.T) { vars := baseVars() vars["issueFieldValues"] = []any{} matcher := githubv4mock.NewQueryMatcher(qNoLabels, vars, response) // Build a transport chain matching production: GraphQLFeaturesTransport // wraps a header-capturing spy, which forwards to the mock's RoundTripper. - // This verifies the handler sets the issue_fields context value and the - // transport translates it into the outgoing header. mockClient := githubv4mock.NewMockedHTTPClient(matcher) spy := &headerCaptureTransport{inner: mockClient.Transport} httpClient := &http.Client{ @@ -4397,7 +4395,7 @@ func Test_ListIssues_FieldFilters(t *testing.T) { res, err := handler(ContextWithDeps(context.Background(), deps), &req) require.NoError(t, err) require.False(t, res.IsError, getTextResult(t, res).Text) - assert.Equal(t, "issue_fields, repo_issue_fields", spy.captured.Get(headers.GraphQLFeaturesHeader)) + assert.Empty(t, spy.captured.Get(headers.GraphQLFeaturesHeader)) }) } diff --git a/pkg/github/projects_resolver.go b/pkg/github/projects_resolver.go index 9716d36a93..81bf55c0e7 100644 --- a/pkg/github/projects_resolver.go +++ b/pkg/github/projects_resolver.go @@ -6,7 +6,6 @@ import ( "strconv" "strings" - ghcontext "github.com/github/github-mcp-server/v2/pkg/context" ghErrors "github.com/github/github-mcp-server/v2/pkg/errors" "github.com/shurcooL/githubv4" ) @@ -336,15 +335,14 @@ func resolveIssueFieldForUpdate(ctx context.Context, gqlClient *githubv4.Client, } var conn projectIssueFieldMetadataConnection - ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "issue_fields") var queryErr error if ownerType == "org" { var q projectIssueFieldMetadataQueryOrg - queryErr = gqlClient.Query(ctxWithFeatures, &q, vars) + queryErr = gqlClient.Query(ctx, &q, vars) conn = q.Organization.ProjectV2.Fields } else { var q projectIssueFieldMetadataQueryUser - queryErr = gqlClient.Query(ctxWithFeatures, &q, vars) + queryErr = gqlClient.Query(ctx, &q, vars) conn = q.User.ProjectV2.Fields } if queryErr != nil { diff --git a/pkg/github/projects_resolver_test.go b/pkg/github/projects_resolver_test.go index 769572b411..dbce224563 100644 --- a/pkg/github/projects_resolver_test.go +++ b/pkg/github/projects_resolver_test.go @@ -192,7 +192,7 @@ func Test_ResolveIssueFieldForUpdate(t *testing.T) { if tt.wantOption.ID != "" { assert.Equal(t, []ResolvedFieldOption{tt.wantOption}, field.Options) } - assert.Equal(t, "issue_fields", capture.captured.Get(headers.GraphQLFeaturesHeader)) + assert.Empty(t, capture.captured.Get(headers.GraphQLFeaturesHeader)) }) } }