Skip to content

Commit 40849b1

Browse files
refactor: use GraphQLFeaturesTransport internally
Replace inline GraphQL-Features header logic in bearerAuthTransport with the exported GraphQLFeaturesTransport. This removes code duplication and ensures the transport is actually used, not just exported.
1 parent 6cfa8ce commit 40849b1

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

internal/ghmcp/server.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ func createGitHubClients(cfg MCPServerConfig, apiHost apiHost) (*githubClients,
9696
// We use NewEnterpriseClient unconditionally since we already parsed the API host
9797
gqlHTTPClient := &http.Client{
9898
Transport: &bearerAuthTransport{
99-
transport: http.DefaultTransport,
100-
token: cfg.Token,
99+
transport: &github.GraphQLFeaturesTransport{
100+
Transport: http.DefaultTransport,
101+
},
102+
token: cfg.Token,
101103
},
102104
}
103105
gqlClient := githubv4.NewEnterpriseClient(apiHost.graphqlURL.String(), gqlHTTPClient)
@@ -622,12 +624,6 @@ type bearerAuthTransport struct {
622624
func (t *bearerAuthTransport) RoundTrip(req *http.Request) (*http.Response, error) {
623625
req = req.Clone(req.Context())
624626
req.Header.Set("Authorization", "Bearer "+t.token)
625-
626-
// Check for GraphQL-Features in context and add header if present
627-
if features := github.GetGraphQLFeatures(req.Context()); len(features) > 0 {
628-
req.Header.Set("GraphQL-Features", strings.Join(features, ", "))
629-
}
630-
631627
return t.transport.RoundTrip(req)
632628
}
633629

pkg/github/transport.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
// header to requests based on context values. This is required for using
1010
// non-GA GraphQL API features like the agent assignment API.
1111
//
12-
// This transport is exported for use by library consumers who need to build
13-
// their own HTTP clients with GraphQL feature flag support. The MCP server
14-
// itself uses an inline implementation in its transport stack.
12+
// This transport is used internally by the MCP server and is also exported
13+
// for library consumers who need to build their own HTTP clients with
14+
// GraphQL feature flag support.
1515
//
1616
// Usage:
1717
//

0 commit comments

Comments
 (0)