Skip to content

Commit 1209da8

Browse files
MayorFajSamMorrowDrumsCopilot
authored
feat: add get_file_blame tool for retrieving git blame information (#1538)
* feat: add get_file_blame tool * feat: implement cursor-based pagination for get_file_blame tool * resolve annotated tags to their target commit in get_file_blame * Regenerate get_file_blame toolsnap and docs after merge with main The cursor-pagination parameter description changed on main; regenerate the toolsnap and README so docs-check and toolsnap tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * 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> --------- Co-authored-by: Sam Morrow <sammorrowdrums@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e0fba89 commit 1209da8

7 files changed

Lines changed: 1176 additions & 1 deletion

File tree

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
---
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "Get file blame information"
5+
},
6+
"description": "Get git blame information for a file, showing the commit that last modified each line. Ranges share commit metadata via the top-level 'commits' map keyed by SHA. Use 'start_line'/'end_line' to restrict the result to a window of the file, and 'perPage'/'after' to cursor-page through returned ranges. Matching ranges are capped at 1000; when the cap is hit 'truncated' is set to true and 'total_ranges' reports the pre-cap match count.",
7+
"inputSchema": {
8+
"properties": {
9+
"after": {
10+
"description": "Cursor for pagination. Use the cursor from the previous response.",
11+
"type": "string"
12+
},
13+
"end_line": {
14+
"description": "Optional 1-based ending line of the window of interest. Must be \u003e= start_line when both are provided.",
15+
"minimum": 1,
16+
"type": "number"
17+
},
18+
"owner": {
19+
"description": "Repository owner (username or organization)",
20+
"type": "string"
21+
},
22+
"path": {
23+
"description": "Path to the file in the repository, relative to the repository root",
24+
"type": "string"
25+
},
26+
"perPage": {
27+
"description": "Results per page for pagination (min 1, max 100)",
28+
"maximum": 100,
29+
"minimum": 1,
30+
"type": "number"
31+
},
32+
"ref": {
33+
"description": "Git reference (branch, tag, or commit SHA). Defaults to the repository's default branch (HEAD).",
34+
"type": "string"
35+
},
36+
"repo": {
37+
"description": "Repository name",
38+
"type": "string"
39+
},
40+
"start_line": {
41+
"description": "Optional 1-based starting line of the window of interest. Only ranges overlapping [start_line, end_line] are returned, clamped to the window.",
42+
"minimum": 1,
43+
"type": "number"
44+
}
45+
},
46+
"required": [
47+
"owner",
48+
"repo",
49+
"path"
50+
],
51+
"type": "object"
52+
},
53+
"name": "get_file_blame"
54+
}

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.

0 commit comments

Comments
 (0)