MCPcopy
hub / github.com/github/github-mcp-server / newRepoVisibilityIFCLabeler

Function newRepoVisibilityIFCLabeler

pkg/github/ifc_labels.go:145–171  ·  view source on GitHub ↗

newRepoVisibilityIFCLabeler returns a closure that attaches a repo-visibility IFC label to a tool result, for handlers that have several return paths and want to label each one. The returned function owns the feature-flag gate (so callers invoke it unconditionally) and caches the repository visibili

(
	ctx context.Context,
	deps ToolDependencies,
	client *github.Client,
	owner, repo string,
	labelFn func(isPrivate bool) ifc.SecurityLabel,
)

Source from the content-addressed store, hash-verified

143// a later return path can retry; on persistent failure the label is omitted
144// rather than risking a misclassification.
145func newRepoVisibilityIFCLabeler(
146 ctx context.Context,
147 deps ToolDependencies,
148 client *github.Client,
149 owner, repo string,
150 labelFn func(isPrivate bool) ifc.SecurityLabel,
151) func(*mcp.CallToolResult) *mcp.CallToolResult {
152 var (
153 known bool
154 isPrivate bool
155 )
156 return func(r *mcp.CallToolResult) *mcp.CallToolResult {
157 if r == nil || r.IsError || !deps.IsFeatureEnabled(ctx, FeatureFlagIFCLabels) {
158 return r
159 }
160 if !known {
161 p, err := FetchRepoIsPrivate(ctx, client, owner, repo)
162 if err != nil {
163 return r
164 }
165 isPrivate = p
166 known = true
167 }
168 setIFCLabel(r, labelFn(isPrivate))
169 return r
170 }
171}

Callers 2

GetFileContentsFunction · 0.85
IssueReadFunction · 0.85

Calls 3

FetchRepoIsPrivateFunction · 0.85
setIFCLabelFunction · 0.85
IsFeatureEnabledMethod · 0.65

Tested by

no test coverage detected