Skip to content

Commit d15026b

Browse files
authored
fix: get_file_contents use "/" for root (github#666)
* update path description to use "/" for root * update docs and toolsnaps * use mcp.DefaultString, revert description, update unit test
1 parent c23b1f9 commit d15026b

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
899899

900900
- **get_file_contents** - Get file or directory contents
901901
- `owner`: Repository owner (username or organization) (string, required)
902-
- `path`: Path to file/directory (directories must end with a slash '/') (string, required)
902+
- `path`: Path to file/directory (directories must end with a slash '/') (string, optional)
903903
- `ref`: Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head` (string, optional)
904904
- `repo`: Repository name (string, required)
905905
- `sha`: Accepts optional commit SHA. If specified, it will be used instead of ref (string, optional)

pkg/github/__toolsnaps__/get_file_contents.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"type": "string"
1212
},
1313
"path": {
14+
"default": "/",
1415
"description": "Path to file/directory (directories must end with a slash '/')",
1516
"type": "string"
1617
},
@@ -29,8 +30,7 @@
2930
},
3031
"required": [
3132
"owner",
32-
"repo",
33-
"path"
33+
"repo"
3434
],
3535
"type": "object"
3636
},

pkg/github/repositories.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ func GetFileContents(getClient GetClientFn, getRawClient raw.GetRawClientFn, t t
462462
mcp.Description("Repository name"),
463463
),
464464
mcp.WithString("path",
465-
mcp.Required(),
466465
mcp.Description("Path to file/directory (directories must end with a slash '/')"),
466+
mcp.DefaultString("/"),
467467
),
468468
mcp.WithString("ref",
469469
mcp.Description("Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head`"),

pkg/github/repositories_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func Test_GetFileContents(t *testing.T) {
3333
assert.Contains(t, tool.InputSchema.Properties, "path")
3434
assert.Contains(t, tool.InputSchema.Properties, "ref")
3535
assert.Contains(t, tool.InputSchema.Properties, "sha")
36-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "path"})
36+
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo"})
3737

3838
// Mock response for raw content
3939
mockRawContent := []byte("# Test Repository\n\nThis is a test repository.")

0 commit comments

Comments
 (0)