You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add fields param to search_code and get_file_contents
Add an optional `fields` array parameter to the `search_code` and
`get_file_contents` tools so callers can request only the fields they
need, reducing tool response size and context usage.
- search_code: filters each result item to the selected fields while
preserving the total_count / incomplete_results wrapper.
- get_file_contents: filters each directory entry when listing a
directory; ignored for single-file responses.
Adds shared filterFields / filterEachField helpers and per-tool field
enums, plus unit tests and regenerated toolsnaps and docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1255,6 +1255,7 @@ The following sets of tools are available:
1255
1255
1256
1256
-**get_file_contents** - Get file or directory contents
1257
1257
-**Required OAuth Scopes**: `repo`
1258
+
-`fields`: Subset of fields to return for each entry when the path is a directory. If omitted, all fields are returned. Ignored when the path is a single file. Use this to reduce response size when listing directories and you only need specific fields, e.g. just 'name' and 'type'. (string[], optional)
1258
1259
-`owner`: Repository owner (username or organization) (string, required)
1259
1260
-`path`: Path to file/directory (string, optional)
1260
1261
-`ref`: Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head` (string, optional)
@@ -1329,6 +1330,7 @@ The following sets of tools are available:
1329
1330
1330
1331
-**search_code** - Search code
1331
1332
-**Required OAuth Scopes**: `repo`
1333
+
-`fields`: Subset of fields to return for each code search result. If omitted, all fields are returned. Use this to reduce response size when you only need specific fields; omitting 'repository' and 'text_matches' in particular drops the largest per-result data. (string[], optional)
1332
1334
-`order`: Sort order for results (string, optional)
1333
1335
-`page`: Page number for pagination (min 1) (number, optional)
1334
1336
-`perPage`: Results per page for pagination (min 1, max 100) (number, optional)
Copy file name to clipboardExpand all lines: pkg/github/__toolsnaps__/get_file_contents.snap
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,24 @@
6
6
"description": "Get the contents of a file or directory from a GitHub repository",
7
7
"inputSchema": {
8
8
"properties": {
9
+
"fields": {
10
+
"description": "Subset of fields to return for each entry when the path is a directory. If omitted, all fields are returned. Ignored when the path is a single file. Use this to reduce response size when listing directories and you only need specific fields, e.g. just 'name' and 'type'.",
11
+
"items": {
12
+
"enum": [
13
+
"type",
14
+
"name",
15
+
"path",
16
+
"size",
17
+
"sha",
18
+
"url",
19
+
"git_url",
20
+
"html_url",
21
+
"download_url"
22
+
],
23
+
"type": "string"
24
+
},
25
+
"type": "array"
26
+
},
9
27
"owner": {
10
28
"description": "Repository owner (username or organization)",
Copy file name to clipboardExpand all lines: pkg/github/__toolsnaps__/search_code.snap
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,20 @@
6
6
"description": "Fast and precise code search across ALL GitHub repositories using GitHub's native search engine. Best for finding exact symbols, functions, classes, or specific code patterns.",
7
7
"inputSchema": {
8
8
"properties": {
9
+
"fields": {
10
+
"description": "Subset of fields to return for each code search result. If omitted, all fields are returned. Use this to reduce response size when you only need specific fields; omitting 'repository' and 'text_matches' in particular drops the largest per-result data.",
Description: "Accepts optional commit SHA. If specified, it will be used instead of ref",
730
730
},
731
+
"fields": {
732
+
Type: "array",
733
+
Description: "Subset of fields to return for each entry when the path is a directory. If omitted, all fields are returned. Ignored when the path is a single file. Use this to reduce response size when listing directories and you only need specific fields, e.g. just 'name' and 'type'.",
Description: "Subset of fields to return for each code search result. If omitted, all fields are returned. Use this to reduce response size when you only need specific fields; omitting 'repository' and 'text_matches' in particular drops the largest per-result data.",
0 commit comments