Skip to content

Commit c18f879

Browse files
committed
fix GetFlags check, move lockdown parsing in WithRequestConfig and fix broken tests
1 parent 2dc44cf commit c18f879

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

pkg/github/dependencies.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func (d *RequestDeps) GetT() translations.TranslationHelperFunc { return d.T }
379379
// GetFlags implements ToolDependencies.
380380
func (d *RequestDeps) GetFlags(ctx context.Context) FeatureFlags {
381381
return FeatureFlags{
382-
LockdownMode: ghcontext.IsLockdownMode(ctx),
382+
LockdownMode: d.lockdownMode && ghcontext.IsLockdownMode(ctx),
383383
}
384384
}
385385

pkg/github/feature_flags_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func HelloWorldTool(t translations.TranslationHelperFunc) inventory.ServerTool {
4545
if deps.IsFeatureEnabled(ctx, RemoteMCPEnthusiasticGreeting) {
4646
greeting += " Welcome to the future of MCP! 🎉"
4747
}
48-
if deps.GetFlags().InsiderMode {
48+
if deps.GetFlags(ctx).InsiderMode {
4949
greeting += " Experimental features are enabled! 🚀"
5050
}
5151

pkg/http/handler.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ func withToolset(next http.Handler) http.Handler {
106106
}
107107

108108
func (h *HTTPMcpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
109-
if relaxedParseBool(r.Header.Get(headers.MCPLockdownHeader)) {
110-
r = r.WithContext(ghcontext.WithLockdownMode(r.Context(), true))
111-
}
112-
113109
inventory, err := h.inventoryFactoryFunc(r)
114110
if err != nil {
115111
w.WriteHeader(http.StatusInternalServerError)

pkg/http/middleware/request_config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ func WithRequestConfig(next http.Handler) http.Handler {
2222
ctx = ghcontext.WithToolsets(ctx, toolsets)
2323
}
2424

25+
if relaxedParseBool(r.Header.Get(headers.MCPLockdownHeader)) {
26+
ctx = ghcontext.WithLockdownMode(ctx, true)
27+
}
28+
2529
next.ServeHTTP(w, r.WithContext(ctx))
2630
})
2731
}

0 commit comments

Comments
 (0)