File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ package http
2+
3+ import (
4+ "context"
5+ "slices"
6+
7+ "github.com/github/github-mcp-server/pkg/github"
8+ "github.com/github/github-mcp-server/pkg/inventory"
9+ )
10+
11+ // KnownFeatureFlags are the feature flags that can be enabled via X-MCP-Features header.
12+ var KnownFeatureFlags = []string {
13+ github .FeatureFlagConsolidatedProjects ,
14+ github .FeatureFlagConsolidatedActions ,
15+ }
16+
17+ // ComposeFeatureChecker combines header-based feature flags with a static checker.
18+ func ComposeFeatureChecker (headerFeatures []string , staticChecker inventory.FeatureFlagChecker ) inventory.FeatureFlagChecker {
19+ if len (headerFeatures ) == 0 && staticChecker == nil {
20+ return nil
21+ }
22+
23+ // Only accept header features that are in the known list
24+ headerSet := make (map [string ]bool , len (headerFeatures ))
25+ for _ , f := range headerFeatures {
26+ if slices .Contains (KnownFeatureFlags , f ) {
27+ headerSet [f ] = true
28+ }
29+ }
30+
31+ return func (ctx context.Context , flag string ) (bool , error ) {
32+ // Header-based: static string matching
33+ if headerSet [flag ] {
34+ return true , nil
35+ }
36+ // Static checker
37+ if staticChecker != nil {
38+ return staticChecker (ctx , flag )
39+ }
40+ return false , nil
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments