Skip to content

Commit 6b232fb

Browse files
feat: gate get_file_blame behind file_blame feature flag
The git blame tool adds a new tool to the inventory, which carries a context-footprint cost for every client. Gate it behind a new file_blame feature flag (user opt-in via --features / X-MCP-Features) that is also auto-enabled in insiders mode, so it is not advertised by default. Regenerated README, feature-flags.md and insiders-features.md docs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7d73541 commit 6b232fb

6 files changed

Lines changed: 40 additions & 12 deletions

File tree

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,17 +1229,6 @@ The following sets of tools are available:
12291229
- `repo`: Repository name (string, required)
12301230
- `sha`: Commit SHA, branch name, or tag name (string, required)
12311231

1232-
- **get_file_blame** - Get file blame information
1233-
- **Required OAuth Scopes**: `repo`
1234-
- `after`: Cursor for pagination. Use the cursor from the previous response. (string, optional)
1235-
- `end_line`: Optional 1-based ending line of the window of interest. Must be >= start_line when both are provided. (number, optional)
1236-
- `owner`: Repository owner (username or organization) (string, required)
1237-
- `path`: Path to the file in the repository, relative to the repository root (string, required)
1238-
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
1239-
- `ref`: Git reference (branch, tag, or commit SHA). Defaults to the repository's default branch (HEAD). (string, optional)
1240-
- `repo`: Repository name (string, required)
1241-
- `start_line`: Optional 1-based starting line of the window of interest. Only ranges overlapping [start_line, end_line] are returned, clamped to the window. (number, optional)
1242-
12431232
- **get_file_contents** - Get file or directory contents
12441233
- **Required OAuth Scopes**: `repo`
12451234
- `owner`: Repository owner (username or organization) (string, required)

docs/feature-flags.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,17 @@ runtime behavior (such as output formatting) won't appear here.
287287
- `repo`: Repository name (string, required)
288288
- `title`: The new title for the pull request (string, required)
289289

290+
### `file_blame`
291+
292+
- **get_file_blame** - Get file blame information
293+
- **Required OAuth Scopes**: `repo`
294+
- `after`: Cursor for pagination. Use the cursor from the previous response. (string, optional)
295+
- `end_line`: Optional 1-based ending line of the window of interest. Must be >= start_line when both are provided. (number, optional)
296+
- `owner`: Repository owner (username or organization) (string, required)
297+
- `path`: Path to the file in the repository, relative to the repository root (string, required)
298+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
299+
- `ref`: Git reference (branch, tag, or commit SHA). Defaults to the repository's default branch (HEAD). (string, optional)
300+
- `repo`: Repository name (string, required)
301+
- `start_line`: Optional 1-based starting line of the window of interest. Only ranges overlapping [start_line, end_line] are returned, clamped to the window. (number, optional)
302+
290303
<!-- END AUTOMATED FEATURE FLAG TOOLS -->

docs/insiders-features.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ The list below is generated from the Go source. It covers tool **inventory and s
107107
- `since`: Filter by date (ISO 8601 timestamp) (string, optional)
108108
- `state`: Filter by state, by default both open and closed issues are returned when not provided (string, optional)
109109

110+
### `file_blame`
111+
112+
- **get_file_blame** - Get file blame information
113+
- **Required OAuth Scopes**: `repo`
114+
- `after`: Cursor for pagination. Use the cursor from the previous response. (string, optional)
115+
- `end_line`: Optional 1-based ending line of the window of interest. Must be >= start_line when both are provided. (number, optional)
116+
- `owner`: Repository owner (username or organization) (string, required)
117+
- `path`: Path to the file in the repository, relative to the repository root (string, required)
118+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
119+
- `ref`: Git reference (branch, tag, or commit SHA). Defaults to the repository's default branch (HEAD). (string, optional)
120+
- `repo`: Repository name (string, required)
121+
- `start_line`: Optional 1-based starting line of the window of interest. Only ranges overlapping [start_line, end_line] are returned, clamped to the window. (number, optional)
122+
110123
<!-- END AUTOMATED INSIDERS TOOLS -->
111124

112125
---

pkg/github/feature_flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const FeatureFlagIFCLabels = "ifc_labels"
1616
// and field_values enrichment in list_issues / search_issues output.
1717
const FeatureFlagIssueFields = "remote_mcp_issue_fields"
1818

19+
// FeatureFlagFileBlame is the feature flag name for the get_file_blame tool,
20+
// which exposes git blame information for a file. It is gated so the extra tool
21+
// is not advertised by default, keeping the tool surface small unless opted in.
22+
const FeatureFlagFileBlame = "file_blame"
23+
1924
// AllowedFeatureFlags is the allowlist of feature flags that can be enabled
2025
// by users via --features CLI flag or X-MCP-Features HTTP header.
2126
// Only flags in this list are accepted; unknown flags are silently ignored.
@@ -27,6 +32,7 @@ var AllowedFeatureFlags = []string{
2732
FeatureFlagIssueFields,
2833
FeatureFlagIssuesGranular,
2934
FeatureFlagPullRequestsGranular,
35+
FeatureFlagFileBlame,
3036
}
3137

3238
// InsidersFeatureFlags is the list of feature flags that insiders mode enables.
@@ -37,6 +43,7 @@ var InsidersFeatureFlags = []string{
3743
MCPAppsFeatureFlag,
3844
FeatureFlagCSVOutput,
3945
FeatureFlagIssueFields,
46+
FeatureFlagFileBlame,
4047
}
4148

4249
// FeatureFlags defines runtime feature toggles that adjust tool behavior.

pkg/github/repositories.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ func validateBlamePath(p string) error {
23842384
}
23852385

23862386
func GetFileBlame(t translations.TranslationHelperFunc) inventory.ServerTool {
2387-
return NewTool(
2387+
st := NewTool(
23882388
ToolsetMetadataRepos,
23892389
mcp.Tool{
23902390
Name: "get_file_blame",
@@ -2679,6 +2679,8 @@ func GetFileBlame(t translations.TranslationHelperFunc) inventory.ServerTool {
26792679
return utils.NewToolResultText(string(payload)), nil, nil
26802680
},
26812681
)
2682+
st.FeatureFlagEnable = FeatureFlagFileBlame
2683+
return st
26822684
}
26832685

26842686
// ListRepositoryCollaborators creates a tool to list collaborators of a GitHub repository.

pkg/github/repositories_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4712,6 +4712,10 @@ func Test_GetFileBlame(t *testing.T) {
47124712
tool := serverTool.Tool
47134713
require.NoError(t, toolsnaps.Test(tool.Name, tool))
47144714

4715+
// get_file_blame is gated so it is not advertised unless the feature flag
4716+
// (or insiders mode) opts it in.
4717+
assert.Equal(t, FeatureFlagFileBlame, serverTool.FeatureFlagEnable, "get_file_blame must be gated behind the file_blame feature flag")
4718+
47154719
schema, ok := tool.InputSchema.(*jsonschema.Schema)
47164720
require.True(t, ok, "InputSchema should be *jsonschema.Schema")
47174721
assert.Equal(t, "get_file_blame", tool.Name)

0 commit comments

Comments
 (0)