Skip to content

Commit 4e54bf0

Browse files
committed
fix GetFlags check, move lockdown parsing in WithRequestConfig and fix broken tests
1 parent cc173c3 commit 4e54bf0

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
@@ -26,6 +26,10 @@ func WithRequestConfig(next http.Handler) http.Handler {
2626
ctx = ghcontext.WithTools(ctx, tools)
2727
}
2828

29+
if relaxedParseBool(r.Header.Get(headers.MCPLockdownHeader)) {
30+
ctx = ghcontext.WithLockdownMode(ctx, true)
31+
}
32+
2933
next.ServeHTTP(w, r.WithContext(ctx))
3034
})
3135
}

0 commit comments

Comments
 (0)