-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Expand file tree
/
Copy pathfeatures.go
More file actions
42 lines (36 loc) · 1.12 KB
/
features.go
File metadata and controls
42 lines (36 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package http
import (
"context"
"slices"
"github.com/github/github-mcp-server/pkg/github"
"github.com/github/github-mcp-server/pkg/inventory"
)
// KnownFeatureFlags are the feature flags that can be enabled via X-MCP-Features header.
var KnownFeatureFlags = []string{
github.FeatureFlagHoldbackConsolidatedProjects,
github.FeatureFlagHoldbackConsolidatedActions,
}
// ComposeFeatureChecker combines header-based feature flags with a static checker.
func ComposeFeatureChecker(headerFeatures []string, staticChecker inventory.FeatureFlagChecker) inventory.FeatureFlagChecker {
if len(headerFeatures) == 0 && staticChecker == nil {
return nil
}
// Only accept header features that are in the known list
headerSet := make(map[string]bool, len(headerFeatures))
for _, f := range headerFeatures {
if slices.Contains(KnownFeatureFlags, f) {
headerSet[f] = true
}
}
return func(ctx context.Context, flag string) (bool, error) {
// Header-based: static string matching
if headerSet[flag] {
return true, nil
}
// Static checker
if staticChecker != nil {
return staticChecker(ctx, flag)
}
return false, nil
}
}