diff --git a/README.md b/README.md index 8cff2e138..c5274ff83 100644 --- a/README.md +++ b/README.md @@ -899,7 +899,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - **get_file_contents** - Get file or directory contents - `owner`: Repository owner (username or organization) (string, required) - - `path`: Path to file/directory (directories must end with a slash '/') (string, required) + - `path`: Path to file/directory (directories must end with a slash '/') (string, optional) - `ref`: Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head` (string, optional) - `repo`: Repository name (string, required) - `sha`: Accepts optional commit SHA. If specified, it will be used instead of ref (string, optional) diff --git a/pkg/github/__toolsnaps__/get_file_contents.snap b/pkg/github/__toolsnaps__/get_file_contents.snap index e550e8db8..53f5a29e5 100644 --- a/pkg/github/__toolsnaps__/get_file_contents.snap +++ b/pkg/github/__toolsnaps__/get_file_contents.snap @@ -11,6 +11,7 @@ "type": "string" }, "path": { + "default": "/", "description": "Path to file/directory (directories must end with a slash '/')", "type": "string" }, @@ -29,8 +30,7 @@ }, "required": [ "owner", - "repo", - "path" + "repo" ], "type": "object" }, diff --git a/pkg/github/repositories.go b/pkg/github/repositories.go index 732f20ab1..186bd2321 100644 --- a/pkg/github/repositories.go +++ b/pkg/github/repositories.go @@ -462,8 +462,8 @@ func GetFileContents(getClient GetClientFn, getRawClient raw.GetRawClientFn, t t mcp.Description("Repository name"), ), mcp.WithString("path", - mcp.Required(), mcp.Description("Path to file/directory (directories must end with a slash '/')"), + mcp.DefaultString("/"), ), mcp.WithString("ref", mcp.Description("Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head`"), diff --git a/pkg/github/repositories_test.go b/pkg/github/repositories_test.go index 0b9c5d9f9..4977bb0a9 100644 --- a/pkg/github/repositories_test.go +++ b/pkg/github/repositories_test.go @@ -33,7 +33,7 @@ func Test_GetFileContents(t *testing.T) { assert.Contains(t, tool.InputSchema.Properties, "path") assert.Contains(t, tool.InputSchema.Properties, "ref") assert.Contains(t, tool.InputSchema.Properties, "sha") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "path"}) + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo"}) // Mock response for raw content mockRawContent := []byte("# Test Repository\n\nThis is a test repository.")